1 //===- Configuration.cpp - OpenMP device configuration interface -- 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 //===----------------------------------------------------------------------===//
9 // This file contains the data object of the constant device environment and the
12 //===----------------------------------------------------------------------===//
14 #include "Configuration.h"
20 #pragma omp begin declare target device_type(nohost)
22 // Weak definitions will be overridden by CGOpenmpRuntimeGPU if enabled.
23 [[gnu::weak
]] extern const uint32_t __omp_rtl_debug_kind
= 0;
24 [[gnu::weak
]] extern const uint32_t __omp_rtl_assume_no_thread_state
= 0;
25 [[gnu::weak
]] extern const uint32_t __omp_rtl_assume_no_nested_parallelism
= 0;
27 // This variable should be visibile to the plugin so we override the default
29 [[gnu::used
, gnu::retain
, gnu::weak
,
30 gnu::visibility("protected")]] DeviceEnvironmentTy
31 CONSTANT(__omp_rtl_device_environment
);
33 uint32_t config::getDebugKind() {
34 return __omp_rtl_debug_kind
& __omp_rtl_device_environment
.DeviceDebugKind
;
37 uint32_t config::getNumDevices() {
38 return __omp_rtl_device_environment
.NumDevices
;
41 uint32_t config::getDeviceNum() {
42 return __omp_rtl_device_environment
.DeviceNum
;
45 uint64_t config::getDynamicMemorySize() {
46 return __omp_rtl_device_environment
.DynamicMemSize
;
49 uint64_t config::getClockFrequency() {
50 return __omp_rtl_device_environment
.ClockFrequency
;
53 void *config::getIndirectCallTablePtr() {
54 return reinterpret_cast<void *>(
55 __omp_rtl_device_environment
.IndirectCallTable
);
58 uint64_t config::getHardwareParallelism() {
59 return __omp_rtl_device_environment
.HardwareParallelism
;
62 uint64_t config::getIndirectCallTableSize() {
63 return __omp_rtl_device_environment
.IndirectCallTableSize
;
66 bool config::isDebugMode(DeviceDebugKind Kind
) {
67 return config::getDebugKind() & uint32_t(Kind
);
70 bool config::mayUseThreadStates() { return !__omp_rtl_assume_no_thread_state
; }
72 bool config::mayUseNestedParallelism() {
73 if (__omp_rtl_assume_no_nested_parallelism
)
75 return state::getKernelEnvironment().Configuration
.MayUseNestedParallelism
;
78 #pragma omp end declare target