diff options
author | Jonathan Peyton <jonathan.l.peyton@intel.com> | 2015-12-18 16:19:35 +0000 |
---|---|---|
committer | Jonathan Peyton <jonathan.l.peyton@intel.com> | 2015-12-18 16:19:35 +0000 |
commit | b9e832608879a9defe8be23384677b9335b00546 (patch) | |
tree | 3f1559550e19d59e845434a1fa2f802deb853bcc /openmp/runtime/cmake | |
parent | 7a36355b21faec780a7050363b60727cfaa90d31 (diff) | |
download | bcm5719-llvm-b9e832608879a9defe8be23384677b9335b00546.tar.gz bcm5719-llvm-b9e832608879a9defe8be23384677b9335b00546.zip |
[STATS] Have CMake do real check for stats functionality
This change allows clang to build the stats library for every architecture
which supports __builtin_readcyclecounter(). CMake also checks for all
necessary features for stats and will error out if the platform does not
support it.
Patch by Hal Finkel and Johnny Peyton
llvm-svn: 256002
Diffstat (limited to 'openmp/runtime/cmake')
-rw-r--r-- | openmp/runtime/cmake/config-ix.cmake | 31 |
1 files changed, 27 insertions, 4 deletions
diff --git a/openmp/runtime/cmake/config-ix.cmake b/openmp/runtime/cmake/config-ix.cmake index eccb8634b3b..6a78a7aebc5 100644 --- a/openmp/runtime/cmake/config-ix.cmake +++ b/openmp/runtime/cmake/config-ix.cmake @@ -182,10 +182,33 @@ else() endif() # Check if stats-gathering is available -if(NOT (WIN32 OR APPLE) AND (${IA32} OR ${INTEL64} OR ${MIC})) - set(LIBOMP_HAVE_STATS TRUE) -else() - set(LIBOMP_HAVE_STATS FALSE) +if(${LIBOMP_STATS}) + check_c_source_compiles( + "__thread int x; + int main(int argc, char** argv) + { x = argc; return x; }" + LIBOMP_HAVE___THREAD) + check_c_source_compiles( + "int main(int argc, char** argv) + { unsigned long long t = __builtin_readcyclecounter(); return 0; }" + LIBOMP_HAVE___BUILTIN_READCYCLECOUNTER) + if(NOT LIBOMP_HAVE___BUILTIN_READCYCLECOUNTER) + if(${IA32} OR ${INTEL64}) + 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() endif() # Check if OMPT support is available |