[sanitizer] Improve FreeBSD ASLR detection
[llvm-project.git] / openmp / libomptarget / DeviceRTL / src / Misc.cpp
blob7284be87896f7dc625f946c2a5be624d268d43e1
1 //===--------- Misc.cpp - OpenMP device misc interfaces ----------- C++ -*-===//
2 //
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
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 //
10 //===----------------------------------------------------------------------===//
12 #include "Types.h"
14 #include "Debug.h"
16 #pragma omp declare target
18 namespace _OMP {
19 namespace impl {
21 /// AMDGCN Implementation
22 ///
23 ///{
24 #pragma omp begin declare variant match(device = {arch(amdgcn)})
26 double getWTick() { return ((double)1E-9); }
28 double getWTime() {
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.
33 return 0;
36 #pragma omp end declare variant
38 /// NVPTX Implementation
39 ///
40 ///{
41 #pragma omp begin declare variant match( \
42 device = {arch(nvptx, nvptx64)}, implementation = {extension(match_any)})
44 double getWTick() {
45 // Timer precision is 1ns
46 return ((double)1E-9);
49 double getWTime() {
50 unsigned long long nsecs;
51 asm("mov.u64 %0, %%globaltimer;" : "=l"(nsecs));
52 return (double)nsecs * getWTick();
55 #pragma omp end declare variant
57 } // namespace impl
58 } // namespace _OMP
60 /// Interfaces
61 ///
62 ///{
64 extern "C" {
65 int32_t __kmpc_cancellationpoint(IdentTy *, int32_t, int32_t) {
66 FunctionTracingRAII();
67 return 0;
70 int32_t __kmpc_cancel(IdentTy *, int32_t, int32_t) {
71 FunctionTracingRAII();
72 return 0;
75 double omp_get_wtick(void) { return _OMP::impl::getWTick(); }
77 double omp_get_wtime(void) { return _OMP::impl::getWTime(); }
80 ///}
81 #pragma omp end declare target