diff options
author | Jonathan Peyton <jonathan.l.peyton@intel.com> | 2015-11-30 20:02:59 +0000 |
---|---|---|
committer | Jonathan Peyton <jonathan.l.peyton@intel.com> | 2015-11-30 20:02:59 +0000 |
commit | 01dcf36bd54be75dcf6c3cc9cc8d1f20e783d86a (patch) | |
tree | 538111ad7545036c7e9d75ab83e37da63b4ddaa9 /openmp/runtime/cmake | |
parent | 7a096596b2eead02405329a5504b0d71dd5b4a8d (diff) | |
download | bcm5719-llvm-01dcf36bd54be75dcf6c3cc9cc8d1f20e783d86a.tar.gz bcm5719-llvm-01dcf36bd54be75dcf6c3cc9cc8d1f20e783d86a.zip |
Adding Hwloc library option for affinity mechanism
These changes allow libhwloc to be used as the topology discovery/affinity
mechanism for libomp. It is supported on Unices. The code additions:
* Canonicalize KMP_CPU_* interface macros so bitmask operations are
implementation independent and work with both hwloc bitmaps and libomp
bitmaps. So there are new KMP_CPU_ALLOC_* and KMP_CPU_ITERATE() macros and
the like. These are all in kmp.h and appropriately placed.
* Hwloc topology discovery code in kmp_affinity.cpp. This uses the hwloc
interface to create a libomp address2os object which the rest of libomp knows
how to handle already.
* To build, use -DLIBOMP_USE_HWLOC=on and
-DLIBOMP_HWLOC_INSTALL_DIR=/path/to/install/dir [default /usr/local]. If CMake
can't find the library or hwloc.h, then it will tell you and exit.
Differential Revision: http://reviews.llvm.org/D13991
llvm-svn: 254320
Diffstat (limited to 'openmp/runtime/cmake')
-rw-r--r-- | openmp/runtime/cmake/LibompHandleFlags.cmake | 1 | ||||
-rw-r--r-- | openmp/runtime/cmake/LibompMicroTests.cmake | 6 | ||||
-rw-r--r-- | openmp/runtime/cmake/config-ix.cmake | 23 |
3 files changed, 30 insertions, 0 deletions
diff --git a/openmp/runtime/cmake/LibompHandleFlags.cmake b/openmp/runtime/cmake/LibompHandleFlags.cmake index 19bcea47036..8fb524fdb29 100644 --- a/openmp/runtime/cmake/LibompHandleFlags.cmake +++ b/openmp/runtime/cmake/LibompHandleFlags.cmake @@ -151,6 +151,7 @@ endfunction() function(libomp_get_libflags libflags) set(libflags_local) libomp_append(libflags_local "${CMAKE_THREAD_LIBS_INIT}") + libomp_append(libflags_local "${LIBOMP_HWLOC_LIBRARY}" LIBOMP_USE_HWLOC) if(${IA32}) libomp_append(libflags_local -lirc_pic LIBOMP_HAVE_IRC_PIC_LIBRARY) endif() diff --git a/openmp/runtime/cmake/LibompMicroTests.cmake b/openmp/runtime/cmake/LibompMicroTests.cmake index 4087703f387..89ca83d8689 100644 --- a/openmp/runtime/cmake/LibompMicroTests.cmake +++ b/openmp/runtime/cmake/LibompMicroTests.cmake @@ -82,10 +82,13 @@ else() # (Unix based systems, Intel(R) MIC Architecture, and Mac) libomp_append(libomp_test_touch_cflags -m32 LIBOMP_HAVE_M32_FLAG) endif() libomp_append(libomp_test_touch_libs ${LIBOMP_OUTPUT_DIRECTORY}/${LIBOMP_LIB_FILE}) + libomp_append(libomp_test_touch_libs "${LIBOMP_HWLOC_LIBRARY}" LIBOMP_USE_HWLOC) if(APPLE) set(libomp_test_touch_env "DYLD_LIBRARY_PATH=.:${LIBOMP_OUTPUT_DIRECTORY}:$ENV{DYLD_LIBRARY_PATH}") + libomp_append(libomp_test_touch_ldflags "-Wl,-rpath,${LIBOMP_HWLOC_LIBRARY_DIR}" LIBOMP_USE_HWLOC) else() set(libomp_test_touch_env "LD_LIBRARY_PATH=.:${LIBOMP_OUTPUT_DIRECTORY}:$ENV{LD_LIBRARY_PATH}") + libomp_append(libomp_test_touch_ldflags "-Wl,-rpath=${LIBOMP_HWLOC_LIBRARY_DIR}" LIBOMP_USE_HWLOC) endif() endif() macro(libomp_test_touch_recipe test_touch_dir) @@ -169,8 +172,10 @@ add_custom_target(libomp-test-deps DEPENDS test-deps/.success) set(libomp_expected_library_deps) if(CMAKE_SYSTEM_NAME MATCHES "FreeBSD") set(libomp_expected_library_deps libc.so.7 libthr.so.3) + libomp_append(libomp_expected_library_deps libhwloc.so.5 LIBOMP_USE_HWLOC) elseif(CMAKE_SYSTEM_NAME MATCHES "NetBSD") set(libomp_expected_library_deps libc.so.12 libpthread.so.1 libm.so.0) + libomp_append(libomp_expected_library_deps libhwloc.so.5 LIBOMP_USE_HWLOC) elseif(APPLE) set(libomp_expected_library_deps /usr/lib/libSystem.B.dylib) elseif(WIN32) @@ -203,6 +208,7 @@ else() libomp_append(libomp_expected_library_deps ld64.so.1) endif() libomp_append(libomp_expected_library_deps libpthread.so.0 IF_FALSE STUBS_LIBRARY) + libomp_append(libomp_expected_library_deps libhwloc.so.5 LIBOMP_USE_HWLOC) endif() libomp_append(libomp_expected_library_deps libstdc++.so.6 LIBOMP_USE_STDCPPLIB) endif() diff --git a/openmp/runtime/cmake/config-ix.cmake b/openmp/runtime/cmake/config-ix.cmake index 9c7848b3bcf..eccb8634b3b 100644 --- a/openmp/runtime/cmake/config-ix.cmake +++ b/openmp/runtime/cmake/config-ix.cmake @@ -12,6 +12,7 @@ include(CheckCCompilerFlag) include(CheckCSourceCompiles) include(CheckCXXCompilerFlag) +include(CheckIncludeFile) include(CheckLibraryExists) include(CheckIncludeFiles) include(LibompCheckLinkerFlag) @@ -211,3 +212,25 @@ else() endif() endif() +# Check if HWLOC support is available +if(${LIBOMP_USE_HWLOC}) + if(WIN32) + set(LIBOMP_HAVE_HWLOC FALSE) + libomp_say("Using hwloc not supported on Windows yet") + else() + set(CMAKE_REQUIRED_INCLUDES ${LIBOMP_HWLOC_INSTALL_DIR}/include) + check_include_file(hwloc.h LIBOMP_HAVE_HWLOC_H) + set(CMAKE_REQUIRED_INCLUDES) + check_library_exists(hwloc hwloc_topology_init + ${LIBOMP_HWLOC_INSTALL_DIR}/lib LIBOMP_HAVE_LIBHWLOC) + find_library(LIBOMP_HWLOC_LIBRARY hwloc ${LIBOMP_HWLOC_INSTALL_DIR}/lib) + get_filename_component(LIBOMP_HWLOC_LIBRARY_DIR ${LIBOMP_HWLOC_LIBRARY} PATH) + if(LIBOMP_HAVE_HWLOC_H AND LIBOMP_HAVE_LIBHWLOC AND LIBOMP_HWLOC_LIBRARY) + set(LIBOMP_HAVE_HWLOC TRUE) + else() + set(LIBOMP_HAVE_HWLOC FALSE) + libomp_say("Could not find hwloc") + endif() + endif() +endif() + |