2017-10-12 00:18:53 +02:00
|
|
|
//===--- AMDGPUMetadata.h ---------------------------------------*- C++ -*-===//
|
2017-03-22 23:32:22 +01:00
|
|
|
//
|
2019-01-19 09:50:56 +01:00
|
|
|
// 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
|
2017-03-22 23:32:22 +01:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
/// \file
|
2018-05-01 17:54:18 +02:00
|
|
|
/// AMDGPU metadata definitions and in-memory representations.
|
2017-03-22 23:32:22 +01:00
|
|
|
///
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2017-10-12 00:18:53 +02:00
|
|
|
#ifndef LLVM_SUPPORT_AMDGPUMETADATA_H
|
|
|
|
#define LLVM_SUPPORT_AMDGPUMETADATA_H
|
2017-03-22 23:32:22 +01:00
|
|
|
|
2021-01-26 17:09:27 +01:00
|
|
|
#include "llvm/ADT/StringRef.h"
|
2017-03-22 23:32:22 +01:00
|
|
|
#include <cstdint>
|
|
|
|
#include <string>
|
|
|
|
#include <system_error>
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
namespace llvm {
|
|
|
|
namespace AMDGPU {
|
|
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
2017-10-12 00:18:53 +02:00
|
|
|
// HSA metadata.
|
2017-03-22 23:32:22 +01:00
|
|
|
//===----------------------------------------------------------------------===//
|
2017-10-12 00:18:53 +02:00
|
|
|
namespace HSAMD {
|
2017-03-22 23:32:22 +01:00
|
|
|
|
2021-03-24 16:52:10 +01:00
|
|
|
/// HSA metadata major version for code object V2.
|
|
|
|
constexpr uint32_t VersionMajorV2 = 1;
|
|
|
|
/// HSA metadata minor version for code object V2.
|
|
|
|
constexpr uint32_t VersionMinorV2 = 0;
|
|
|
|
|
|
|
|
/// HSA metadata major version for code object V3.
|
|
|
|
constexpr uint32_t VersionMajorV3 = 1;
|
|
|
|
/// HSA metadata minor version for code object V3.
|
|
|
|
constexpr uint32_t VersionMinorV3 = 0;
|
|
|
|
|
|
|
|
/// HSA metadata major version for code object V4.
|
|
|
|
constexpr uint32_t VersionMajorV4 = 1;
|
|
|
|
/// HSA metadata minor version for code object V4.
|
|
|
|
constexpr uint32_t VersionMinorV4 = 1;
|
2017-03-22 23:32:22 +01:00
|
|
|
|
2018-05-01 17:54:18 +02:00
|
|
|
/// HSA metadata beginning assembler directive.
|
2017-10-12 00:18:53 +02:00
|
|
|
constexpr char AssemblerDirectiveBegin[] = ".amd_amdgpu_hsa_metadata";
|
2018-05-01 17:54:18 +02:00
|
|
|
/// HSA metadata ending assembler directive.
|
2017-10-12 00:18:53 +02:00
|
|
|
constexpr char AssemblerDirectiveEnd[] = ".end_amd_amdgpu_hsa_metadata";
|
2017-03-22 23:32:22 +01:00
|
|
|
|
2018-05-01 17:54:18 +02:00
|
|
|
/// Access qualifiers.
|
2017-03-22 23:32:22 +01:00
|
|
|
enum class AccessQualifier : uint8_t {
|
|
|
|
Default = 0,
|
|
|
|
ReadOnly = 1,
|
|
|
|
WriteOnly = 2,
|
|
|
|
ReadWrite = 3,
|
|
|
|
Unknown = 0xff
|
|
|
|
};
|
|
|
|
|
2018-05-01 17:54:18 +02:00
|
|
|
/// Address space qualifiers.
|
2017-03-22 23:32:22 +01:00
|
|
|
enum class AddressSpaceQualifier : uint8_t {
|
|
|
|
Private = 0,
|
|
|
|
Global = 1,
|
|
|
|
Constant = 2,
|
|
|
|
Local = 3,
|
|
|
|
Generic = 4,
|
|
|
|
Region = 5,
|
|
|
|
Unknown = 0xff
|
|
|
|
};
|
|
|
|
|
2018-05-01 17:54:18 +02:00
|
|
|
/// Value kinds.
|
2017-03-22 23:32:22 +01:00
|
|
|
enum class ValueKind : uint8_t {
|
|
|
|
ByValue = 0,
|
|
|
|
GlobalBuffer = 1,
|
|
|
|
DynamicSharedPointer = 2,
|
|
|
|
Sampler = 3,
|
|
|
|
Image = 4,
|
|
|
|
Pipe = 5,
|
|
|
|
Queue = 6,
|
|
|
|
HiddenGlobalOffsetX = 7,
|
|
|
|
HiddenGlobalOffsetY = 8,
|
|
|
|
HiddenGlobalOffsetZ = 9,
|
|
|
|
HiddenNone = 10,
|
|
|
|
HiddenPrintfBuffer = 11,
|
|
|
|
HiddenDefaultQueue = 12,
|
|
|
|
HiddenCompletionAction = 13,
|
2019-07-05 18:05:17 +02:00
|
|
|
HiddenMultiGridSyncArg = 14,
|
2019-11-19 09:35:39 +01:00
|
|
|
HiddenHostcallBuffer = 15,
|
2017-03-22 23:32:22 +01:00
|
|
|
Unknown = 0xff
|
|
|
|
};
|
|
|
|
|
2020-06-29 23:02:10 +02:00
|
|
|
/// Value types. This is deprecated and only remains for compatibility parsing
|
|
|
|
/// of old metadata.
|
2017-03-22 23:32:22 +01:00
|
|
|
enum class ValueType : uint8_t {
|
|
|
|
Struct = 0,
|
|
|
|
I8 = 1,
|
|
|
|
U8 = 2,
|
|
|
|
I16 = 3,
|
|
|
|
U16 = 4,
|
|
|
|
F16 = 5,
|
|
|
|
I32 = 6,
|
|
|
|
U32 = 7,
|
|
|
|
F32 = 8,
|
|
|
|
I64 = 9,
|
|
|
|
U64 = 10,
|
|
|
|
F64 = 11,
|
|
|
|
Unknown = 0xff
|
|
|
|
};
|
|
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// Kernel Metadata.
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
namespace Kernel {
|
|
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// Kernel Attributes Metadata.
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
namespace Attrs {
|
|
|
|
|
|
|
|
namespace Key {
|
2018-05-01 17:54:18 +02:00
|
|
|
/// Key for Kernel::Attr::Metadata::mReqdWorkGroupSize.
|
2017-03-22 23:32:22 +01:00
|
|
|
constexpr char ReqdWorkGroupSize[] = "ReqdWorkGroupSize";
|
2018-05-01 17:54:18 +02:00
|
|
|
/// Key for Kernel::Attr::Metadata::mWorkGroupSizeHint.
|
2017-03-22 23:32:22 +01:00
|
|
|
constexpr char WorkGroupSizeHint[] = "WorkGroupSizeHint";
|
2018-05-01 17:54:18 +02:00
|
|
|
/// Key for Kernel::Attr::Metadata::mVecTypeHint.
|
2017-03-22 23:32:22 +01:00
|
|
|
constexpr char VecTypeHint[] = "VecTypeHint";
|
2018-05-01 17:54:18 +02:00
|
|
|
/// Key for Kernel::Attr::Metadata::mRuntimeHandle.
|
2017-10-10 21:39:48 +02:00
|
|
|
constexpr char RuntimeHandle[] = "RuntimeHandle";
|
2017-03-22 23:32:22 +01:00
|
|
|
} // end namespace Key
|
|
|
|
|
2018-05-01 17:54:18 +02:00
|
|
|
/// In-memory representation of kernel attributes metadata.
|
2017-03-22 23:32:22 +01:00
|
|
|
struct Metadata final {
|
2018-05-01 17:54:18 +02:00
|
|
|
/// 'reqd_work_group_size' attribute. Optional.
|
2017-03-22 23:32:22 +01:00
|
|
|
std::vector<uint32_t> mReqdWorkGroupSize = std::vector<uint32_t>();
|
2018-05-01 17:54:18 +02:00
|
|
|
/// 'work_group_size_hint' attribute. Optional.
|
2017-03-22 23:32:22 +01:00
|
|
|
std::vector<uint32_t> mWorkGroupSizeHint = std::vector<uint32_t>();
|
2018-05-01 17:54:18 +02:00
|
|
|
/// 'vec_type_hint' attribute. Optional.
|
2017-03-22 23:32:22 +01:00
|
|
|
std::string mVecTypeHint = std::string();
|
2018-05-01 17:54:18 +02:00
|
|
|
/// External symbol created by runtime to store the kernel address
|
2017-10-10 21:39:48 +02:00
|
|
|
/// for enqueued blocks.
|
|
|
|
std::string mRuntimeHandle = std::string();
|
2017-03-22 23:32:22 +01:00
|
|
|
|
2018-05-01 17:54:18 +02:00
|
|
|
/// Default constructor.
|
2017-03-22 23:32:22 +01:00
|
|
|
Metadata() = default;
|
|
|
|
|
|
|
|
/// \returns True if kernel attributes metadata is empty, false otherwise.
|
|
|
|
bool empty() const {
|
2017-10-14 21:03:51 +02:00
|
|
|
return !notEmpty();
|
2017-03-22 23:32:22 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/// \returns True if kernel attributes metadata is not empty, false otherwise.
|
|
|
|
bool notEmpty() const {
|
2017-10-14 21:03:51 +02:00
|
|
|
return !mReqdWorkGroupSize.empty() || !mWorkGroupSizeHint.empty() ||
|
|
|
|
!mVecTypeHint.empty() || !mRuntimeHandle.empty();
|
2017-03-22 23:32:22 +01:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
} // end namespace Attrs
|
|
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// Kernel Argument Metadata.
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
namespace Arg {
|
|
|
|
|
|
|
|
namespace Key {
|
2018-05-01 17:54:18 +02:00
|
|
|
/// Key for Kernel::Arg::Metadata::mName.
|
2017-10-14 21:03:51 +02:00
|
|
|
constexpr char Name[] = "Name";
|
2018-05-01 17:54:18 +02:00
|
|
|
/// Key for Kernel::Arg::Metadata::mTypeName.
|
2017-10-14 21:03:51 +02:00
|
|
|
constexpr char TypeName[] = "TypeName";
|
2018-05-01 17:54:18 +02:00
|
|
|
/// Key for Kernel::Arg::Metadata::mSize.
|
2017-03-22 23:32:22 +01:00
|
|
|
constexpr char Size[] = "Size";
|
2019-04-03 21:07:29 +02:00
|
|
|
/// Key for Kernel::Arg::Metadata::mOffset.
|
|
|
|
constexpr char Offset[] = "Offset";
|
2018-05-01 17:54:18 +02:00
|
|
|
/// Key for Kernel::Arg::Metadata::mAlign.
|
2017-03-22 23:32:22 +01:00
|
|
|
constexpr char Align[] = "Align";
|
2018-05-01 17:54:18 +02:00
|
|
|
/// Key for Kernel::Arg::Metadata::mValueKind.
|
2017-03-24 19:43:15 +01:00
|
|
|
constexpr char ValueKind[] = "ValueKind";
|
2020-06-29 23:02:10 +02:00
|
|
|
/// Key for Kernel::Arg::Metadata::mValueType. (deprecated)
|
2017-03-22 23:32:22 +01:00
|
|
|
constexpr char ValueType[] = "ValueType";
|
2018-05-01 17:54:18 +02:00
|
|
|
/// Key for Kernel::Arg::Metadata::mPointeeAlign.
|
2017-03-22 23:32:22 +01:00
|
|
|
constexpr char PointeeAlign[] = "PointeeAlign";
|
2018-05-01 17:54:18 +02:00
|
|
|
/// Key for Kernel::Arg::Metadata::mAddrSpaceQual.
|
2017-03-22 23:32:22 +01:00
|
|
|
constexpr char AddrSpaceQual[] = "AddrSpaceQual";
|
2018-05-01 17:54:18 +02:00
|
|
|
/// Key for Kernel::Arg::Metadata::mAccQual.
|
2017-10-14 21:03:51 +02:00
|
|
|
constexpr char AccQual[] = "AccQual";
|
2018-05-01 17:54:18 +02:00
|
|
|
/// Key for Kernel::Arg::Metadata::mActualAccQual.
|
2017-10-14 21:03:51 +02:00
|
|
|
constexpr char ActualAccQual[] = "ActualAccQual";
|
2018-05-01 17:54:18 +02:00
|
|
|
/// Key for Kernel::Arg::Metadata::mIsConst.
|
2017-03-22 23:32:22 +01:00
|
|
|
constexpr char IsConst[] = "IsConst";
|
2018-05-01 17:54:18 +02:00
|
|
|
/// Key for Kernel::Arg::Metadata::mIsRestrict.
|
2017-03-22 23:32:22 +01:00
|
|
|
constexpr char IsRestrict[] = "IsRestrict";
|
2018-05-01 17:54:18 +02:00
|
|
|
/// Key for Kernel::Arg::Metadata::mIsVolatile.
|
2017-03-22 23:32:22 +01:00
|
|
|
constexpr char IsVolatile[] = "IsVolatile";
|
2018-05-01 17:54:18 +02:00
|
|
|
/// Key for Kernel::Arg::Metadata::mIsPipe.
|
2017-10-14 21:03:51 +02:00
|
|
|
constexpr char IsPipe[] = "IsPipe";
|
2017-03-22 23:32:22 +01:00
|
|
|
} // end namespace Key
|
|
|
|
|
2018-05-01 17:54:18 +02:00
|
|
|
/// In-memory representation of kernel argument metadata.
|
2017-03-22 23:32:22 +01:00
|
|
|
struct Metadata final {
|
2018-05-01 17:54:18 +02:00
|
|
|
/// Name. Optional.
|
2017-10-14 21:03:51 +02:00
|
|
|
std::string mName = std::string();
|
2018-05-01 17:54:18 +02:00
|
|
|
/// Type name. Optional.
|
2017-10-14 21:03:51 +02:00
|
|
|
std::string mTypeName = std::string();
|
2018-05-01 17:54:18 +02:00
|
|
|
/// Size in bytes. Required.
|
2017-03-22 23:32:22 +01:00
|
|
|
uint32_t mSize = 0;
|
2019-04-03 21:07:29 +02:00
|
|
|
/// Offset in bytes. Required for code object v3, unused for code object v2.
|
|
|
|
uint32_t mOffset = 0;
|
2018-05-01 17:54:18 +02:00
|
|
|
/// Alignment in bytes. Required.
|
2017-03-22 23:32:22 +01:00
|
|
|
uint32_t mAlign = 0;
|
2018-05-01 17:54:18 +02:00
|
|
|
/// Value kind. Required.
|
2017-03-22 23:32:22 +01:00
|
|
|
ValueKind mValueKind = ValueKind::Unknown;
|
2018-05-01 17:54:18 +02:00
|
|
|
/// Pointee alignment in bytes. Optional.
|
2017-03-22 23:32:22 +01:00
|
|
|
uint32_t mPointeeAlign = 0;
|
2018-05-01 17:54:18 +02:00
|
|
|
/// Address space qualifier. Optional.
|
2017-03-22 23:32:22 +01:00
|
|
|
AddressSpaceQualifier mAddrSpaceQual = AddressSpaceQualifier::Unknown;
|
2018-05-01 17:54:18 +02:00
|
|
|
/// Access qualifier. Optional.
|
2017-10-14 21:03:51 +02:00
|
|
|
AccessQualifier mAccQual = AccessQualifier::Unknown;
|
2018-05-01 17:54:18 +02:00
|
|
|
/// Actual access qualifier. Optional.
|
2017-10-14 21:03:51 +02:00
|
|
|
AccessQualifier mActualAccQual = AccessQualifier::Unknown;
|
2018-05-01 17:54:18 +02:00
|
|
|
/// True if 'const' qualifier is specified. Optional.
|
2017-03-22 23:32:22 +01:00
|
|
|
bool mIsConst = false;
|
2018-05-01 17:54:18 +02:00
|
|
|
/// True if 'restrict' qualifier is specified. Optional.
|
2017-03-22 23:32:22 +01:00
|
|
|
bool mIsRestrict = false;
|
2018-05-01 17:54:18 +02:00
|
|
|
/// True if 'volatile' qualifier is specified. Optional.
|
2017-03-22 23:32:22 +01:00
|
|
|
bool mIsVolatile = false;
|
2018-05-01 17:54:18 +02:00
|
|
|
/// True if 'pipe' qualifier is specified. Optional.
|
2017-10-14 21:03:51 +02:00
|
|
|
bool mIsPipe = false;
|
2017-03-22 23:32:22 +01:00
|
|
|
|
2018-05-01 17:54:18 +02:00
|
|
|
/// Default constructor.
|
2017-03-22 23:32:22 +01:00
|
|
|
Metadata() = default;
|
|
|
|
};
|
|
|
|
|
|
|
|
} // end namespace Arg
|
|
|
|
|
2017-03-22 23:54:39 +01:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// Kernel Code Properties Metadata.
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
namespace CodeProps {
|
|
|
|
|
|
|
|
namespace Key {
|
2018-05-01 17:54:18 +02:00
|
|
|
/// Key for Kernel::CodeProps::Metadata::mKernargSegmentSize.
|
2017-03-22 23:54:39 +01:00
|
|
|
constexpr char KernargSegmentSize[] = "KernargSegmentSize";
|
2018-05-01 17:54:18 +02:00
|
|
|
/// Key for Kernel::CodeProps::Metadata::mGroupSegmentFixedSize.
|
2017-10-14 21:03:51 +02:00
|
|
|
constexpr char GroupSegmentFixedSize[] = "GroupSegmentFixedSize";
|
2018-05-01 17:54:18 +02:00
|
|
|
/// Key for Kernel::CodeProps::Metadata::mPrivateSegmentFixedSize.
|
2017-10-14 21:03:51 +02:00
|
|
|
constexpr char PrivateSegmentFixedSize[] = "PrivateSegmentFixedSize";
|
2018-05-01 17:54:18 +02:00
|
|
|
/// Key for Kernel::CodeProps::Metadata::mKernargSegmentAlign.
|
2017-03-22 23:54:39 +01:00
|
|
|
constexpr char KernargSegmentAlign[] = "KernargSegmentAlign";
|
2018-05-01 17:54:18 +02:00
|
|
|
/// Key for Kernel::CodeProps::Metadata::mWavefrontSize.
|
2017-03-22 23:54:39 +01:00
|
|
|
constexpr char WavefrontSize[] = "WavefrontSize";
|
2018-05-01 17:54:18 +02:00
|
|
|
/// Key for Kernel::CodeProps::Metadata::mNumSGPRs.
|
2017-10-14 21:03:51 +02:00
|
|
|
constexpr char NumSGPRs[] = "NumSGPRs";
|
2018-05-01 17:54:18 +02:00
|
|
|
/// Key for Kernel::CodeProps::Metadata::mNumVGPRs.
|
2017-10-14 21:03:51 +02:00
|
|
|
constexpr char NumVGPRs[] = "NumVGPRs";
|
2018-05-01 17:54:18 +02:00
|
|
|
/// Key for Kernel::CodeProps::Metadata::mMaxFlatWorkGroupSize.
|
2017-10-18 19:31:09 +02:00
|
|
|
constexpr char MaxFlatWorkGroupSize[] = "MaxFlatWorkGroupSize";
|
2018-05-01 17:54:18 +02:00
|
|
|
/// Key for Kernel::CodeProps::Metadata::mIsDynamicCallStack.
|
2017-10-14 21:03:51 +02:00
|
|
|
constexpr char IsDynamicCallStack[] = "IsDynamicCallStack";
|
2018-05-01 17:54:18 +02:00
|
|
|
/// Key for Kernel::CodeProps::Metadata::mIsXNACKEnabled.
|
2017-10-14 21:03:51 +02:00
|
|
|
constexpr char IsXNACKEnabled[] = "IsXNACKEnabled";
|
2018-05-01 17:54:18 +02:00
|
|
|
/// Key for Kernel::CodeProps::Metadata::mNumSpilledSGPRs.
|
2017-11-28 18:51:08 +01:00
|
|
|
constexpr char NumSpilledSGPRs[] = "NumSpilledSGPRs";
|
2018-05-01 17:54:18 +02:00
|
|
|
/// Key for Kernel::CodeProps::Metadata::mNumSpilledVGPRs.
|
2017-11-28 18:51:08 +01:00
|
|
|
constexpr char NumSpilledVGPRs[] = "NumSpilledVGPRs";
|
2017-03-22 23:54:39 +01:00
|
|
|
} // end namespace Key
|
|
|
|
|
2018-05-01 17:54:18 +02:00
|
|
|
/// In-memory representation of kernel code properties metadata.
|
2017-03-22 23:54:39 +01:00
|
|
|
struct Metadata final {
|
2018-05-01 17:54:18 +02:00
|
|
|
/// Size in bytes of the kernarg segment memory. Kernarg segment memory
|
2017-10-14 21:03:51 +02:00
|
|
|
/// holds the values of the arguments to the kernel. Required.
|
2017-03-22 23:54:39 +01:00
|
|
|
uint64_t mKernargSegmentSize = 0;
|
2018-05-01 17:54:18 +02:00
|
|
|
/// Size in bytes of the group segment memory required by a workgroup.
|
2017-03-22 23:54:39 +01:00
|
|
|
/// This value does not include any dynamically allocated group segment memory
|
2017-10-14 21:03:51 +02:00
|
|
|
/// that may be added when the kernel is dispatched. Required.
|
|
|
|
uint32_t mGroupSegmentFixedSize = 0;
|
2018-05-01 17:54:18 +02:00
|
|
|
/// Size in bytes of the private segment memory required by a workitem.
|
2017-10-14 21:03:51 +02:00
|
|
|
/// Private segment memory includes arg, spill and private segments. Required.
|
|
|
|
uint32_t mPrivateSegmentFixedSize = 0;
|
2018-05-01 17:54:18 +02:00
|
|
|
/// Maximum byte alignment of variables used by the kernel in the
|
2017-10-14 21:03:51 +02:00
|
|
|
/// kernarg memory segment. Required.
|
|
|
|
uint32_t mKernargSegmentAlign = 0;
|
2018-05-01 17:54:18 +02:00
|
|
|
/// Wavefront size. Required.
|
2017-10-14 21:03:51 +02:00
|
|
|
uint32_t mWavefrontSize = 0;
|
2018-05-01 17:54:18 +02:00
|
|
|
/// Total number of SGPRs used by a wavefront. Optional.
|
2017-10-14 21:03:51 +02:00
|
|
|
uint16_t mNumSGPRs = 0;
|
2018-05-01 17:54:18 +02:00
|
|
|
/// Total number of VGPRs used by a workitem. Optional.
|
2017-10-14 21:03:51 +02:00
|
|
|
uint16_t mNumVGPRs = 0;
|
2018-05-01 17:54:18 +02:00
|
|
|
/// Maximum flat work-group size supported by the kernel. Optional.
|
2017-10-18 19:31:09 +02:00
|
|
|
uint32_t mMaxFlatWorkGroupSize = 0;
|
2018-05-01 17:54:18 +02:00
|
|
|
/// True if the generated machine code is using a dynamically sized
|
2017-10-14 21:03:51 +02:00
|
|
|
/// call stack. Optional.
|
|
|
|
bool mIsDynamicCallStack = false;
|
2018-05-01 17:54:18 +02:00
|
|
|
/// True if the generated machine code is capable of supporting XNACK.
|
2017-10-14 21:03:51 +02:00
|
|
|
/// Optional.
|
|
|
|
bool mIsXNACKEnabled = false;
|
2018-05-01 17:54:18 +02:00
|
|
|
/// Number of SGPRs spilled by a wavefront. Optional.
|
2017-11-28 18:51:08 +01:00
|
|
|
uint16_t mNumSpilledSGPRs = 0;
|
2018-05-01 17:54:18 +02:00
|
|
|
/// Number of VGPRs spilled by a workitem. Optional.
|
2017-11-28 18:51:08 +01:00
|
|
|
uint16_t mNumSpilledVGPRs = 0;
|
2017-03-22 23:54:39 +01:00
|
|
|
|
2018-05-01 17:54:18 +02:00
|
|
|
/// Default constructor.
|
2017-03-22 23:54:39 +01:00
|
|
|
Metadata() = default;
|
|
|
|
|
|
|
|
/// \returns True if kernel code properties metadata is empty, false
|
|
|
|
/// otherwise.
|
|
|
|
bool empty() const {
|
|
|
|
return !notEmpty();
|
|
|
|
}
|
|
|
|
|
|
|
|
/// \returns True if kernel code properties metadata is not empty, false
|
|
|
|
/// otherwise.
|
|
|
|
bool notEmpty() const {
|
2017-10-14 21:03:51 +02:00
|
|
|
return true;
|
2017-03-22 23:54:39 +01:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
} // end namespace CodeProps
|
|
|
|
|
2017-03-23 00:10:46 +01:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// Kernel Debug Properties Metadata.
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
namespace DebugProps {
|
|
|
|
|
|
|
|
namespace Key {
|
2018-05-01 17:54:18 +02:00
|
|
|
/// Key for Kernel::DebugProps::Metadata::mDebuggerABIVersion.
|
2017-03-23 00:10:46 +01:00
|
|
|
constexpr char DebuggerABIVersion[] = "DebuggerABIVersion";
|
2018-05-01 17:54:18 +02:00
|
|
|
/// Key for Kernel::DebugProps::Metadata::mReservedNumVGPRs.
|
2017-03-23 00:10:46 +01:00
|
|
|
constexpr char ReservedNumVGPRs[] = "ReservedNumVGPRs";
|
2018-05-01 17:54:18 +02:00
|
|
|
/// Key for Kernel::DebugProps::Metadata::mReservedFirstVGPR.
|
2017-03-23 00:10:46 +01:00
|
|
|
constexpr char ReservedFirstVGPR[] = "ReservedFirstVGPR";
|
2018-05-01 17:54:18 +02:00
|
|
|
/// Key for Kernel::DebugProps::Metadata::mPrivateSegmentBufferSGPR.
|
2017-03-23 00:10:46 +01:00
|
|
|
constexpr char PrivateSegmentBufferSGPR[] = "PrivateSegmentBufferSGPR";
|
2018-05-01 17:54:18 +02:00
|
|
|
/// Key for
|
2017-03-23 00:10:46 +01:00
|
|
|
/// Kernel::DebugProps::Metadata::mWavefrontPrivateSegmentOffsetSGPR.
|
|
|
|
constexpr char WavefrontPrivateSegmentOffsetSGPR[] =
|
|
|
|
"WavefrontPrivateSegmentOffsetSGPR";
|
|
|
|
} // end namespace Key
|
|
|
|
|
2018-05-01 17:54:18 +02:00
|
|
|
/// In-memory representation of kernel debug properties metadata.
|
2017-03-23 00:10:46 +01:00
|
|
|
struct Metadata final {
|
2018-05-01 17:54:18 +02:00
|
|
|
/// Debugger ABI version. Optional.
|
2017-03-23 00:10:46 +01:00
|
|
|
std::vector<uint32_t> mDebuggerABIVersion = std::vector<uint32_t>();
|
2018-05-01 17:54:18 +02:00
|
|
|
/// Consecutive number of VGPRs reserved for debugger use. Must be 0 if
|
2017-03-23 00:10:46 +01:00
|
|
|
/// mDebuggerABIVersion is not set. Optional.
|
|
|
|
uint16_t mReservedNumVGPRs = 0;
|
2018-05-01 17:54:18 +02:00
|
|
|
/// First fixed VGPR reserved. Must be uint16_t(-1) if
|
2017-03-23 00:10:46 +01:00
|
|
|
/// mDebuggerABIVersion is not set or mReservedFirstVGPR is 0. Optional.
|
|
|
|
uint16_t mReservedFirstVGPR = uint16_t(-1);
|
2018-05-01 17:54:18 +02:00
|
|
|
/// Fixed SGPR of the first of 4 SGPRs used to hold the scratch V# used
|
2017-03-23 00:10:46 +01:00
|
|
|
/// for the entire kernel execution. Must be uint16_t(-1) if
|
|
|
|
/// mDebuggerABIVersion is not set or SGPR not used or not known. Optional.
|
|
|
|
uint16_t mPrivateSegmentBufferSGPR = uint16_t(-1);
|
2018-05-01 17:54:18 +02:00
|
|
|
/// Fixed SGPR used to hold the wave scratch offset for the entire
|
2017-03-23 00:10:46 +01:00
|
|
|
/// kernel execution. Must be uint16_t(-1) if mDebuggerABIVersion is not set
|
|
|
|
/// or SGPR is not used or not known. Optional.
|
|
|
|
uint16_t mWavefrontPrivateSegmentOffsetSGPR = uint16_t(-1);
|
|
|
|
|
2018-05-01 17:54:18 +02:00
|
|
|
/// Default constructor.
|
2017-03-23 00:10:46 +01:00
|
|
|
Metadata() = default;
|
|
|
|
|
|
|
|
/// \returns True if kernel debug properties metadata is empty, false
|
|
|
|
/// otherwise.
|
|
|
|
bool empty() const {
|
|
|
|
return !notEmpty();
|
|
|
|
}
|
|
|
|
|
|
|
|
/// \returns True if kernel debug properties metadata is not empty, false
|
|
|
|
/// otherwise.
|
|
|
|
bool notEmpty() const {
|
|
|
|
return !mDebuggerABIVersion.empty();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
} // end namespace DebugProps
|
|
|
|
|
2017-03-22 23:32:22 +01:00
|
|
|
namespace Key {
|
2018-05-01 17:54:18 +02:00
|
|
|
/// Key for Kernel::Metadata::mName.
|
2017-03-22 23:32:22 +01:00
|
|
|
constexpr char Name[] = "Name";
|
2018-05-01 17:54:18 +02:00
|
|
|
/// Key for Kernel::Metadata::mSymbolName.
|
2017-10-14 21:03:51 +02:00
|
|
|
constexpr char SymbolName[] = "SymbolName";
|
2018-05-01 17:54:18 +02:00
|
|
|
/// Key for Kernel::Metadata::mLanguage.
|
2017-03-22 23:32:22 +01:00
|
|
|
constexpr char Language[] = "Language";
|
2018-05-01 17:54:18 +02:00
|
|
|
/// Key for Kernel::Metadata::mLanguageVersion.
|
2017-03-22 23:32:22 +01:00
|
|
|
constexpr char LanguageVersion[] = "LanguageVersion";
|
2018-05-01 17:54:18 +02:00
|
|
|
/// Key for Kernel::Metadata::mAttrs.
|
2017-03-22 23:32:22 +01:00
|
|
|
constexpr char Attrs[] = "Attrs";
|
2018-05-01 17:54:18 +02:00
|
|
|
/// Key for Kernel::Metadata::mArgs.
|
2017-03-22 23:32:22 +01:00
|
|
|
constexpr char Args[] = "Args";
|
2018-05-01 17:54:18 +02:00
|
|
|
/// Key for Kernel::Metadata::mCodeProps.
|
2017-03-22 23:54:39 +01:00
|
|
|
constexpr char CodeProps[] = "CodeProps";
|
2018-05-01 17:54:18 +02:00
|
|
|
/// Key for Kernel::Metadata::mDebugProps.
|
2017-03-23 00:10:46 +01:00
|
|
|
constexpr char DebugProps[] = "DebugProps";
|
2017-03-22 23:32:22 +01:00
|
|
|
} // end namespace Key
|
|
|
|
|
2018-05-01 17:54:18 +02:00
|
|
|
/// In-memory representation of kernel metadata.
|
2017-03-22 23:32:22 +01:00
|
|
|
struct Metadata final {
|
2018-05-01 17:54:18 +02:00
|
|
|
/// Kernel source name. Required.
|
2017-03-22 23:32:22 +01:00
|
|
|
std::string mName = std::string();
|
2018-05-01 17:54:18 +02:00
|
|
|
/// Kernel descriptor name. Required.
|
2017-10-14 21:03:51 +02:00
|
|
|
std::string mSymbolName = std::string();
|
2018-05-01 17:54:18 +02:00
|
|
|
/// Language. Optional.
|
2017-03-22 23:32:22 +01:00
|
|
|
std::string mLanguage = std::string();
|
2018-05-01 17:54:18 +02:00
|
|
|
/// Language version. Optional.
|
2017-03-22 23:32:22 +01:00
|
|
|
std::vector<uint32_t> mLanguageVersion = std::vector<uint32_t>();
|
2018-05-01 17:54:18 +02:00
|
|
|
/// Attributes metadata. Optional.
|
2017-03-22 23:32:22 +01:00
|
|
|
Attrs::Metadata mAttrs = Attrs::Metadata();
|
2018-05-01 17:54:18 +02:00
|
|
|
/// Arguments metadata. Optional.
|
2017-03-22 23:32:22 +01:00
|
|
|
std::vector<Arg::Metadata> mArgs = std::vector<Arg::Metadata>();
|
2018-05-01 17:54:18 +02:00
|
|
|
/// Code properties metadata. Optional.
|
2017-03-22 23:54:39 +01:00
|
|
|
CodeProps::Metadata mCodeProps = CodeProps::Metadata();
|
2018-05-01 17:54:18 +02:00
|
|
|
/// Debug properties metadata. Optional.
|
2017-03-23 00:10:46 +01:00
|
|
|
DebugProps::Metadata mDebugProps = DebugProps::Metadata();
|
2017-03-22 23:32:22 +01:00
|
|
|
|
2018-05-01 17:54:18 +02:00
|
|
|
/// Default constructor.
|
2017-03-22 23:32:22 +01:00
|
|
|
Metadata() = default;
|
|
|
|
};
|
|
|
|
|
|
|
|
} // end namespace Kernel
|
|
|
|
|
|
|
|
namespace Key {
|
2018-05-01 17:54:18 +02:00
|
|
|
/// Key for HSA::Metadata::mVersion.
|
2017-03-22 23:32:22 +01:00
|
|
|
constexpr char Version[] = "Version";
|
2018-05-01 17:54:18 +02:00
|
|
|
/// Key for HSA::Metadata::mPrintf.
|
2017-03-22 23:32:22 +01:00
|
|
|
constexpr char Printf[] = "Printf";
|
2018-05-01 17:54:18 +02:00
|
|
|
/// Key for HSA::Metadata::mKernels.
|
2017-03-22 23:32:22 +01:00
|
|
|
constexpr char Kernels[] = "Kernels";
|
|
|
|
} // end namespace Key
|
|
|
|
|
2018-05-01 17:54:18 +02:00
|
|
|
/// In-memory representation of HSA metadata.
|
2017-03-22 23:32:22 +01:00
|
|
|
struct Metadata final {
|
2018-05-01 17:54:18 +02:00
|
|
|
/// HSA metadata version. Required.
|
2017-03-22 23:32:22 +01:00
|
|
|
std::vector<uint32_t> mVersion = std::vector<uint32_t>();
|
2018-05-01 17:54:18 +02:00
|
|
|
/// Printf metadata. Optional.
|
2017-03-22 23:32:22 +01:00
|
|
|
std::vector<std::string> mPrintf = std::vector<std::string>();
|
2018-05-01 17:54:18 +02:00
|
|
|
/// Kernels metadata. Required.
|
2017-03-22 23:32:22 +01:00
|
|
|
std::vector<Kernel::Metadata> mKernels = std::vector<Kernel::Metadata>();
|
|
|
|
|
2018-05-01 17:54:18 +02:00
|
|
|
/// Default constructor.
|
2017-03-22 23:32:22 +01:00
|
|
|
Metadata() = default;
|
2017-10-12 00:59:35 +02:00
|
|
|
};
|
2017-03-22 23:32:22 +01:00
|
|
|
|
2018-05-01 17:54:18 +02:00
|
|
|
/// Converts \p String to \p HSAMetadata.
|
2021-01-26 17:09:27 +01:00
|
|
|
std::error_code fromString(StringRef String, Metadata &HSAMetadata);
|
2017-03-22 23:32:22 +01:00
|
|
|
|
2018-05-01 17:54:18 +02:00
|
|
|
/// Converts \p HSAMetadata to \p String.
|
2017-10-12 00:59:35 +02:00
|
|
|
std::error_code toString(Metadata HSAMetadata, std::string &String);
|
2017-03-22 23:32:22 +01:00
|
|
|
|
2018-12-12 20:39:27 +01:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// HSA metadata for v3 code object.
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
namespace V3 {
|
|
|
|
/// HSA metadata major version.
|
|
|
|
constexpr uint32_t VersionMajor = 1;
|
|
|
|
/// HSA metadata minor version.
|
|
|
|
constexpr uint32_t VersionMinor = 0;
|
|
|
|
|
|
|
|
/// HSA metadata beginning assembler directive.
|
|
|
|
constexpr char AssemblerDirectiveBegin[] = ".amdgpu_metadata";
|
|
|
|
/// HSA metadata ending assembler directive.
|
|
|
|
constexpr char AssemblerDirectiveEnd[] = ".end_amdgpu_metadata";
|
|
|
|
} // end namespace V3
|
|
|
|
|
2017-10-12 00:18:53 +02:00
|
|
|
} // end namespace HSAMD
|
2017-10-12 00:41:09 +02:00
|
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// PAL metadata.
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
namespace PALMD {
|
|
|
|
|
2019-03-20 19:47:21 +01:00
|
|
|
/// PAL metadata (old linear format) assembler directive.
|
2017-10-12 00:41:09 +02:00
|
|
|
constexpr char AssemblerDirective[] = ".amd_amdgpu_pal_metadata";
|
|
|
|
|
2019-03-20 19:47:21 +01:00
|
|
|
/// PAL metadata (new MsgPack format) beginning assembler directive.
|
|
|
|
constexpr char AssemblerDirectiveBegin[] = ".amdgpu_pal_metadata";
|
|
|
|
|
|
|
|
/// PAL metadata (new MsgPack format) ending assembler directive.
|
|
|
|
constexpr char AssemblerDirectiveEnd[] = ".end_amdgpu_pal_metadata";
|
|
|
|
|
2018-05-01 17:54:18 +02:00
|
|
|
/// PAL metadata keys.
|
2017-10-12 00:41:09 +02:00
|
|
|
enum Key : uint32_t {
|
2019-03-20 18:42:00 +01:00
|
|
|
R_2E12_COMPUTE_PGM_RSRC1 = 0x2e12,
|
|
|
|
R_2D4A_SPI_SHADER_PGM_RSRC1_LS = 0x2d4a,
|
|
|
|
R_2D0A_SPI_SHADER_PGM_RSRC1_HS = 0x2d0a,
|
|
|
|
R_2CCA_SPI_SHADER_PGM_RSRC1_ES = 0x2cca,
|
|
|
|
R_2C8A_SPI_SHADER_PGM_RSRC1_GS = 0x2c8a,
|
|
|
|
R_2C4A_SPI_SHADER_PGM_RSRC1_VS = 0x2c4a,
|
|
|
|
R_2C0A_SPI_SHADER_PGM_RSRC1_PS = 0x2c0a,
|
|
|
|
R_2E00_COMPUTE_DISPATCH_INITIATOR = 0x2e00,
|
|
|
|
R_A1B3_SPI_PS_INPUT_ENA = 0xa1b3,
|
|
|
|
R_A1B4_SPI_PS_INPUT_ADDR = 0xa1b4,
|
|
|
|
R_A1B6_SPI_PS_IN_CONTROL = 0xa1b6,
|
|
|
|
R_A2D5_VGT_SHADER_STAGES_EN = 0xa2d5,
|
|
|
|
|
2017-11-15 00:05:36 +01:00
|
|
|
LS_NUM_USED_VGPRS = 0x10000021,
|
|
|
|
HS_NUM_USED_VGPRS = 0x10000022,
|
|
|
|
ES_NUM_USED_VGPRS = 0x10000023,
|
|
|
|
GS_NUM_USED_VGPRS = 0x10000024,
|
|
|
|
VS_NUM_USED_VGPRS = 0x10000025,
|
|
|
|
PS_NUM_USED_VGPRS = 0x10000026,
|
|
|
|
CS_NUM_USED_VGPRS = 0x10000027,
|
|
|
|
|
|
|
|
LS_NUM_USED_SGPRS = 0x10000028,
|
|
|
|
HS_NUM_USED_SGPRS = 0x10000029,
|
|
|
|
ES_NUM_USED_SGPRS = 0x1000002a,
|
|
|
|
GS_NUM_USED_SGPRS = 0x1000002b,
|
|
|
|
VS_NUM_USED_SGPRS = 0x1000002c,
|
|
|
|
PS_NUM_USED_SGPRS = 0x1000002d,
|
|
|
|
CS_NUM_USED_SGPRS = 0x1000002e,
|
|
|
|
|
|
|
|
LS_SCRATCH_SIZE = 0x10000044,
|
|
|
|
HS_SCRATCH_SIZE = 0x10000045,
|
|
|
|
ES_SCRATCH_SIZE = 0x10000046,
|
|
|
|
GS_SCRATCH_SIZE = 0x10000047,
|
|
|
|
VS_SCRATCH_SIZE = 0x10000048,
|
|
|
|
PS_SCRATCH_SIZE = 0x10000049,
|
|
|
|
CS_SCRATCH_SIZE = 0x1000004a
|
2017-10-12 00:41:09 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
} // end namespace PALMD
|
2017-03-22 23:32:22 +01:00
|
|
|
} // end namespace AMDGPU
|
|
|
|
} // end namespace llvm
|
|
|
|
|
2017-10-12 00:18:53 +02:00
|
|
|
#endif // LLVM_SUPPORT_AMDGPUMETADATA_H
|