summaryrefslogtreecommitdiffstats
path: root/openmp
diff options
context:
space:
mode:
authorJon Chesterfield <jonathanchesterfield@gmail.com>2019-12-17 02:22:28 +0000
committerJon Chesterfield <jonathanchesterfield@gmail.com>2019-12-17 02:22:29 +0000
commitce12a523b0e1a64cea63ba099642d7f3492a3791 (patch)
tree60f27e959665591f7b7bc7c73326cb4e7f7ce660 /openmp
parent9e9c5f0a6346ef02e31d5e8b91e6aab16a2e9370 (diff)
downloadbcm5719-llvm-ce12a523b0e1a64cea63ba099642d7f3492a3791.tar.gz
bcm5719-llvm-ce12a523b0e1a64cea63ba099642d7f3492a3791.zip
[libomptarget][nfc] Move timer functions behind target_impl
Summary: [libomptarget][nfc] Move timer functions behind target_impl Reviewers: jdoerfert, ABataev, grokos Reviewed By: jdoerfert Subscribers: jvesely, openmp-commits Tags: #openmp Differential Revision: https://reviews.llvm.org/D71584
Diffstat (limited to 'openmp')
-rw-r--r--openmp/libomptarget/deviceRTLs/amdgcn/src/target_impl.h7
-rw-r--r--openmp/libomptarget/deviceRTLs/nvptx/src/libcall.cu13
-rw-r--r--openmp/libomptarget/deviceRTLs/nvptx/src/target_impl.h11
3 files changed, 23 insertions, 8 deletions
diff --git a/openmp/libomptarget/deviceRTLs/amdgcn/src/target_impl.h b/openmp/libomptarget/deviceRTLs/amdgcn/src/target_impl.h
index 858a023eb8d..3c4e1f38bde 100644
--- a/openmp/libomptarget/deviceRTLs/amdgcn/src/target_impl.h
+++ b/openmp/libomptarget/deviceRTLs/amdgcn/src/target_impl.h
@@ -105,6 +105,13 @@ INLINE uint32_t __kmpc_impl_smid() {
return __smid();
}
+INLINE double __target_impl_get_wtick() { return ((double)1E-9); }
+
+EXTERN int64_t __clock64();
+INLINE double __target_impl_get_wtime() {
+ return ((double)1.0 / 745000000.0) * __clock64();
+}
+
INLINE uint64_t __kmpc_impl_ffs(uint64_t x) { return __builtin_ffsl(x); }
INLINE uint64_t __kmpc_impl_popc(uint64_t x) { return __builtin_popcountl(x); }
diff --git a/openmp/libomptarget/deviceRTLs/nvptx/src/libcall.cu b/openmp/libomptarget/deviceRTLs/nvptx/src/libcall.cu
index d8656f34591..a43f0c6d8d9 100644
--- a/openmp/libomptarget/deviceRTLs/nvptx/src/libcall.cu
+++ b/openmp/libomptarget/deviceRTLs/nvptx/src/libcall.cu
@@ -12,19 +12,16 @@
//===----------------------------------------------------------------------===//
#include "common/omptarget.h"
-
-// Timer precision is 1ns
-#define TIMER_PRECISION ((double)1E-9)
+#include "target_impl.h"
EXTERN double omp_get_wtick(void) {
- PRINT(LD_IO, "omp_get_wtick() returns %g\n", TIMER_PRECISION);
- return TIMER_PRECISION;
+ double rc = __target_impl_get_wtick();
+ PRINT(LD_IO, "omp_get_wtick() returns %g\n", rc);
+ return rc;
}
EXTERN double omp_get_wtime(void) {
- unsigned long long nsecs;
- asm("mov.u64 %0, %%globaltimer;" : "=l"(nsecs));
- double rc = (double)nsecs * TIMER_PRECISION;
+ double rc = __target_impl_get_wtime();
PRINT(LD_IO, "call omp_get_wtime() returns %g\n", rc);
return rc;
}
diff --git a/openmp/libomptarget/deviceRTLs/nvptx/src/target_impl.h b/openmp/libomptarget/deviceRTLs/nvptx/src/target_impl.h
index 4bb66776a2a..7a85e744f9d 100644
--- a/openmp/libomptarget/deviceRTLs/nvptx/src/target_impl.h
+++ b/openmp/libomptarget/deviceRTLs/nvptx/src/target_impl.h
@@ -100,6 +100,17 @@ INLINE uint32_t __kmpc_impl_smid() {
return id;
}
+INLINE double __target_impl_get_wtick() {
+ // Timer precision is 1ns
+ return ((double)1E-9);
+}
+
+INLINE double __target_impl_get_wtime() {
+ unsigned long long nsecs;
+ asm("mov.u64 %0, %%globaltimer;" : "=l"(nsecs));
+ return (double)nsecs * __target_impl_get_wtick();
+}
+
INLINE uint32_t __kmpc_impl_ffs(uint32_t x) { return __ffs(x); }
INLINE uint32_t __kmpc_impl_popc(uint32_t x) { return __popc(x); }
OpenPOWER on IntegriCloud