llvm-project/openmp/runtime/cmake
Jonas Hahnfeld d0ef19ef9b [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
2017-11-11 13:59:48 +00:00
..
LibompCheckFortranFlag.cmake Re-indent the CMake refactor to two-space indention 2015-07-15 16:57:19 +00:00
LibompCheckLinkerFlag.cmake [CMake] Fix libomp_check_linker_flag function 2015-07-23 14:41:35 +00:00
LibompDefinitions.cmake Revert r273898's UNICODE quick fix in favor of CMake's remove_definitions() 2016-06-28 19:25:13 +00:00
LibompExports.cmake [OMPT] Purge OMPT_BLAME and OMPT_TRACE 2017-11-10 15:17:57 +00:00
LibompGetArchitecture.cmake Support of mips & mips64 for openmprtl 2016-12-08 09:22:24 +00:00
LibompHandleFlags.cmake OpenMP version 5.0 added 2017-03-06 22:07:40 +00:00
LibompMicroTests.cmake Support of mips & mips64 for openmprtl 2016-12-08 09:22:24 +00:00
LibompUtils.cmake Change source files from .c to .cpp 2016-12-14 22:39:11 +00:00
config-ix.cmake [OMPT] Provide initialization for Mac OS X 2017-11-11 13:59:48 +00:00