make (dev-)tests build support for threading libraries in threadmode=SEQ

Issue #451 resolved
Dan Bonachea created an issue

As documented in docs/implementation-defined.md, we now have documented support for correctly and safely issuing UPC++ calls in multi-threaded programs built against the UPCXX_THREADMODE=seq UPC++ library, provided those programs follow a few simple restrictions.

We even have several multi-threaded tests that "follow the rules" in order to exercise that support, namely:

However, our make (dev-)tests infrastructure currently lacks the build logic to portably build these tests in SEQ mode with appropriate threading libraries, and consequently these tests are currently skipped in SEQ mode (harness does the same, for similar reasons). This means that at present we effectively have no automated test coverage for this "multithreaded SEQ" operation mode.

The underlying problem here, discussed in related issue #319, is that some systems need -lpthread or -pthread added to the link line in order to successfully link programs invoking std::thread, and there is no one fixed recipe that reliably works for all supported platforms. GASNet's PAR-mode Makefile fragments automatically provide the correct incantation into upcxx-meta LIBS/LDFLAGS, but this is usually missing in UPCXX_THREADMODE=seq which uses the GASNet SEQ-mode fragments.

Fixing this probably means having Makefile.tests extract @GASNET_THREAD_LIBS@ (and possibly @GASNET_THREAD_DEFINES@?) and conditionally adding these to the test build commands (conditional on a new opt-in list of multi-threaded SEQ-safe tests).

Comments (3)

  1. Paul Hargrove

    Fixing this probably means having Makefile.tests extract @GASNET_THREAD_LIBS@ (and possibly @GASNET_THREAD_DEFINES@?) ...

    I believe that requires no more than adding corresponding lines to bld/gasnet_config.mak.in

    ... and conditionally adding these to the test build commands (conditional on a new opt-in list of multi-threaded SEQ-safe tests).

    Sounds like a job for the same idiom currently applied to $(test_pgi_debug_symbols_broken) in tests.mak

    So, overall it doesn't sound to me like a daunting task to provide what has been asked for so far (under 10 lines, I am guessing)

    I do have a minor concern over the backend compiler behavior when the arguments are doubled as can happen for two reasons I can think of:

    1. Lacking distinct $(TEST_FLAGS_[TEST]) for SEQ vs PAR, the PAR builds will double the flags
    2. Even with distinct flags for SEQ vs PAR, the SEQ fragments for IBV and UCX already include the GASNET_THREAD_* settings

    That said, I've confirmed that current g++, clang++, icpc and pgc++ are all OK with [foo++] -D_REENTRANT -D_REENTRANT -lpthread -lpthread hello.cc, so there is probably no reason to be concerned until/unless we encounter a problem.

  2. Log in to comment