[Openmp-commits] [PATCH] D39801: [OMPT] Provide initialization for Mac OS X
Jonas Hahnfeld via Phabricator via Openmp-commits
openmp-commits at lists.llvm.org
Wed Nov 8 07:21:33 PST 2017
Hahnfeld created this revision.
Herald added a subscriber: mgorny.
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.
https://reviews.llvm.org/D39801
Files:
runtime/cmake/config-ix.cmake
runtime/src/ompt-general.cpp
runtime/test/lit.cfg
runtime/test/ompt/loadtool/tool_available.c
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D39801.122092.patch
Type: text/x-patch
Size: 9884 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/openmp-commits/attachments/20171108/83a4cb84/attachment.bin>
More information about the Openmp-commits
mailing list