diff --git a/projects/clr/rocclr/runtime/device/devkernel.hpp b/projects/clr/rocclr/runtime/device/devkernel.hpp index d3ec08dcae..9f7a57436b 100644 --- a/projects/clr/rocclr/runtime/device/devkernel.hpp +++ b/projects/clr/rocclr/runtime/device/devkernel.hpp @@ -17,6 +17,14 @@ namespace llvm { struct Metadata; }}}} typedef llvm::AMDGPU::HSAMD::Kernel::Metadata KernelMD; + +//! Runtime handle structure for device enqueue +struct RuntimeHandle { + uint64_t kernel_handle; //!< Pointer to amd_kernel_code_s or kernel_descriptor_t + uint32_t private_segment_size; //!< From PRIVATE_SEGMENT_FIXED_SIZE + uint32_t group_segment_size; //!< From GROUP_SEGMENT_FIXED_SIZE +}; + #endif // defined(WITH_LIGHTNING_COMPILER) namespace amd { @@ -262,4 +270,4 @@ class Kernel : public amd::HeapObject { std::unordered_map patchReferences_; //!< Patch table for references }; -} // namespace device \ No newline at end of file +} // namespace device diff --git a/projects/clr/rocclr/runtime/device/pal/palkernel.cpp b/projects/clr/rocclr/runtime/device/pal/palkernel.cpp index 3ee42beaf3..a679a9191e 100644 --- a/projects/clr/rocclr/runtime/device/pal/palkernel.cpp +++ b/projects/clr/rocclr/runtime/device/pal/palkernel.cpp @@ -439,10 +439,15 @@ bool LightningKernel::init(amd::hsa::loader::Symbol* symbol) { // Copy the kernel_object pointer to the runtime handle symbol GPU address const Memory& codeSegGpu = prog_.codeSegGpu(); uint64_t offset = symbol_address - codeSegGpu.vmAddress(); - uint64_t kernel_object = gpuAqlCode(); VirtualGPU* gpu = codeSegGpu.dev().xferQueue(); - codeSegGpu.writeRawData(*gpu, offset, 8, &kernel_object, true); + const struct RuntimeHandle runtime_handle = { + gpuAqlCode(), + spillSegSize(), + ldsSize() + }; + + codeSegGpu.writeRawData(*gpu, offset, sizeof(runtime_handle), &runtime_handle, true); } // Copy wavefront size diff --git a/projects/clr/rocclr/runtime/device/pal/palkernel.hpp b/projects/clr/rocclr/runtime/device/pal/palkernel.hpp index 77f6106c8b..e5041f3f92 100644 --- a/projects/clr/rocclr/runtime/device/pal/palkernel.hpp +++ b/projects/clr/rocclr/runtime/device/pal/palkernel.hpp @@ -74,7 +74,7 @@ class HSAILKernel : public device::Kernel { size_t argsBufferSize() const { return akc_.kernarg_segment_byte_size; } //! Returns spill reg size per workitem - int spillSegSize() const { return amd::alignUp(akc_.workitem_private_segment_byte_size, sizeof(uint32_t)); } + uint32_t spillSegSize() const { return amd::alignUp(akc_.workitem_private_segment_byte_size, sizeof(uint32_t)); } //! Returns AQL packet in CPU memory //! if the kernel arguments were successfully loaded, otherwise NULL diff --git a/projects/clr/rocclr/runtime/device/rocm/rockernel.cpp b/projects/clr/rocclr/runtime/device/rocm/rockernel.cpp index 93fba7bc5b..04f2c18f02 100644 --- a/projects/clr/rocclr/runtime/device/rocm/rockernel.cpp +++ b/projects/clr/rocclr/runtime/device/rocm/rockernel.cpp @@ -109,7 +109,13 @@ bool LightningKernel::init() { return false; } - status = hsa_memory_copy(reinterpret_cast(variable_address), &kernelCodeHandle_, variable_size); + const struct RuntimeHandle runtime_handle = { + kernelCodeHandle_, + workitemPrivateSegmentByteSize(), + WorkgroupGroupSegmentByteSize() + }; + + status = hsa_memory_copy(reinterpret_cast(variable_address), &runtime_handle, variable_size); if (status != HSA_STATUS_SUCCESS) { return false; }