[Openmp-commits] [PATCH] D71584: [libomptarget][nfc] Move timer functions behind target_impl
Jon Chesterfield via Phabricator via Openmp-commits
openmp-commits at lists.llvm.org
Mon Dec 16 17:31:01 PST 2019
JonChesterfield created this revision.
JonChesterfield added reviewers: jdoerfert, ABataev, grokos.
Herald added subscribers: openmp-commits, jvesely.
Herald added a project: OpenMP.
[libomptarget][nfc] Move timer functions behind target_impl
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D71584
Files:
openmp/libomptarget/deviceRTLs/amdgcn/src/target_impl.h
openmp/libomptarget/deviceRTLs/nvptx/src/libcall.cu
openmp/libomptarget/deviceRTLs/nvptx/src/target_impl.h
Index: openmp/libomptarget/deviceRTLs/nvptx/src/target_impl.h
===================================================================
--- openmp/libomptarget/deviceRTLs/nvptx/src/target_impl.h
+++ openmp/libomptarget/deviceRTLs/nvptx/src/target_impl.h
@@ -100,6 +100,17 @@
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); }
Index: openmp/libomptarget/deviceRTLs/nvptx/src/libcall.cu
===================================================================
--- openmp/libomptarget/deviceRTLs/nvptx/src/libcall.cu
+++ 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;
}
Index: openmp/libomptarget/deviceRTLs/amdgcn/src/target_impl.h
===================================================================
--- openmp/libomptarget/deviceRTLs/amdgcn/src/target_impl.h
+++ openmp/libomptarget/deviceRTLs/amdgcn/src/target_impl.h
@@ -105,6 +105,13 @@
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); }
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D71584.234198.patch
Type: text/x-patch
Size: 2364 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/openmp-commits/attachments/20191217/72fbc231/attachment.bin>
More information about the Openmp-commits
mailing list