1//===- Configuration.cpp - OpenMP device configuration interface -- 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// This file contains the data object of the constant device environment and the
10// query API.
11//
12//===----------------------------------------------------------------------===//
13
14#include "Configuration.h"
15#include "DeviceTypes.h"
16#include "State.h"
17
18using namespace ompx;
19
20// Weak definitions will be overridden by CGOpenmpRuntimeGPU if enabled.
21[[gnu::weak]] extern const uint32_t __omp_rtl_debug_kind = 0;
22[[gnu::weak]] extern const uint32_t __omp_rtl_assume_no_thread_state = 0;
23[[gnu::weak]] extern const uint32_t __omp_rtl_assume_no_nested_parallelism = 0;
24[[gnu::weak]] extern const uint32_t __omp_rtl_assume_threads_oversubscription =
25 0;
26[[gnu::weak]] extern const uint32_t __omp_rtl_assume_teams_oversubscription = 0;
27
28// This variable should be visible to the plugin so we override the default
29// hidden visibility.
30[[gnu::used, gnu::retain, gnu::weak,
31 gnu::visibility(
32 "protected")]] Constant<DeviceEnvironmentTy> __omp_rtl_device_environment;
33
34uint32_t config::getAssumeTeamsOversubscription() {
35 return __omp_rtl_assume_teams_oversubscription;
36}
37
38uint32_t config::getAssumeThreadsOversubscription() {
39 return __omp_rtl_assume_threads_oversubscription;
40}
41
42uint32_t config::getDebugKind() {
43 return __omp_rtl_debug_kind & __omp_rtl_device_environment.DeviceDebugKind;
44}
45
46uint32_t config::getNumDevices() {
47 return __omp_rtl_device_environment.NumDevices;
48}
49
50uint32_t config::getDeviceNum() {
51 return __omp_rtl_device_environment.DeviceNum;
52}
53
54uint64_t config::getDynamicMemorySize() {
55 return __omp_rtl_device_environment.DynamicMemSize;
56}
57
58uint64_t config::getClockFrequency() {
59 return __omp_rtl_device_environment.ClockFrequency;
60}
61
62void *config::getIndirectCallTablePtr() {
63 return reinterpret_cast<void *>(
64 __omp_rtl_device_environment.IndirectCallTable);
65}
66
67uint64_t config::getHardwareParallelism() {
68 return __omp_rtl_device_environment.HardwareParallelism;
69}
70
71uint64_t config::getIndirectCallTableSize() {
72 return __omp_rtl_device_environment.IndirectCallTableSize;
73}
74
75bool config::isDebugMode(DeviceDebugKind Kind) {
76 return config::getDebugKind() & uint32_t(Kind);
77}
78
79bool config::mayUseThreadStates() { return !__omp_rtl_assume_no_thread_state; }
80
81bool config::mayUseNestedParallelism() {
82 if (__omp_rtl_assume_no_nested_parallelism)
83 return false;
84 return state::getKernelEnvironment().Configuration.MayUseNestedParallelism;
85}
86

Provided by KDAB

Privacy Policy
Learn to use CMake with our Intro Training
Find out more

source code of offload/DeviceRTL/src/Configuration.cpp