summaryrefslogtreecommitdiffstats
path: root/openmp/runtime/cmake
diff options
context:
space:
mode:
authorJonathan Peyton <jonathan.l.peyton@intel.com>2015-10-29 20:56:24 +0000
committerJonathan Peyton <jonathan.l.peyton@intel.com>2015-10-29 20:56:24 +0000
commit69e596a5e7dc0038191a7d10cddf7c6cf77f4ff7 (patch)
tree7d0c4f9eb892ee53f9dd3fc2a80eec96f8e90a73 /openmp/runtime/cmake
parente8df6750f434af5ce85a8683e6dea445973c9eb7 (diff)
downloadbcm5719-llvm-69e596a5e7dc0038191a7d10cddf7c6cf77f4ff7.tar.gz
bcm5719-llvm-69e596a5e7dc0038191a7d10cddf7c6cf77f4ff7.zip
[OMPT] Windows Support for OMPT
The problem is that the ompt_tool() function (which must be implemented by a performance tool) should be defined in the RTL as well to cover the case when the tool is not present in the address space of the process. This functionality is accomplished with weak symbols in Unices. Unfortunately, Windows does not support weak symbols. The solution in these changes is to grab the list of all modules loaded by the process and then search for symbol "ompt_tool()" within them. The function ompt_tool_windows() performs the search of the ompt_tool symbol. If ompt_tool is found, then its return value is used to initialize the tool. If ompt_tool is not found, then ompt_tool_windows() returns NULL and OMPT is thus, disabled. While doing these changes, the OMPT_SUPPORT detection in CMake was changed to test for the required featuers for OMPT_SUPPORT, namely: builtin_frame_address() existence, weak attribute existence and psapi.dll existence. For LIBOMP_HAVE_OMPT_SUPPORT to be true, it must be that the builtin_frame_address() intrinsic exists AND one of: either weak attributes exist or psapi.dll exists. Also, since Process Status API is used I had to add new dependency -- psapi.dll to the library dependency micro test. Differential Revision: http://reviews.llvm.org/D14027 llvm-svn: 251654
Diffstat (limited to 'openmp/runtime/cmake')
-rw-r--r--openmp/runtime/cmake/LibompMicroTests.cmake1
-rw-r--r--openmp/runtime/cmake/config-ix.cmake25
2 files changed, 23 insertions, 3 deletions
diff --git a/openmp/runtime/cmake/LibompMicroTests.cmake b/openmp/runtime/cmake/LibompMicroTests.cmake
index dd24748766b..4087703f387 100644
--- a/openmp/runtime/cmake/LibompMicroTests.cmake
+++ b/openmp/runtime/cmake/LibompMicroTests.cmake
@@ -175,6 +175,7 @@ elseif(APPLE)
set(libomp_expected_library_deps /usr/lib/libSystem.B.dylib)
elseif(WIN32)
set(libomp_expected_library_deps kernel32.dll)
+ libomp_append(libomp_expected_library_deps psapi.dll LIBOMP_OMPT_SUPPORT)
else()
if(${MIC})
set(libomp_expected_library_deps libc.so.6 libpthread.so.0 libdl.so.2)
diff --git a/openmp/runtime/cmake/config-ix.cmake b/openmp/runtime/cmake/config-ix.cmake
index 875b5519a26..9c7848b3bcf 100644
--- a/openmp/runtime/cmake/config-ix.cmake
+++ b/openmp/runtime/cmake/config-ix.cmake
@@ -13,6 +13,7 @@ include(CheckCCompilerFlag)
include(CheckCSourceCompiles)
include(CheckCXXCompilerFlag)
include(CheckLibraryExists)
+include(CheckIncludeFiles)
include(LibompCheckLinkerFlag)
include(LibompCheckFortranFlag)
@@ -187,8 +188,26 @@ else()
endif()
# Check if OMPT support is available
-if(NOT WIN32)
- set(LIBOMP_HAVE_OMPT_SUPPORT TRUE)
-else()
+# Currently, __builtin_frame_address() is required for OMPT
+# Weak attribute is required for Unices, 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)
+check_c_source_compiles("__attribute__ ((weak)) int foo(int a) { return a*a; }
+ int main(int argc, char** argv) {
+ return foo(argc);}" LIBOMP_HAVE_WEAK_ATTRIBUTE)
+check_include_files("windows.h;psapi.h" LIBOMP_HAVE_PSAPI_H)
+check_library_exists(psapi EnumProcessModules "" LIBOMP_HAVE_LIBPSAPI)
+if(LIBOMP_HAVE_PSAPI_H AND LIBOMP_HAVE_LIBPSAPI)
+ set(LIBOMP_HAVE_PSAPI TRUE)
+endif()
+if(NOT LIBOMP_HAVE___BUILTIN_FRAME_ADDRESS)
set(LIBOMP_HAVE_OMPT_SUPPORT FALSE)
+else()
+ if(LIBOMP_HAVE_WEAK_ATTRIBUTE OR LIBOMP_HAVE_PSAPI)
+ set(LIBOMP_HAVE_OMPT_SUPPORT TRUE)
+ else()
+ set(LIBOMP_HAVE_OMPT_SUPPORT FALSE)
+ endif()
endif()
+
OpenPOWER on IntegriCloud