Skip to content

Commit 489bdcb

Browse files
committed
address reviewer comments
1 parent 529dbb2 commit 489bdcb

File tree

8 files changed

+298
-343
lines changed

8 files changed

+298
-343
lines changed

llvm/include/llvm/Frontend/Offloading/AMDGPU/ObjectUtilities.h

Lines changed: 0 additions & 77 deletions
This file was deleted.

llvm/include/llvm/Frontend/Offloading/Utility.h

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,14 @@
99
#ifndef LLVM_FRONTEND_OFFLOADING_UTILITY_H
1010
#define LLVM_FRONTEND_OFFLOADING_UTILITY_H
1111

12+
#include <cstdint>
13+
14+
#include "llvm/ADT/StringMap.h"
15+
#include "llvm/ADT/StringRef.h"
1216
#include "llvm/IR/Module.h"
1317
#include "llvm/Object/OffloadBinary.h"
18+
#include "llvm/Support/Error.h"
19+
#include "llvm/Support/MemoryBufferRef.h"
1420

1521
namespace llvm {
1622
namespace offloading {
@@ -73,6 +79,60 @@ getOffloadingEntryInitializer(Module &M, Constant *Addr, StringRef Name,
7379
std::pair<GlobalVariable *, GlobalVariable *>
7480
getOffloadEntryArray(Module &M, StringRef SectionName);
7581

82+
namespace amdgpu {
83+
/// Check if an image is compatible with current system's environment. The
84+
/// system environment is given as a 'target-id' which has the form:
85+
///
86+
/// <target-id> := <processor> ( ":" <target-feature> ( "+" | "-" ) )*
87+
///
88+
/// If a feature is not specific as '+' or '-' it is assumed to be in an 'any'
89+
/// and is compatible with either '+' or '-'. The HSA runtime returns this
90+
/// information using the target-id, while we use the ELF header to determine
91+
/// these features.
92+
bool isImageCompatibleWithEnv(StringRef ImageArch, uint32_t ImageFlags,
93+
StringRef EnvTargetID);
94+
95+
/// Struct for holding metadata related to AMDGPU kernels, for more information
96+
/// about the metadata and its meaning see:
97+
/// https://llvm.org/docs/AMDGPUUsage.html#code-object-v3
98+
struct AMDGPUKernelMetaData {
99+
/// Constant indicating that a value is invalid.
100+
static constexpr uint32_t KInvalidValue =
101+
std::numeric_limits<uint32_t>::max();
102+
/// The amount of group segment memory required by a work-group in bytes.
103+
uint32_t GroupSegmentList = KInvalidValue;
104+
/// The amount of fixed private address space memory required for a work-item
105+
/// in bytes.
106+
uint32_t PrivateSegmentSize = KInvalidValue;
107+
/// Number of scalar registers required by a wavefront.
108+
uint32_t SGPRCount = KInvalidValue;
109+
/// Number of vector registers required by each work-item.
110+
uint32_t VGPRCount = KInvalidValue;
111+
/// Number of stores from a scalar register to a register allocator created
112+
/// spill location.
113+
uint32_t SGPRSpillCount = KInvalidValue;
114+
/// Number of stores from a vector register to a register allocator created
115+
/// spill location.
116+
uint32_t VGPRSpillCount = KInvalidValue;
117+
/// Number of accumulator registers required by each work-item.
118+
uint32_t AGPRCount = KInvalidValue;
119+
/// Corresponds to the OpenCL reqd_work_group_size attribute.
120+
uint32_t RequestedWorkgroupSize[3] = {KInvalidValue, KInvalidValue,
121+
KInvalidValue};
122+
/// Corresponds to the OpenCL work_group_size_hint attribute.
123+
uint32_t WorkgroupSizeHint[3] = {KInvalidValue, KInvalidValue, KInvalidValue};
124+
/// Wavefront size.
125+
uint32_t WavefrontSize = KInvalidValue;
126+
/// Maximum flat work-group size supported by the kernel in work-items.
127+
uint32_t MaxFlatWorkgroupSize = KInvalidValue;
128+
};
129+
130+
/// Reads AMDGPU specific metadata from the ELF file and propagates the
131+
/// KernelInfoMap.
132+
Error getAMDGPUMetaDataFromImage(MemoryBufferRef MemBuffer,
133+
StringMap<AMDGPUKernelMetaData> &KernelInfoMap,
134+
uint16_t &ELFABIVersion);
135+
} // namespace amdgpu
76136
} // namespace offloading
77137
} // namespace llvm
78138

llvm/lib/Frontend/Offloading/AMDGPU/CMakeLists.txt

Lines changed: 0 additions & 8 deletions
This file was deleted.

0 commit comments

Comments
 (0)