[Openmp-commits] [openmp] r256002 - [STATS] Have CMake do real check for stats functionality
Jonathan Peyton via Openmp-commits
openmp-commits at lists.llvm.org
Fri Dec 18 08:19:36 PST 2015
Author: jlpeyton
Date: Fri Dec 18 10:19:35 2015
New Revision: 256002
URL: http://llvm.org/viewvc/llvm-project?rev=256002&view=rev
Log:
[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
Modified:
openmp/trunk/runtime/CMakeLists.txt
openmp/trunk/runtime/cmake/config-ix.cmake
openmp/trunk/runtime/src/kmp_config.h.cmake
openmp/trunk/runtime/src/kmp_stats_timing.h
Modified: openmp/trunk/runtime/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/openmp/trunk/runtime/CMakeLists.txt?rev=256002&r1=256001&r2=256002&view=diff
==============================================================================
--- openmp/trunk/runtime/CMakeLists.txt (original)
+++ openmp/trunk/runtime/CMakeLists.txt Fri Dec 18 10:19:35 2015
@@ -267,7 +267,6 @@ endif()
# - stats-gathering enables OpenMP stats where things like the number of
# parallel regions, clock ticks spent in particular openmp regions are recorded.
-# TODO: Make this a real feature check
set(LIBOMP_STATS FALSE CACHE BOOL
"Stats-Gathering functionality?")
if(LIBOMP_STATS AND (NOT LIBOMP_HAVE_STATS))
Modified: openmp/trunk/runtime/cmake/config-ix.cmake
URL: http://llvm.org/viewvc/llvm-project/openmp/trunk/runtime/cmake/config-ix.cmake?rev=256002&r1=256001&r2=256002&view=diff
==============================================================================
--- openmp/trunk/runtime/cmake/config-ix.cmake (original)
+++ openmp/trunk/runtime/cmake/config-ix.cmake Fri Dec 18 10:19:35 2015
@@ -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
Modified: openmp/trunk/runtime/src/kmp_config.h.cmake
URL: http://llvm.org/viewvc/llvm-project/openmp/trunk/runtime/src/kmp_config.h.cmake?rev=256002&r1=256001&r2=256002&view=diff
==============================================================================
--- openmp/trunk/runtime/src/kmp_config.h.cmake (original)
+++ openmp/trunk/runtime/src/kmp_config.h.cmake Fri Dec 18 10:19:35 2015
@@ -33,6 +33,12 @@
#define KMP_HAVE_PSAPI LIBOMP_HAVE_PSAPI
#cmakedefine01 LIBOMP_STATS
#define KMP_STATS_ENABLED LIBOMP_STATS
+#cmakedefine01 LIBOMP_HAVE_X86INTRIN_H
+#define KMP_HAVE_X86INTRIN_H LIBOMP_HAVE_X86INTRIN_H
+#cmakedefine01 LIBOMP_HAVE___BUILTIN_READCYCLECOUNTER
+#define KMP_HAVE___BUILTIN_READCYCLECOUNTER LIBOMP_HAVE___BUILTIN_READCYCLECOUNTER
+#cmakedefine01 LIBOMP_HAVE___RDTSC
+#define KMP_HAVE___RDTSC LIBOMP_HAVE___RDTSC
#cmakedefine01 LIBOMP_USE_DEBUGGER
#define USE_DEBUGGER LIBOMP_USE_DEBUGGER
#cmakedefine01 LIBOMP_OMPT_DEBUG
Modified: openmp/trunk/runtime/src/kmp_stats_timing.h
URL: http://llvm.org/viewvc/llvm-project/openmp/trunk/runtime/src/kmp_stats_timing.h?rev=256002&r1=256001&r2=256002&view=diff
==============================================================================
--- openmp/trunk/runtime/src/kmp_stats_timing.h (original)
+++ openmp/trunk/runtime/src/kmp_stats_timing.h Fri Dec 18 10:19:35 2015
@@ -21,6 +21,9 @@
#include <string>
#include <limits>
#include "kmp_os.h"
+#if KMP_HAVE_X86INTRIN_H
+# include <x86intrin.h>
+#endif
class tsc_tick_count {
private:
@@ -44,7 +47,13 @@ class tsc_tick_count {
const tsc_tick_count t1, const tsc_tick_count t0);
};
+#if KMP_HAVE___BUILTIN_READCYCLECOUNTER
+ tsc_tick_count() : my_count(static_cast<int64_t>(__builtin_readcyclecounter())) {}
+#elif KMP_HAVE___RDTSC
tsc_tick_count() : my_count(static_cast<int64_t>(__rdtsc())) {};
+#else
+# error Must have high resolution timer defined
+#endif
tsc_tick_count(int64_t value) : my_count(value) {};
int64_t getValue() const { return my_count; }
tsc_tick_count later (tsc_tick_count const other) const {
More information about the Openmp-commits
mailing list