2015-07-16 00:05:30 +08:00
|
|
|
#
|
|
|
|
#//===----------------------------------------------------------------------===//
|
|
|
|
#//
|
2019-01-19 18:56:40 +08:00
|
|
|
#// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
#// See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
#// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
2015-07-16 00:05:30 +08:00
|
|
|
#//
|
|
|
|
#//===----------------------------------------------------------------------===//
|
|
|
|
#
|
|
|
|
|
|
|
|
include(CheckCCompilerFlag)
|
|
|
|
include(CheckCSourceCompiles)
|
2020-12-02 04:03:40 +08:00
|
|
|
include(CheckCXXSourceCompiles)
|
2015-07-16 00:05:30 +08:00
|
|
|
include(CheckCXXCompilerFlag)
|
2015-12-01 04:02:59 +08:00
|
|
|
include(CheckIncludeFile)
|
2015-07-16 00:05:30 +08:00
|
|
|
include(CheckLibraryExists)
|
2015-10-30 04:56:24 +08:00
|
|
|
include(CheckIncludeFiles)
|
2020-10-27 00:02:21 +08:00
|
|
|
include(CheckSymbolExists)
|
2015-07-16 00:05:30 +08:00
|
|
|
include(LibompCheckLinkerFlag)
|
|
|
|
include(LibompCheckFortranFlag)
|
|
|
|
|
|
|
|
# Check for versioned symbols
|
|
|
|
function(libomp_check_version_symbols retval)
|
2015-07-16 00:57:19 +08:00
|
|
|
set(source_code
|
|
|
|
"#include <stdio.h>
|
|
|
|
void func1() { printf(\"Hello\"); }
|
|
|
|
void func2() { printf(\"World\"); }
|
|
|
|
__asm__(\".symver func1, func@VER1\");
|
|
|
|
__asm__(\".symver func2, func@VER2\");
|
|
|
|
int main() {
|
|
|
|
func1();
|
|
|
|
func2();
|
|
|
|
return 0;
|
|
|
|
}")
|
|
|
|
set(version_script_source "VER1 { }; VER2 { } VER1;")
|
|
|
|
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/__version_script.txt "${version_script_source}")
|
|
|
|
set(CMAKE_REQUIRED_FLAGS -Wl,--version-script=${CMAKE_CURRENT_BINARY_DIR}/__version_script.txt)
|
|
|
|
check_c_source_compiles("${source_code}" ${retval})
|
|
|
|
set(${retval} ${${retval}} PARENT_SCOPE)
|
|
|
|
file(REMOVE ${CMAKE_CURRENT_BINARY_DIR}/__version_script.txt)
|
2015-07-16 00:05:30 +08:00
|
|
|
endfunction()
|
|
|
|
|
|
|
|
# Includes the architecture flag in both compile and link phase
|
|
|
|
function(libomp_check_architecture_flag flag retval)
|
2015-07-16 00:57:19 +08:00
|
|
|
set(CMAKE_REQUIRED_FLAGS "${flag}")
|
|
|
|
check_c_compiler_flag("${flag}" ${retval})
|
|
|
|
set(${retval} ${${retval}} PARENT_SCOPE)
|
2015-07-16 00:05:30 +08:00
|
|
|
endfunction()
|
|
|
|
|
[OpenMP] Turn on -Wall compiler warnings by default
Instead, maintain a list of disabled options to still build libomp and
libomptarget without warnings. This includes -Wno-error and -Wno-pedantic
to silence warnings that LLVM enables when building in-tree.
I tested the following compilers:
* Clang 6.0, 7.0, 8.0
* GCC 4.8.5 (CentOS 7), GCC 6, 7, 8, 9
* Intel Compiler 16, 17, 18, 19
RFC thread on openmp-dev mailing list:
http://lists.llvm.org/pipermail/openmp-dev/2019-August/002668.html
Differential Revision: https://reviews.llvm.org/D65867
llvm-svn: 368999
2019-08-15 21:11:50 +08:00
|
|
|
# Checking CXX, Linker Flags
|
2015-07-16 00:05:30 +08:00
|
|
|
check_cxx_compiler_flag(-fno-exceptions LIBOMP_HAVE_FNO_EXCEPTIONS_FLAG)
|
2016-11-15 05:08:35 +08:00
|
|
|
check_cxx_compiler_flag(-fno-rtti LIBOMP_HAVE_FNO_RTTI_FLAG)
|
[OpenMP] Turn on -Wall compiler warnings by default
Instead, maintain a list of disabled options to still build libomp and
libomptarget without warnings. This includes -Wno-error and -Wno-pedantic
to silence warnings that LLVM enables when building in-tree.
I tested the following compilers:
* Clang 6.0, 7.0, 8.0
* GCC 4.8.5 (CentOS 7), GCC 6, 7, 8, 9
* Intel Compiler 16, 17, 18, 19
RFC thread on openmp-dev mailing list:
http://lists.llvm.org/pipermail/openmp-dev/2019-August/002668.html
Differential Revision: https://reviews.llvm.org/D65867
llvm-svn: 368999
2019-08-15 21:11:50 +08:00
|
|
|
check_cxx_compiler_flag(-Wno-class-memaccess LIBOMP_HAVE_WNO_CLASS_MEMACCESS_FLAG)
|
|
|
|
check_cxx_compiler_flag(-Wno-covered-switch-default LIBOMP_HAVE_WNO_COVERED_SWITCH_DEFAULT_FLAG)
|
|
|
|
check_cxx_compiler_flag(-Wno-frame-address LIBOMP_HAVE_WNO_FRAME_ADDRESS_FLAG)
|
|
|
|
check_cxx_compiler_flag(-Wno-strict-aliasing LIBOMP_HAVE_WNO_STRICT_ALIASING_FLAG)
|
|
|
|
check_cxx_compiler_flag(-Wstringop-overflow=0 LIBOMP_HAVE_WSTRINGOP_OVERFLOW_FLAG)
|
|
|
|
check_cxx_compiler_flag(-Wno-stringop-truncation LIBOMP_HAVE_WNO_STRINGOP_TRUNCATION_FLAG)
|
|
|
|
check_cxx_compiler_flag(-Wno-switch LIBOMP_HAVE_WNO_SWITCH_FLAG)
|
|
|
|
check_cxx_compiler_flag(-Wno-uninitialized LIBOMP_HAVE_WNO_UNINITIALIZED_FLAG)
|
|
|
|
check_cxx_compiler_flag(-Wno-unused-but-set-variable LIBOMP_HAVE_WNO_UNUSED_BUT_SET_VARIABLE_FLAG)
|
2021-02-12 17:38:25 +08:00
|
|
|
check_cxx_compiler_flag(-Wno-return-type-c-linkage LIBOMP_HAVE_WNO_RETURN_TYPE_C_LINKAGE_FLAG)
|
|
|
|
check_cxx_compiler_flag(-Wno-cast-qual LIBOMP_HAVE_WNO_CAST_QUAL_FLAG)
|
|
|
|
check_cxx_compiler_flag(-Wno-int-to-void-pointer-cast LIBOMP_HAVE_WNO_INT_TO_VOID_POINTER_CAST_FLAG)
|
2020-12-31 05:39:48 +08:00
|
|
|
# check_cxx_compiler_flag(-Wconversion LIBOMP_HAVE_WCONVERSION_FLAG)
|
[OpenMP] Turn on -Wall compiler warnings by default
Instead, maintain a list of disabled options to still build libomp and
libomptarget without warnings. This includes -Wno-error and -Wno-pedantic
to silence warnings that LLVM enables when building in-tree.
I tested the following compilers:
* Clang 6.0, 7.0, 8.0
* GCC 4.8.5 (CentOS 7), GCC 6, 7, 8, 9
* Intel Compiler 16, 17, 18, 19
RFC thread on openmp-dev mailing list:
http://lists.llvm.org/pipermail/openmp-dev/2019-August/002668.html
Differential Revision: https://reviews.llvm.org/D65867
llvm-svn: 368999
2019-08-15 21:11:50 +08:00
|
|
|
check_cxx_compiler_flag(-msse2 LIBOMP_HAVE_MSSE2_FLAG)
|
|
|
|
check_cxx_compiler_flag(-ftls-model=initial-exec LIBOMP_HAVE_FTLS_MODEL_FLAG)
|
2015-07-16 00:05:30 +08:00
|
|
|
libomp_check_architecture_flag(-mmic LIBOMP_HAVE_MMIC_FLAG)
|
|
|
|
libomp_check_architecture_flag(-m32 LIBOMP_HAVE_M32_FLAG)
|
|
|
|
if(WIN32)
|
2018-12-10 21:45:00 +08:00
|
|
|
if(MSVC)
|
|
|
|
# Check Windows MSVC style flags.
|
|
|
|
check_cxx_compiler_flag(/EHsc LIBOMP_HAVE_EHSC_FLAG)
|
|
|
|
check_cxx_compiler_flag(/GS LIBOMP_HAVE_GS_FLAG)
|
|
|
|
check_cxx_compiler_flag(/Oy- LIBOMP_HAVE_Oy__FLAG)
|
|
|
|
check_cxx_compiler_flag(/arch:SSE2 LIBOMP_HAVE_ARCH_SSE2_FLAG)
|
|
|
|
check_cxx_compiler_flag(/Qsafeseh LIBOMP_HAVE_QSAFESEH_FLAG)
|
|
|
|
endif()
|
[OpenMP] Turn on -Wall compiler warnings by default
Instead, maintain a list of disabled options to still build libomp and
libomptarget without warnings. This includes -Wno-error and -Wno-pedantic
to silence warnings that LLVM enables when building in-tree.
I tested the following compilers:
* Clang 6.0, 7.0, 8.0
* GCC 4.8.5 (CentOS 7), GCC 6, 7, 8, 9
* Intel Compiler 16, 17, 18, 19
RFC thread on openmp-dev mailing list:
http://lists.llvm.org/pipermail/openmp-dev/2019-August/002668.html
Differential Revision: https://reviews.llvm.org/D65867
llvm-svn: 368999
2019-08-15 21:11:50 +08:00
|
|
|
check_cxx_compiler_flag(-mrtm LIBOMP_HAVE_MRTM_FLAG)
|
2015-07-16 00:57:19 +08:00
|
|
|
# It is difficult to create a dummy masm assembly file
|
|
|
|
# and then check the MASM assembler to see if these flags exist and work,
|
|
|
|
# so we assume they do for Windows.
|
|
|
|
set(LIBOMP_HAVE_SAFESEH_MASM_FLAG TRUE)
|
|
|
|
set(LIBOMP_HAVE_COFF_MASM_FLAG TRUE)
|
|
|
|
# Change Windows flags /MDx to /MTx
|
|
|
|
foreach(libomp_lang IN ITEMS C CXX)
|
|
|
|
foreach(libomp_btype IN ITEMS DEBUG RELWITHDEBINFO RELEASE MINSIZEREL)
|
|
|
|
string(REPLACE "/MD" "/MT"
|
|
|
|
CMAKE_${libomp_lang}_FLAGS_${libomp_btype}
|
|
|
|
"${CMAKE_${libomp_lang}_FLAGS_${libomp_btype}}"
|
|
|
|
)
|
2015-07-16 00:05:30 +08:00
|
|
|
endforeach()
|
2015-07-16 00:57:19 +08:00
|
|
|
endforeach()
|
2015-07-16 00:05:30 +08:00
|
|
|
else()
|
2015-07-16 00:57:19 +08:00
|
|
|
# It is difficult to create a dummy assembly file that compiles into an
|
2020-01-07 14:03:31 +08:00
|
|
|
# executable for every architecture and then check the C compiler to
|
2015-07-16 00:57:19 +08:00
|
|
|
# see if -x assembler-with-cpp exists and works, so we assume it does for non-Windows.
|
|
|
|
set(LIBOMP_HAVE_X_ASSEMBLER_WITH_CPP_FLAG TRUE)
|
2015-07-16 00:05:30 +08:00
|
|
|
endif()
|
|
|
|
if(${LIBOMP_FORTRAN_MODULES})
|
2015-07-16 00:57:19 +08:00
|
|
|
libomp_check_fortran_flag(-m32 LIBOMP_HAVE_M32_FORTRAN_FLAG)
|
2015-07-16 00:05:30 +08:00
|
|
|
endif()
|
|
|
|
|
2020-10-27 00:02:21 +08:00
|
|
|
# Check for Unix shared memory
|
|
|
|
check_symbol_exists(shm_open "sys/mman.h" LIBOMP_HAVE_SHM_OPEN_NO_LRT)
|
|
|
|
if (NOT LIBOMP_HAVE_SHM_OPEN_NO_LRT)
|
|
|
|
set(CMAKE_REQUIRED_LIBRARIES -lrt)
|
|
|
|
check_symbol_exists(shm_open "sys/mman.h" LIBOMP_HAVE_SHM_OPEN_WITH_LRT)
|
|
|
|
set(CMAKE_REQUIRED_LIBRARIES)
|
|
|
|
endif()
|
|
|
|
|
[OpenMP] libomp: Add new experimental barrier: two-level distributed barrier
Two-level distributed barrier is a new experimental barrier designed
for Intel hardware that has better performance in some cases than the
default hyper barrier.
This barrier is designed to handle fine granularity parallelism where
barriers are used frequently with little compute and memory access
between barriers. There is no need to use it for codes with few
barriers and large granularity compute, or memory intensive
applications, as little difference will be seen between this barrier
and the default hyper barrier. This barrier is designed to work
optimally with a fixed number of threads, and has a significant setup
time, so should NOT be used in situations where the number of threads
in a team is varied frequently.
The two-level distributed barrier is off by default -- hyper barrier
is used by default. To use this barrier, you must set all barrier
patterns to use this type, because it will not work with other barrier
patterns. Thus, to turn it on, the following settings are required:
KMP_FORKJOIN_BARRIER_PATTERN=dist,dist
KMP_PLAIN_BARRIER_PATTERN=dist,dist
KMP_REDUCTION_BARRIER_PATTERN=dist,dist
Branching factors (set with KMP_FORKJOIN_BARRIER, KMP_PLAIN_BARRIER,
and KMP_REDUCTION_BARRIER) are ignored by the two-level distributed
barrier.
Patch fixed for ITTNotify disabled builds and non-x86 builds
Co-authored-by: Jonathan Peyton <jonathan.l.peyton@intel.com>
Co-authored-by: Vladislav Vinogradov <vlad.vinogradov@intel.com>
Differential Revision: https://reviews.llvm.org/D103121
2021-07-15 23:28:47 +08:00
|
|
|
# Check for aligned memory allocator function
|
|
|
|
check_include_file(xmmintrin.h LIBOMP_HAVE_XMMINTRIN_H)
|
|
|
|
set(OLD_CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS})
|
|
|
|
if (LIBOMP_HAVE_XMMINTRIN_H)
|
|
|
|
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -DLIBOMP_HAVE_XMMINTRIN_H")
|
|
|
|
endif()
|
|
|
|
set(source_code "// check for _mm_malloc
|
|
|
|
#ifdef LIBOMP_HAVE_XMMINTRIN_H
|
|
|
|
#include <xmmintrin.h>
|
|
|
|
#endif
|
|
|
|
int main() { void *ptr = _mm_malloc(sizeof(int) * 1000, 64); _mm_free(ptr); return 0; }")
|
|
|
|
check_cxx_source_compiles("${source_code}" LIBOMP_HAVE__MM_MALLOC)
|
|
|
|
set(CMAKE_REQUIRED_FLAGS ${OLD_CMAKE_REQUIRED_FLAGS})
|
|
|
|
check_symbol_exists(aligned_alloc "stdlib.h" LIBOMP_HAVE_ALIGNED_ALLOC)
|
|
|
|
check_symbol_exists(posix_memalign "stdlib.h" LIBOMP_HAVE_POSIX_MEMALIGN)
|
|
|
|
check_symbol_exists(_aligned_malloc "malloc.h" LIBOMP_HAVE__ALIGNED_MALLOC)
|
|
|
|
|
2015-07-16 00:05:30 +08:00
|
|
|
# Check linker flags
|
|
|
|
if(WIN32)
|
2015-07-16 00:57:19 +08:00
|
|
|
libomp_check_linker_flag(/SAFESEH LIBOMP_HAVE_SAFESEH_FLAG)
|
2015-07-16 00:05:30 +08:00
|
|
|
elseif(NOT APPLE)
|
2015-07-16 00:57:19 +08:00
|
|
|
libomp_check_linker_flag(-Wl,-x LIBOMP_HAVE_X_FLAG)
|
|
|
|
libomp_check_linker_flag(-Wl,--warn-shared-textrel LIBOMP_HAVE_WARN_SHARED_TEXTREL_FLAG)
|
|
|
|
libomp_check_linker_flag(-Wl,--as-needed LIBOMP_HAVE_AS_NEEDED_FLAG)
|
|
|
|
libomp_check_linker_flag("-Wl,--version-script=${LIBOMP_SRC_DIR}/exports_so.txt" LIBOMP_HAVE_VERSION_SCRIPT_FLAG)
|
|
|
|
libomp_check_linker_flag(-static-libgcc LIBOMP_HAVE_STATIC_LIBGCC_FLAG)
|
|
|
|
libomp_check_linker_flag(-Wl,-z,noexecstack LIBOMP_HAVE_Z_NOEXECSTACK_FLAG)
|
2015-07-16 00:05:30 +08:00
|
|
|
endif()
|
|
|
|
|
|
|
|
# Check Intel(R) C Compiler specific flags
|
2022-02-01 00:04:49 +08:00
|
|
|
if(CMAKE_C_COMPILER_ID STREQUAL "Intel" OR CMAKE_C_COMPILER_ID STREQUAL "IntelLLVM")
|
2015-07-16 00:57:19 +08:00
|
|
|
check_cxx_compiler_flag(/Qlong_double LIBOMP_HAVE_LONG_DOUBLE_FLAG)
|
|
|
|
check_cxx_compiler_flag(/Qdiag-disable:177 LIBOMP_HAVE_DIAG_DISABLE_177_FLAG)
|
|
|
|
check_cxx_compiler_flag(/Qinline-min-size=1 LIBOMP_HAVE_INLINE_MIN_SIZE_FLAG)
|
|
|
|
check_cxx_compiler_flag(-Qoption,cpp,--extended_float_types LIBOMP_HAVE_EXTENDED_FLOAT_TYPES_FLAG)
|
|
|
|
check_cxx_compiler_flag(-falign-stack=maintain-16-byte LIBOMP_HAVE_FALIGN_STACK_FLAG)
|
|
|
|
check_cxx_compiler_flag("-opt-streaming-stores never" LIBOMP_HAVE_OPT_STREAMING_STORES_FLAG)
|
|
|
|
libomp_check_linker_flag(-static-intel LIBOMP_HAVE_STATIC_INTEL_FLAG)
|
|
|
|
libomp_check_linker_flag(-no-intel-extensions LIBOMP_HAVE_NO_INTEL_EXTENSIONS_FLAG)
|
|
|
|
check_library_exists(irc_pic _intel_fast_memcpy "" LIBOMP_HAVE_IRC_PIC_LIBRARY)
|
2015-07-16 00:05:30 +08:00
|
|
|
endif()
|
|
|
|
|
|
|
|
# Checking Threading requirements
|
|
|
|
find_package(Threads REQUIRED)
|
|
|
|
if(WIN32)
|
2015-07-16 00:57:19 +08:00
|
|
|
if(NOT CMAKE_USE_WIN32_THREADS_INIT)
|
|
|
|
libomp_error_say("Need Win32 thread interface on Windows.")
|
|
|
|
endif()
|
2015-07-16 00:05:30 +08:00
|
|
|
else()
|
2015-07-16 00:57:19 +08:00
|
|
|
if(NOT CMAKE_USE_PTHREADS_INIT)
|
|
|
|
libomp_error_say("Need pthread interface on Unix-like systems.")
|
|
|
|
endif()
|
2015-07-16 00:05:30 +08:00
|
|
|
endif()
|
|
|
|
|
2020-12-02 04:03:40 +08:00
|
|
|
# Checking for x86-specific waitpkg and rtm attribute and intrinsics
|
|
|
|
if (IA32 OR INTEL64)
|
|
|
|
check_include_file(immintrin.h LIBOMP_HAVE_IMMINTRIN_H)
|
|
|
|
if (NOT LIBOMP_HAVE_IMMINTRIN_H)
|
|
|
|
check_include_file(intrin.h LIBOMP_HAVE_INTRIN_H)
|
|
|
|
endif()
|
|
|
|
check_cxx_source_compiles("__attribute__((target(\"rtm\")))
|
|
|
|
int main() {return 0;}" LIBOMP_HAVE_ATTRIBUTE_RTM)
|
|
|
|
check_cxx_source_compiles("__attribute__((target(\"waitpkg\")))
|
|
|
|
int main() {return 0;}" LIBOMP_HAVE_ATTRIBUTE_WAITPKG)
|
|
|
|
libomp_append(CMAKE_REQUIRED_DEFINITIONS -DIMMINTRIN_H LIBOMP_HAVE_IMMINTRIN_H)
|
|
|
|
libomp_append(CMAKE_REQUIRED_DEFINITIONS -DINTRIN_H LIBOMP_HAVE_INTRIN_H)
|
|
|
|
libomp_append(CMAKE_REQUIRED_DEFINITIONS -DATTRIBUTE_WAITPKG LIBOMP_HAVE_ATTRIBUTE_WAITPKG)
|
|
|
|
libomp_append(CMAKE_REQUIRED_DEFINITIONS -DATTRIBUTE_RTM LIBOMP_HAVE_ATTRIBUTE_RTM)
|
|
|
|
set(source_code "// check for attribute and wait pkg intrinsics
|
|
|
|
#ifdef IMMINTRIN_H
|
|
|
|
#include <immintrin.h>
|
|
|
|
#endif
|
|
|
|
#ifdef INTRIN_H
|
|
|
|
#include <intrin.h>
|
|
|
|
#endif
|
|
|
|
#ifdef ATTRIBUTE_WAITPKG
|
|
|
|
__attribute__((target(\"waitpkg\")))
|
|
|
|
#endif
|
|
|
|
static inline int __kmp_umwait(unsigned hint, unsigned long long counter) {
|
|
|
|
return _umwait(hint, counter);
|
|
|
|
}
|
|
|
|
int main() { int a = __kmp_umwait(0, 1000); return a; }")
|
|
|
|
check_cxx_source_compiles("${source_code}" LIBOMP_HAVE_WAITPKG_INTRINSICS)
|
2021-03-02 21:44:15 +08:00
|
|
|
set(OLD_CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS})
|
|
|
|
if (LIBOMP_HAVE_MRTM_FLAG)
|
|
|
|
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -mrtm")
|
|
|
|
endif()
|
2020-12-02 04:03:40 +08:00
|
|
|
set(source_code "// check for attribute rtm and rtm intrinsics
|
|
|
|
#ifdef IMMINTRIN_H
|
|
|
|
#include <immintrin.h>
|
|
|
|
#endif
|
|
|
|
#ifdef INTRIN_H
|
|
|
|
#include <intrin.h>
|
|
|
|
#endif
|
|
|
|
#ifdef ATTRIBUTE_RTM
|
|
|
|
__attribute__((target(\"rtm\")))
|
|
|
|
#endif
|
|
|
|
static inline int __kmp_xbegin() {
|
|
|
|
return _xbegin();
|
|
|
|
}
|
|
|
|
int main() { int a = __kmp_xbegin(); return a; }")
|
|
|
|
check_cxx_source_compiles("${source_code}" LIBOMP_HAVE_RTM_INTRINSICS)
|
|
|
|
set(CMAKE_REQUIRED_DEFINITIONS)
|
2021-03-02 21:44:15 +08:00
|
|
|
set(CMAKE_REQUIRED_FLAGS ${OLD_CMAKE_REQUIRED_FLAGS})
|
2020-12-02 04:03:40 +08:00
|
|
|
endif()
|
|
|
|
|
2015-07-16 00:05:30 +08:00
|
|
|
# Find perl executable
|
|
|
|
# Perl is used to create omp.h (and other headers) along with kmp_i18n_id.inc and kmp_i18n_default.inc
|
|
|
|
find_package(Perl REQUIRED)
|
2016-01-27 03:44:31 +08:00
|
|
|
# The perl scripts take the --os=/--arch= flags which expect a certain format for operating systems and arch's.
|
|
|
|
# Until the perl scripts are removed, the most portable way to handle this is to have all operating systems that
|
2015-07-16 00:05:30 +08:00
|
|
|
# are neither Windows nor Mac (Most Unix flavors) be considered lin to the perl scripts. This is rooted
|
|
|
|
# in that all the Perl scripts check the operating system and will fail if it isn't "valid". This
|
|
|
|
# temporary solution lets us avoid trying to enumerate all the possible OS values inside the Perl modules.
|
|
|
|
if(WIN32)
|
2015-07-16 00:57:19 +08:00
|
|
|
set(LIBOMP_PERL_SCRIPT_OS win)
|
2015-07-16 00:05:30 +08:00
|
|
|
elseif(APPLE)
|
2015-07-16 00:57:19 +08:00
|
|
|
set(LIBOMP_PERL_SCRIPT_OS mac)
|
2015-07-16 00:05:30 +08:00
|
|
|
else()
|
2015-07-16 00:57:19 +08:00
|
|
|
set(LIBOMP_PERL_SCRIPT_OS lin)
|
2015-07-16 00:05:30 +08:00
|
|
|
endif()
|
2016-01-27 03:44:31 +08:00
|
|
|
if(IA32)
|
|
|
|
set(LIBOMP_PERL_SCRIPT_ARCH 32)
|
|
|
|
elseif(MIC)
|
|
|
|
set(LIBOMP_PERL_SCRIPT_ARCH mic)
|
|
|
|
elseif(INTEL64)
|
|
|
|
set(LIBOMP_PERL_SCRIPT_ARCH 32e)
|
|
|
|
else()
|
|
|
|
set(LIBOMP_PERL_SCRIPT_ARCH ${LIBOMP_ARCH})
|
|
|
|
endif()
|
2015-07-16 00:05:30 +08:00
|
|
|
|
|
|
|
# Checking features
|
|
|
|
# Check if version symbol assembler directives are supported
|
|
|
|
libomp_check_version_symbols(LIBOMP_HAVE_VERSION_SYMBOLS)
|
|
|
|
|
|
|
|
# Check if quad precision types are available
|
|
|
|
if(CMAKE_C_COMPILER_ID STREQUAL "GNU")
|
2015-07-16 00:57:19 +08:00
|
|
|
set(LIBOMP_HAVE_QUAD_PRECISION TRUE)
|
2022-02-01 00:04:49 +08:00
|
|
|
elseif(CMAKE_C_COMPILER_ID STREQUAL "Intel" OR CMAKE_C_COMPILER_ID STREQUAL "IntelLLVM")
|
2015-07-16 00:57:19 +08:00
|
|
|
if(LIBOMP_HAVE_EXTENDED_FLOAT_TYPES_FLAG)
|
|
|
|
set(LIBOMP_HAVE_QUAD_PRECISION TRUE)
|
|
|
|
else()
|
|
|
|
set(LIBOMP_HAVE_QUAD_PRECISION TRUE)
|
|
|
|
endif()
|
2015-07-16 00:05:30 +08:00
|
|
|
else()
|
2015-07-16 00:57:19 +08:00
|
|
|
set(LIBOMP_HAVE_QUAD_PRECISION FALSE)
|
2015-07-16 00:05:30 +08:00
|
|
|
endif()
|
|
|
|
|
|
|
|
# Check if adaptive locks are available
|
|
|
|
if((${IA32} OR ${INTEL64}) AND NOT MSVC)
|
2015-07-16 00:57:19 +08:00
|
|
|
set(LIBOMP_HAVE_ADAPTIVE_LOCKS TRUE)
|
2015-07-16 00:05:30 +08:00
|
|
|
else()
|
2015-07-16 00:57:19 +08:00
|
|
|
set(LIBOMP_HAVE_ADAPTIVE_LOCKS FALSE)
|
2015-07-16 00:05:30 +08:00
|
|
|
endif()
|
|
|
|
|
|
|
|
# Check if stats-gathering is available
|
2015-12-19 00:19:35 +08:00
|
|
|
if(${LIBOMP_STATS})
|
|
|
|
check_c_source_compiles(
|
|
|
|
"__thread int x;
|
2016-05-18 04:51:24 +08:00
|
|
|
int main(int argc, char** argv)
|
2015-12-19 00:19:35 +08:00
|
|
|
{ x = argc; return x; }"
|
|
|
|
LIBOMP_HAVE___THREAD)
|
|
|
|
check_c_source_compiles(
|
2016-05-18 04:51:24 +08:00
|
|
|
"int main(int argc, char** argv)
|
2015-12-19 00:19:35 +08:00
|
|
|
{ unsigned long long t = __builtin_readcyclecounter(); return 0; }"
|
|
|
|
LIBOMP_HAVE___BUILTIN_READCYCLECOUNTER)
|
|
|
|
if(NOT LIBOMP_HAVE___BUILTIN_READCYCLECOUNTER)
|
2016-03-29 02:53:10 +08:00
|
|
|
if(${IA32} OR ${INTEL64} OR ${MIC})
|
2015-12-19 00:19:35 +08:00
|
|
|
check_include_file(x86intrin.h LIBOMP_HAVE_X86INTRIN_H)
|
|
|
|
libomp_append(CMAKE_REQUIRED_DEFINITIONS -DLIBOMP_HAVE_X86INTRIN_H LIBOMP_HAVE_X86INTRIN_H)
|
|
|
|
check_c_source_compiles(
|
|
|
|
"#ifdef LIBOMP_HAVE_X86INTRIN_H
|
|
|
|
# include <x86intrin.h>
|
|
|
|
#endif
|
|
|
|
int main(int argc, char** argv) { unsigned long long t = __rdtsc(); return 0; }" LIBOMP_HAVE___RDTSC)
|
|
|
|
set(CMAKE_REQUIRED_DEFINITIONS)
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
if(LIBOMP_HAVE___THREAD AND (LIBOMP_HAVE___RDTSC OR LIBOMP_HAVE___BUILTIN_READCYCLECOUNTER))
|
|
|
|
set(LIBOMP_HAVE_STATS TRUE)
|
|
|
|
else()
|
|
|
|
set(LIBOMP_HAVE_STATS FALSE)
|
|
|
|
endif()
|
2015-07-16 00:05:30 +08:00
|
|
|
endif()
|
|
|
|
|
|
|
|
# Check if OMPT support is available
|
2015-10-30 04:56:24 +08:00
|
|
|
# Currently, __builtin_frame_address() is required for OMPT
|
2017-11-11 21:59:48 +08:00
|
|
|
# Weak attribute is required for Unices (except Darwin), LIBPSAPI is used for Windows
|
2015-10-30 04:56:24 +08:00
|
|
|
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)
|
2021-02-12 17:20:10 +08:00
|
|
|
set(CMAKE_REQUIRED_LIBRARIES psapi)
|
|
|
|
check_c_source_compiles("#include <windows.h>
|
|
|
|
#include <psapi.h>
|
|
|
|
int main(int artc, char** argv) {
|
|
|
|
return EnumProcessModules(NULL, NULL, 0, NULL);
|
|
|
|
}" LIBOMP_HAVE_PSAPI)
|
|
|
|
set(CMAKE_REQUIRED_LIBRARIES)
|
2015-10-30 04:56:24 +08:00
|
|
|
if(NOT LIBOMP_HAVE___BUILTIN_FRAME_ADDRESS)
|
2015-07-16 00:57:19 +08:00
|
|
|
set(LIBOMP_HAVE_OMPT_SUPPORT FALSE)
|
2015-10-30 04:56:24 +08:00
|
|
|
else()
|
2018-01-03 05:09:00 +08:00
|
|
|
if( # hardware architecture supported?
|
|
|
|
((LIBOMP_ARCH STREQUAL x86_64) OR
|
|
|
|
(LIBOMP_ARCH STREQUAL i386) OR
|
|
|
|
# (LIBOMP_ARCH STREQUAL arm) OR
|
|
|
|
(LIBOMP_ARCH STREQUAL aarch64) OR
|
2021-01-10 00:58:37 +08:00
|
|
|
(LIBOMP_ARCH STREQUAL aarch64_a64fx) OR
|
2018-01-03 05:09:00 +08:00
|
|
|
(LIBOMP_ARCH STREQUAL ppc64le) OR
|
2019-07-25 22:36:20 +08:00
|
|
|
(LIBOMP_ARCH STREQUAL ppc64) OR
|
|
|
|
(LIBOMP_ARCH STREQUAL riscv64))
|
2018-01-03 05:09:00 +08:00
|
|
|
AND # OS supported?
|
|
|
|
((WIN32 AND LIBOMP_HAVE_PSAPI) OR APPLE OR (NOT WIN32 AND LIBOMP_HAVE_WEAK_ATTRIBUTE)))
|
2015-10-30 04:56:24 +08:00
|
|
|
set(LIBOMP_HAVE_OMPT_SUPPORT TRUE)
|
|
|
|
else()
|
|
|
|
set(LIBOMP_HAVE_OMPT_SUPPORT FALSE)
|
|
|
|
endif()
|
2015-07-16 00:05:30 +08:00
|
|
|
endif()
|
2015-10-30 04:56:24 +08:00
|
|
|
|
2015-12-01 04:02:59 +08:00
|
|
|
# Check if HWLOC support is available
|
|
|
|
if(${LIBOMP_USE_HWLOC})
|
2022-04-23 06:33:41 +08:00
|
|
|
find_path(LIBOMP_HWLOC_INCLUDE_DIR NAMES hwloc.h HINTS ${LIBOMP_HWLOC_INSTALL_DIR} PATH_SUFFIXES include)
|
|
|
|
set(CMAKE_REQUIRED_INCLUDES ${LIBOMP_HWLOC_INCLUDE_DIR})
|
2016-06-17 04:23:11 +08:00
|
|
|
check_include_file(hwloc.h LIBOMP_HAVE_HWLOC_H)
|
|
|
|
set(CMAKE_REQUIRED_INCLUDES)
|
|
|
|
find_library(LIBOMP_HWLOC_LIBRARY
|
|
|
|
NAMES hwloc libhwloc
|
|
|
|
HINTS ${LIBOMP_HWLOC_INSTALL_DIR}/lib)
|
|
|
|
if(LIBOMP_HWLOC_LIBRARY)
|
|
|
|
check_library_exists(${LIBOMP_HWLOC_LIBRARY} hwloc_topology_init
|
2015-12-01 04:02:59 +08:00
|
|
|
${LIBOMP_HWLOC_INSTALL_DIR}/lib LIBOMP_HAVE_LIBHWLOC)
|
|
|
|
get_filename_component(LIBOMP_HWLOC_LIBRARY_DIR ${LIBOMP_HWLOC_LIBRARY} PATH)
|
2016-06-17 04:23:11 +08:00
|
|
|
endif()
|
|
|
|
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")
|
2015-12-01 04:02:59 +08:00
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
2016-11-07 23:58:36 +08:00
|
|
|
# Check if ThreadSanitizer support is available
|
|
|
|
if("${CMAKE_SYSTEM_NAME}" MATCHES "Linux" AND ${INTEL64})
|
|
|
|
set(LIBOMP_HAVE_TSAN_SUPPORT TRUE)
|
|
|
|
else()
|
|
|
|
set(LIBOMP_HAVE_TSAN_SUPPORT FALSE)
|
|
|
|
endif()
|