1 //===------------ Environment.h - OpenMP GPU environments --------- 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 // Environments shared between host and device.
11 //===----------------------------------------------------------------------===//
13 #ifndef _OMPTARGET_ENVIRONMENT_H_
14 #define _OMPTARGET_ENVIRONMENT_H_
16 #ifdef OMPTARGET_DEVICE_RUNTIME
19 #include "SourceInfo.h"
23 using IdentTy
= ident_t
;
26 #include "llvm/Frontend/OpenMP/OMPDeviceConstants.h"
28 enum class DeviceDebugKind
: uint32_t {
30 FunctionTracing
= 1U << 1,
31 CommonIssues
= 1U << 2,
32 AllocationTracker
= 1U << 3,
35 struct DeviceEnvironmentTy
{
36 uint32_t DeviceDebugKind
;
39 uint32_t DynamicMemSize
;
40 uint64_t ClockFrequency
;
41 uintptr_t IndirectCallTable
;
42 uint64_t IndirectCallTableSize
;
43 uint64_t HardwareParallelism
;
46 struct DeviceMemoryPoolTy
{
51 struct DeviceMemoryPoolTrackingTy
{
52 uint64_t NumAllocations
;
53 uint64_t AllocationTotal
;
54 uint64_t AllocationMin
;
55 uint64_t AllocationMax
;
57 void combine(DeviceMemoryPoolTrackingTy
&Other
) {
58 NumAllocations
+= Other
.NumAllocations
;
59 AllocationTotal
+= Other
.AllocationTotal
;
60 AllocationMin
= AllocationMin
> Other
.AllocationMin
? Other
.AllocationMin
62 AllocationMax
= AllocationMax
< Other
.AllocationMax
? Other
.AllocationMax
67 // NOTE: Please don't change the order of those members as their indices are
68 // used in the middle end. Always add the new data member at the end.
69 // Different from KernelEnvironmentTy below, this structure contains members
70 // that might be modified at runtime.
71 struct DynamicEnvironmentTy
{
72 /// Current indentation level for the function trace. Only accessed by thread
74 uint16_t DebugIndentionLevel
;
77 // NOTE: Please don't change the order of those members as their indices are
78 // used in the middle end. Always add the new data member at the end.
79 struct ConfigurationEnvironmentTy
{
80 uint8_t UseGenericStateMachine
= 2;
81 uint8_t MayUseNestedParallelism
= 2;
82 llvm::omp::OMPTgtExecModeFlags ExecMode
= llvm::omp::OMP_TGT_EXEC_MODE_SPMD
;
83 // Information about (legal) launch configurations.
85 int32_t MinThreads
= -1;
86 int32_t MaxThreads
= -1;
87 int32_t MinTeams
= -1;
88 int32_t MaxTeams
= -1;
89 int32_t ReductionBufferSize
= 0;
93 // NOTE: Please don't change the order of those members as their indices are
94 // used in the middle end. Always add the new data member at the end.
95 struct KernelEnvironmentTy
{
96 ConfigurationEnvironmentTy Configuration
;
97 IdentTy
*Ident
= nullptr;
98 DynamicEnvironmentTy
*DynamicEnv
= nullptr;
101 struct KernelLaunchEnvironmentTy
{
102 uint32_t ReductionCnt
= 0;
103 uint32_t ReductionIterCnt
= 0;
104 void *ReductionBuffer
= nullptr;
107 #endif // _OMPTARGET_ENVIRONMENT_H_