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"
15 #include "DeviceTypes.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;
26 [[gnu::weak
]] extern const uint32_t __omp_rtl_assume_threads_oversubscription
=
28 [[gnu::weak
]] extern const uint32_t __omp_rtl_assume_teams_oversubscription
= 0;
30 // This variable should be visibile to the plugin so we override the default
32 [[gnu::used
, gnu::retain
, gnu::weak
,
33 gnu::visibility("protected")]] DeviceEnvironmentTy
34 CONSTANT(__omp_rtl_device_environment
);
36 uint32_t config::getAssumeTeamsOversubscription() {
37 return __omp_rtl_assume_teams_oversubscription
;
40 uint32_t config::getAssumeThreadsOversubscription() {
41 return __omp_rtl_assume_threads_oversubscription
;
44 uint32_t config::getDebugKind() {
45 return __omp_rtl_debug_kind
& __omp_rtl_device_environment
.DeviceDebugKind
;
48 uint32_t config::getNumDevices() {
49 return __omp_rtl_device_environment
.NumDevices
;
52 uint32_t config::getDeviceNum() {
53 return __omp_rtl_device_environment
.DeviceNum
;
56 uint64_t config::getDynamicMemorySize() {
57 return __omp_rtl_device_environment
.DynamicMemSize
;
60 uint64_t config::getClockFrequency() {
61 return __omp_rtl_device_environment
.ClockFrequency
;
64 void *config::getIndirectCallTablePtr() {
65 return reinterpret_cast<void *>(
66 __omp_rtl_device_environment
.IndirectCallTable
);
69 uint64_t config::getHardwareParallelism() {
70 return __omp_rtl_device_environment
.HardwareParallelism
;
73 uint64_t config::getIndirectCallTableSize() {
74 return __omp_rtl_device_environment
.IndirectCallTableSize
;
77 bool config::isDebugMode(DeviceDebugKind Kind
) {
78 return config::getDebugKind() & uint32_t(Kind
);
81 bool config::mayUseThreadStates() { return !__omp_rtl_assume_no_thread_state
; }
83 bool config::mayUseNestedParallelism() {
84 if (__omp_rtl_assume_no_nested_parallelism
)
86 return state::getKernelEnvironment().Configuration
.MayUseNestedParallelism
;
89 #pragma omp end declare target