SWDEV-470698 - fix formatting, add format check workflow (#657)

This commit is contained in:
Danylo Lytovchenko
2025-08-20 16:28:06 +02:00
committed by GitHub
parent 5840940caa
commit f7338717ae
1574 changed files with 162972 additions and 199346 deletions
+31 -39
View File
@@ -28,9 +28,7 @@
namespace amd::roc {
#if defined(USE_COMGR_LIBRARY)
bool Kernel::init() {
return GetAttrCodePropMetadata();
}
bool Kernel::init() { return GetAttrCodePropMetadata(); }
bool Kernel::postLoad() {
// Set the kernel symbol name and size/alignment based on the kernel metadata
@@ -39,9 +37,8 @@ bool Kernel::postLoad() {
if (codeObjectVer() == 2) {
symbolName_ = name();
}
kernargSegmentAlignment_ =
amd::alignUp(std::max(kernargSegmentAlignment_, 128u),
device().info().globalMemCacheLineSize_);
kernargSegmentAlignment_ = amd::alignUp(std::max(kernargSegmentAlignment_, 128u),
device().info().globalMemCacheLineSize_);
// Set the workgroup information for the kernel
workGroupInfo_.availableLDSSize_ = device().info().localMemSizePerCU_;
@@ -51,12 +48,11 @@ bool Kernel::postLoad() {
hsa_status_t hsaStatus;
hsa_executable_symbol_t symbol;
hsa_agent_t agent = program()->rocDevice().getBackendDevice();
hsaStatus = hsa_executable_get_symbol_by_name(program()->hsaExecutable(),
symbolName().c_str(),
hsaStatus = hsa_executable_get_symbol_by_name(program()->hsaExecutable(), symbolName().c_str(),
&agent, &symbol);
if (hsaStatus != HSA_STATUS_SUCCESS) {
DevLogPrintfError("Cannot Get Symbol : %s, failed with hsa_status: %d \n",
symbolName().c_str(), hsaStatus);
DevLogPrintfError("Cannot Get Symbol : %s, failed with hsa_status: %d \n", symbolName().c_str(),
hsaStatus);
return false;
}
@@ -68,44 +64,42 @@ bool Kernel::postLoad() {
return false;
}
hsaStatus = hsa_executable_symbol_get_info(symbol, HSA_EXECUTABLE_SYMBOL_INFO_KERNEL_DYNAMIC_CALLSTACK,
&kernelHasDynamicCallStack_);
hsaStatus = hsa_executable_symbol_get_info(
symbol, HSA_EXECUTABLE_SYMBOL_INFO_KERNEL_DYNAMIC_CALLSTACK, &kernelHasDynamicCallStack_);
if (hsaStatus != HSA_STATUS_SUCCESS) {
DevLogPrintfError(" Cannot Get Dynamic callstack info, failed with hsa_status: %d \n ", hsaStatus);
DevLogPrintfError(" Cannot Get Dynamic callstack info, failed with hsa_status: %d \n ",
hsaStatus);
return false;
}
if (!RuntimeHandle().empty()) {
hsa_executable_symbol_t kernelSymbol;
int variable_size;
uint64_t variable_address;
int variable_size;
uint64_t variable_address;
// Only kernels that could be enqueued by another kernel has the RuntimeHandle metadata. The RuntimeHandle
// metadata is a string that represents a variable from which the library code can retrieve the kernel code
// object handle of such a kernel. The address of the variable and the kernel code object handle are known
// only after the hsa executable is loaded. The below code copies the kernel code object handle to the
// address of the variable.
// Only kernels that could be enqueued by another kernel has the RuntimeHandle metadata. The
// RuntimeHandle metadata is a string that represents a variable from which the library code can
// retrieve the kernel code object handle of such a kernel. The address of the variable and the
// kernel code object handle are known only after the hsa executable is loaded. The below code
// copies the kernel code object handle to the address of the variable.
hsaStatus = hsa_executable_get_symbol_by_name(program()->hsaExecutable(),
RuntimeHandle().c_str(),
&agent, &kernelSymbol);
RuntimeHandle().c_str(), &agent, &kernelSymbol);
if (hsaStatus != HSA_STATUS_SUCCESS) {
DevLogPrintfError("Cannot get Kernel Symbol by name: %s, failed with hsa_status: %d \n",
RuntimeHandle().c_str(), hsaStatus);
return false;
}
hsaStatus = hsa_executable_symbol_get_info(kernelSymbol,
HSA_EXECUTABLE_SYMBOL_INFO_VARIABLE_SIZE,
&variable_size);
hsaStatus = hsa_executable_symbol_get_info(
kernelSymbol, HSA_EXECUTABLE_SYMBOL_INFO_VARIABLE_SIZE, &variable_size);
if (hsaStatus != HSA_STATUS_SUCCESS) {
DevLogPrintfError("[ROC][Kernel] Cannot get Kernel Symbol Info, failed with hsa_status: %d \n",
hsaStatus);
DevLogPrintfError(
"[ROC][Kernel] Cannot get Kernel Symbol Info, failed with hsa_status: %d \n", hsaStatus);
return false;
}
hsaStatus = hsa_executable_symbol_get_info(kernelSymbol,
HSA_EXECUTABLE_SYMBOL_INFO_VARIABLE_ADDRESS,
&variable_address);
hsaStatus = hsa_executable_symbol_get_info(
kernelSymbol, HSA_EXECUTABLE_SYMBOL_INFO_VARIABLE_ADDRESS, &variable_address);
if (hsaStatus != HSA_STATUS_SUCCESS) {
DevLogPrintfError("[ROC][Kernel] Cannot get Kernel Address, failed with hsa_status: %d \n",
hsaStatus);
@@ -113,12 +107,9 @@ bool Kernel::postLoad() {
}
const struct RuntimeHandle runtime_handle = {
kernelCodeHandle_,
WorkitemPrivateSegmentByteSize(),
WorkgroupGroupSegmentByteSize()
};
hsaStatus = hsa_memory_copy(reinterpret_cast<void*>(variable_address),
&runtime_handle, variable_size);
kernelCodeHandle_, WorkitemPrivateSegmentByteSize(), WorkgroupGroupSegmentByteSize()};
hsaStatus =
hsa_memory_copy(reinterpret_cast<void*>(variable_address), &runtime_handle, variable_size);
if (hsaStatus != HSA_STATUS_SUCCESS) {
DevLogPrintfError("[ROC][Kernel] HSA Memory copy failed, failed with hsa_status: %d \n",
@@ -147,10 +138,11 @@ bool Kernel::postLoad() {
workGroupInfo_.usedLDSSize_ = workgroupGroupSegmentByteSize_;
workGroupInfo_.preferredSizeMultiple_ = wavefront_size;
workGroupInfo_.usedStackSize_ = kernelHasDynamicCallStack_;
workGroupInfo_.wavefrontPerSIMD_ = program()->rocDevice().info().maxWorkItemSizes_[0] / wavefront_size;
workGroupInfo_.wavefrontPerSIMD_ =
program()->rocDevice().info().maxWorkItemSizes_[0] / wavefront_size;
workGroupInfo_.constMemSize_ = 0;
workGroupInfo_.maxDynamicSharedSizeBytes_ = static_cast<int>(workGroupInfo_.availableLDSSize_ -
workGroupInfo_.localMemSize_);
workGroupInfo_.maxDynamicSharedSizeBytes_ =
static_cast<int>(workGroupInfo_.availableLDSSize_ - workGroupInfo_.localMemSize_);
if (workGroupInfo_.size_ == 0) {
return false;
}