Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / openmp / libomptarget / include / Environment.h
blobbd493e8a0be78f11fb50992ba04e1717b033b846
1 //===------------ Environment.h - OpenMP GPU environments --------- 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 // Environments shared between host and device.
11 //===----------------------------------------------------------------------===//
13 #ifndef _OMPTARGET_ENVIRONMENT_H_
14 #define _OMPTARGET_ENVIRONMENT_H_
16 #ifdef OMPTARGET_DEVICE_RUNTIME
17 #include "Types.h"
18 #else
19 #include "SourceInfo.h"
21 #include <cstdint>
23 using IdentTy = ident_t;
24 #endif
26 #include "llvm/Frontend/OpenMP/OMPDeviceConstants.h"
28 enum class DeviceDebugKind : uint32_t {
29 Assertion = 1U << 0,
30 FunctionTracing = 1U << 1,
31 CommonIssues = 1U << 2,
32 AllocationTracker = 1U << 3,
35 struct DeviceEnvironmentTy {
36 uint32_t DeviceDebugKind;
37 uint32_t NumDevices;
38 uint32_t DeviceNum;
39 uint32_t DynamicMemSize;
40 uint64_t ClockFrequency;
41 uintptr_t IndirectCallTable;
42 uint64_t IndirectCallTableSize;
43 uint64_t HardwareParallelism;
46 struct DeviceMemoryPoolTy {
47 void *Ptr;
48 uint64_t Size;
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
61 : AllocationMin;
62 AllocationMax = AllocationMax < Other.AllocationMax ? Other.AllocationMax
63 : 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
73 /// 0.
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.
84 //{
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;
90 //}
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_