diff options
author | Jonas Hahnfeld <hahnjo@hahnjo.de> | 2017-11-11 13:59:48 +0000 |
---|---|---|
committer | Jonas Hahnfeld <hahnjo@hahnjo.de> | 2017-11-11 13:59:48 +0000 |
commit | d0ef19ef9b2c4c61ecd10b133632c795c3bc2d31 (patch) | |
tree | 0887d4ea63782e1a28eaca6791a334261bbc6998 /openmp/runtime/cmake | |
parent | 3acaa701adbb0820d968ffcd4886e443f9fe9ca3 (diff) | |
download | bcm5719-llvm-d0ef19ef9b2c4c61ecd10b133632c795c3bc2d31.tar.gz bcm5719-llvm-d0ef19ef9b2c4c61ecd10b133632c795c3bc2d31.zip |
[OMPT] Provide initialization for Mac OS X
Traditionally, the library had a weak symbol for ompt_start_tool()
that served as fallback and disabled OMPT if called. Tools could
provide their own version and replace the default implementation
to register callbacks and lookup functions. This mechanism has
worked reasonably well on Linux systems where this interface was
initially developed.
On Darwin / Mac OS X the situation is a bit more complicated and
the weak symbol doesn't work out-of-the-box. In my tests, the
library with the tool needed to link against the OpenMP runtime
to make the process work. This would effectively mean that a tool
needed to choose a runtime library whereas one design goal of the
interface was to allow tools that are agnostic of the runtime.
The solution is to use dlsym() with the argument RTLD_DEFAULT so
that static implementations of ompt_start_tool() are found in the
main executable. This works because the linker on Mac OS X includes
all symbols of an executable in the global symbol table by default.
To use the same code path on Linux, the application would need to
be built with -Wl,--export-dynamic. To avoid this restriction, we
continue to use weak symbols on Linux systems as before.
Finally this patch extends the existing test to cover all possible
ways of initializing the tool as described by the standard. It
also fixes ompt_finalize() to not call omp_get_thread_num() when
the library is shut down which resulted in hangs on Darwin.
The changes have been tested on Linux to make sure that it passes
the current tests as well as the newly extended one.
Differential Revision: https://reviews.llvm.org/D39801
llvm-svn: 317980
Diffstat (limited to 'openmp/runtime/cmake')
-rw-r--r-- | openmp/runtime/cmake/config-ix.cmake | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/openmp/runtime/cmake/config-ix.cmake b/openmp/runtime/cmake/config-ix.cmake index 0375d211b75..eb886ca54e2 100644 --- a/openmp/runtime/cmake/config-ix.cmake +++ b/openmp/runtime/cmake/config-ix.cmake @@ -223,7 +223,7 @@ endif() # Check if OMPT support is available # Currently, __builtin_frame_address() is required for OMPT -# Weak attribute is required for Unices, LIBPSAPI is used for Windows +# Weak attribute is required for Unices (except Darwin), LIBPSAPI is used for Windows check_c_source_compiles("int main(int argc, char** argv) { void* p = __builtin_frame_address(0); return 0;}" LIBOMP_HAVE___BUILTIN_FRAME_ADDRESS) @@ -238,7 +238,7 @@ endif() if(NOT LIBOMP_HAVE___BUILTIN_FRAME_ADDRESS) set(LIBOMP_HAVE_OMPT_SUPPORT FALSE) else() - if(LIBOMP_HAVE_WEAK_ATTRIBUTE OR LIBOMP_HAVE_PSAPI) + if((WIN32 AND LIBOMP_HAVE_PSAPI) OR APPLE OR (NOT WIN32 AND LIBOMP_HAVE_WEAK_ATTRIBUTE)) set(LIBOMP_HAVE_OMPT_SUPPORT TRUE) else() set(LIBOMP_HAVE_OMPT_SUPPORT FALSE) |