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