1 //===--------- Misc.cpp - OpenMP device misc interfaces ----------- C++ -*-===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
10 //===----------------------------------------------------------------------===//
16 #pragma omp declare target
21 /// AMDGCN Implementation
24 #pragma omp begin declare variant match(device = {arch(amdgcn)})
26 double getWTick() { return ((double)1E-9); }
29 // The intrinsics for measuring time have undocumented frequency
30 // This will probably need to be found by measurement on a number of
31 // architectures. Until then, return 0, which is very inaccurate as a
32 // timer but resolves the undefined symbol at link time.
36 #pragma omp end declare variant
38 /// NVPTX Implementation
41 #pragma omp begin declare variant match( \
42 device = {arch(nvptx, nvptx64)}, implementation = {extension(match_any)})
45 // Timer precision is 1ns
46 return ((double)1E-9);
50 unsigned long long nsecs
;
51 asm("mov.u64 %0, %%globaltimer;" : "=l"(nsecs
));
52 return (double)nsecs
* getWTick();
55 #pragma omp end declare variant
65 int32_t __kmpc_cancellationpoint(IdentTy
*, int32_t, int32_t) {
66 FunctionTracingRAII();
70 int32_t __kmpc_cancel(IdentTy
*, int32_t, int32_t) {
71 FunctionTracingRAII();
75 double omp_get_wtick(void) { return _OMP::impl::getWTick(); }
77 double omp_get_wtime(void) { return _OMP::impl::getWTime(); }
81 #pragma omp end declare target