Warning: This file is not a C or C++ file. It does not have highlighting.
| 1 | //===-- Shared/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. |
| 10 | // |
| 11 | //===----------------------------------------------------------------------===// |
| 12 | |
| 13 | #ifndef OMPTARGET_SHARED_ENVIRONMENT_H |
| 14 | #define OMPTARGET_SHARED_ENVIRONMENT_H |
| 15 | |
| 16 | #include <stdint.h> |
| 17 | |
| 18 | struct IdentTy; |
| 19 | |
| 20 | enum class DeviceDebugKind : uint32_t { |
| 21 | Assertion = 1U << 0, |
| 22 | FunctionTracing = 1U << 1, |
| 23 | CommonIssues = 1U << 2, |
| 24 | AllocationTracker = 1U << 3, |
| 25 | PGODump = 1U << 4, |
| 26 | }; |
| 27 | |
| 28 | struct DeviceEnvironmentTy { |
| 29 | uint32_t DeviceDebugKind; |
| 30 | uint32_t NumDevices; |
| 31 | uint32_t DeviceNum; |
| 32 | uint32_t DynamicMemSize; |
| 33 | uint64_t ClockFrequency; |
| 34 | uintptr_t IndirectCallTable; |
| 35 | uint64_t IndirectCallTableSize; |
| 36 | uint64_t HardwareParallelism; |
| 37 | }; |
| 38 | |
| 39 | struct DeviceMemoryPoolTy { |
| 40 | void *Ptr; |
| 41 | uint64_t Size; |
| 42 | }; |
| 43 | |
| 44 | struct DeviceMemoryPoolTrackingTy { |
| 45 | uint64_t NumAllocations; |
| 46 | uint64_t AllocationTotal; |
| 47 | uint64_t AllocationMin; |
| 48 | uint64_t AllocationMax; |
| 49 | |
| 50 | void combine(DeviceMemoryPoolTrackingTy &Other) { |
| 51 | NumAllocations += Other.NumAllocations; |
| 52 | AllocationTotal += Other.AllocationTotal; |
| 53 | AllocationMin = AllocationMin > Other.AllocationMin ? Other.AllocationMin |
| 54 | : AllocationMin; |
| 55 | AllocationMax = AllocationMax < Other.AllocationMax ? Other.AllocationMax |
| 56 | : AllocationMax; |
| 57 | } |
| 58 | }; |
| 59 | |
| 60 | // NOTE: Please don't change the order of those members as their indices are |
| 61 | // used in the middle end. Always add the new data member at the end. |
| 62 | // Different from KernelEnvironmentTy below, this structure contains members |
| 63 | // that might be modified at runtime. |
| 64 | struct DynamicEnvironmentTy { |
| 65 | /// Current indentation level for the function trace. Only accessed by thread |
| 66 | /// 0. |
| 67 | uint16_t DebugIndentionLevel; |
| 68 | }; |
| 69 | |
| 70 | // NOTE: Please don't change the order of those members as their indices are |
| 71 | // used in the middle end. Always add the new data member at the end. |
| 72 | struct ConfigurationEnvironmentTy { |
| 73 | uint8_t UseGenericStateMachine = 2; |
| 74 | uint8_t MayUseNestedParallelism = 2; |
| 75 | uint8_t ExecMode = 0; |
| 76 | // Information about (legal) launch configurations. |
| 77 | //{ |
| 78 | int32_t MinThreads = -1; |
| 79 | int32_t MaxThreads = -1; |
| 80 | int32_t MinTeams = -1; |
| 81 | int32_t MaxTeams = -1; |
| 82 | int32_t ReductionDataSize = 0; |
| 83 | int32_t ReductionBufferLength = 0; |
| 84 | //} |
| 85 | }; |
| 86 | |
| 87 | // NOTE: Please don't change the order of those members as their indices are |
| 88 | // used in the middle end. Always add the new data member at the end. |
| 89 | struct KernelEnvironmentTy { |
| 90 | ConfigurationEnvironmentTy Configuration; |
| 91 | IdentTy *Ident = nullptr; |
| 92 | DynamicEnvironmentTy *DynamicEnv = nullptr; |
| 93 | }; |
| 94 | |
| 95 | struct KernelLaunchEnvironmentTy { |
| 96 | uint32_t ReductionCnt = 0; |
| 97 | uint32_t ReductionIterCnt = 0; |
| 98 | void *ReductionBuffer = nullptr; |
| 99 | }; |
| 100 | |
| 101 | #endif // OMPTARGET_SHARED_ENVIRONMENT_H |
| 102 |
Warning: This file is not a C or C++ file. It does not have highlighting.
