xref: /freebsd/contrib/llvm-project/clang/lib/Headers/openmp_wrappers/time.h (revision dd41de95a84d979615a2ef11df6850622bf6184e)
1 /*===---- time.h - OpenMP time header wrapper ------------------------ 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 #ifndef __CLANG_OPENMP_TIME_H__
11 #define __CLANG_OPENMP_TIME_H__
12 
13 #ifndef _OPENMP
14 #error "This file is for OpenMP compilation only."
15 #endif
16 
17 #if defined(__cplusplus)
18 #define __DEVICE__ static constexpr __attribute__((always_inline, nothrow))
19 #else
20 #define __DEVICE__ static __attribute__((always_inline, nothrow))
21 #endif
22 
23 #include_next <time.h>
24 
25 #pragma omp begin declare variant match(                                       \
26     device = {arch(nvptx, nvptx64)}, implementation = {extension(match_any)})
27 
28 __DEVICE__ clock_t clock() { return __nvvm_read_ptx_sreg_clock(); }
29 
30 #pragma omp end declare variant
31 
32 #endif
33