From f6d8feabebbdf225380562270a6de51fe23616fe Mon Sep 17 00:00:00 2001
From: foreman
Date: Thu, 14 Jun 2018 17:51:35 -0400
Subject: [PATCH] P4 to Git Change 1568521 by gandryey@gera-w8 on 2018/06/14
17:43:52
SWDEV-79445 - OCL generic changes and code clean-up
- Change LDS setup to account the size, since LC forces 4 bytes for LDS offsets always
http://ocltc.amd.com/reviews/r/15197/
Affected files ...
... //depot/stg/opencl/drivers/opencl/api/opencl/amdocl/cl_execute.cpp#28 edit
... //depot/stg/opencl/drivers/opencl/api/opencl/amdocl/cl_program.cpp#49 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/gpu/gpublit.cpp#130 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/gpu/gpukernel.cpp#327 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/pal/palblit.cpp#25 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/pal/palkernel.cpp#56 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/pal/palvirtual.cpp#109 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rocblit.hpp#11 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rockernel.cpp#38 edit
... //depot/stg/opencl/drivers/opencl/runtime/platform/command.cpp#88 edit
... //depot/stg/opencl/drivers/opencl/runtime/platform/kernel.cpp#34 edit
... //depot/stg/opencl/drivers/opencl/runtime/platform/kernel.hpp#25 edit
---
rocclr/runtime/device/gpu/gpublit.cpp | 29 +++++-----
rocclr/runtime/device/gpu/gpukernel.cpp | 17 +++---
rocclr/runtime/device/pal/palblit.cpp | 30 +++++------
rocclr/runtime/device/pal/palkernel.cpp | 26 ++-------
rocclr/runtime/device/pal/palvirtual.cpp | 24 ++++++---
rocclr/runtime/device/rocm/rocblit.hpp | 32 +++++------
rocclr/runtime/device/rocm/rockernel.cpp | 26 ++-------
rocclr/runtime/platform/command.cpp | 3 +-
rocclr/runtime/platform/kernel.cpp | 69 +++++++++++++++---------
rocclr/runtime/platform/kernel.hpp | 2 +-
10 files changed, 127 insertions(+), 131 deletions(-)
diff --git a/rocclr/runtime/device/gpu/gpublit.cpp b/rocclr/runtime/device/gpu/gpublit.cpp
index 1584f3b5d5..d31a3a0255 100644
--- a/rocclr/runtime/device/gpu/gpublit.cpp
+++ b/rocclr/runtime/device/gpu/gpublit.cpp
@@ -955,13 +955,14 @@ static void setArgument(amd::Kernel* kernel, size_t index, size_t size, const vo
const amd::KernelParameterDescriptor& desc = kernel->signature().at(index);
void* param = kernel->parameters().values() + desc.offset_;
- assert((desc.type_ == T_POINTER || value != NULL || desc.size_ == 0) &&
- "not a valid local mem arg");
+ assert((desc.type_ == T_POINTER || value != NULL ||
+ (desc.addressQualifier_ == CL_KERNEL_ARG_ADDRESS_LOCAL)) &&
+ "not a valid local mem arg");
uint32_t uint32_value = 0;
uint64_t uint64_value = 0;
- if (desc.type_ == T_POINTER && desc.size_ != 0) {
+ if (desc.type_ == T_POINTER && (desc.addressQualifier_ != CL_KERNEL_ARG_ADDRESS_LOCAL)) {
if ((value == NULL) || (static_cast(value) == NULL)) {
LP64_SWITCH(uint32_value, uint64_value) = 0;
reinterpret_cast(kernel->parameters().values() +
@@ -978,26 +979,24 @@ static void setArgument(amd::Kernel* kernel, size_t index, size_t size, const vo
assert(false && "No sampler support in blit manager! Use internal samplers!");
} else
switch (desc.size_) {
- case 1:
- uint32_value = *static_cast(value);
- break;
- case 2:
- uint32_value = *static_cast(value);
- break;
case 4:
- uint32_value = *static_cast(value);
+ if (desc.addressQualifier_ == CL_KERNEL_ARG_ADDRESS_LOCAL) {
+ uint32_value = size;
+ } else {
+ uint32_value = *static_cast(value);
+ }
break;
case 8:
- uint64_value = *static_cast(value);
+ if (desc.addressQualifier_ == CL_KERNEL_ARG_ADDRESS_LOCAL) {
+ uint64_value = size;
+ } else {
+ uint64_value = *static_cast(value);
+ }
break;
default:
break;
}
-
switch (desc.size_) {
- case 0 /*local mem*/:
- *static_cast(param) = size;
- break;
case sizeof(uint32_t):
*static_cast(param) = uint32_value;
break;
diff --git a/rocclr/runtime/device/gpu/gpukernel.cpp b/rocclr/runtime/device/gpu/gpukernel.cpp
index f1fbae14e1..d0a2377b61 100644
--- a/rocclr/runtime/device/gpu/gpukernel.cpp
+++ b/rocclr/runtime/device/gpu/gpukernel.cpp
@@ -378,7 +378,7 @@ size_t KernelArg::size(bool gpuLayer) const {
return (gpuLayer) ? 0 : sizeof(cl_mem);
case PointerLocal:
case PointerHwLocal:
- return (gpuLayer) ? sizeof(uint32_t) * size_ : 0;
+ return (gpuLayer) ? sizeof(uint32_t) * size_ : sizeof(cl_mem);
case PointerPrivate:
case PointerHwPrivate:
return (gpuLayer) ? sizeof(uint32_t) * size_ : 0;
@@ -2991,7 +2991,7 @@ void HSAILKernel::initArgList(const aclArgData* aclArg) {
// Make a check if it is local or global
if (desc.addressQualifier_ == CL_KERNEL_ARG_ADDRESS_LOCAL) {
- desc.size_ = 0;
+ desc.size_ = sizeof(cl_mem);
} else {
desc.size_ = GetOclSize(aclArg);
}
@@ -3000,10 +3000,7 @@ void HSAILKernel::initArgList(const aclArgData* aclArg) {
// in multidevice config abstraction layer has a single signature
// and CPU sends the paramaters as they are allocated in memory
size_t size = desc.size_;
- if (size == 0) {
- // Local memory for CPU
- size = sizeof(cl_mem);
- }
+
offset = amd::alignUp(offset, std::min(size, size_t(16)));
desc.offset_ = offset;
offset += amd::alignUp(size, sizeof(uint32_t));
@@ -3527,8 +3524,12 @@ hsa_kernel_dispatch_packet_t* HSAILKernel::loadArguments(
else {
assert((arg->addrQual_ == HSAIL_ADDRESS_LOCAL) && "Unsupported address type");
ldsAddress = amd::alignUp(ldsAddress, arg->alignment_);
- WriteAqlArg(&aqlArgBuf, &ldsAddress, sizeof(size_t));
- ldsAddress += *reinterpret_cast(paramaddr);
+ WriteAqlArg(&aqlArgBuf, &ldsAddress, desc.size_);
+ if (desc.size_ == 8) {
+ ldsAddress += *reinterpret_cast(paramaddr);
+ } else {
+ ldsAddress += *reinterpret_cast(paramaddr);
+ }
}
break;
case HSAIL_ARGTYPE_VALUE:
diff --git a/rocclr/runtime/device/pal/palblit.cpp b/rocclr/runtime/device/pal/palblit.cpp
index f64af9d2cf..cf691c8598 100644
--- a/rocclr/runtime/device/pal/palblit.cpp
+++ b/rocclr/runtime/device/pal/palblit.cpp
@@ -938,14 +938,15 @@ static void setArgument(amd::Kernel* kernel, size_t index, size_t size, const vo
const amd::KernelParameterDescriptor& desc = kernel->signature().at(index);
void* param = kernel->parameters().values() + desc.offset_;
- assert((desc.type_ == T_POINTER || value != NULL || desc.size_ == 0) &&
- "not a valid local mem arg");
+ assert((desc.type_ == T_POINTER || value != NULL ||
+ (desc.addressQualifier_ == CL_KERNEL_ARG_ADDRESS_LOCAL)) &&
+ "not a valid local mem arg");
uint32_t uint32_value = 0;
uint64_t uint64_value = 0;
size_t argSize = desc.size_;
- if (desc.type_ == T_POINTER && desc.size_ != 0) {
+ if (desc.type_ == T_POINTER && (desc.addressQualifier_ != CL_KERNEL_ARG_ADDRESS_LOCAL)) {
if ((value == NULL) || (static_cast(value) == NULL)) {
reinterpret_cast(kernel->parameters().values() +
kernel->parameters().memoryObjOffset())[desc.info_.arrayIndex_] = nullptr;
@@ -966,27 +967,26 @@ static void setArgument(amd::Kernel* kernel, size_t index, size_t size, const vo
} else if (desc.type_ == T_SAMPLER) {
assert(false && "No sampler support in blit manager! Use internal samplers!");
} else
- switch (argSize) {
- case 1:
- uint32_value = *static_cast(value);
- break;
- case 2:
- uint32_value = *static_cast(value);
- break;
+ switch (desc.size_) {
case 4:
- uint32_value = *static_cast(value);
+ if (desc.addressQualifier_ == CL_KERNEL_ARG_ADDRESS_LOCAL) {
+ uint32_value = size;
+ } else {
+ uint32_value = *static_cast(value);
+ }
break;
case 8:
- uint64_value = *static_cast(value);
+ if (desc.addressQualifier_ == CL_KERNEL_ARG_ADDRESS_LOCAL) {
+ uint64_value = size;
+ } else {
+ uint64_value = *static_cast(value);
+ }
break;
default:
break;
}
switch (argSize) {
- case 0 /*local mem*/:
- *static_cast(param) = size;
- break;
case sizeof(uint32_t):
*static_cast(param) = uint32_value;
break;
diff --git a/rocclr/runtime/device/pal/palkernel.cpp b/rocclr/runtime/device/pal/palkernel.cpp
index a52bceda98..6abfd86ba6 100644
--- a/rocclr/runtime/device/pal/palkernel.cpp
+++ b/rocclr/runtime/device/pal/palkernel.cpp
@@ -478,22 +478,13 @@ void HSAILKernel::initArgList(const aclArgData* aclArg) {
desc.typeName_ = arguments_[i]->typeName_.c_str();
desc.info_.oclObject_ = GetOclArgumentType(arguments_[i]);
desc.info_.arrayIndex_ = arguments_[i]->pointeeAlignment_;
-
- // Make a check if it is local or global
- if (desc.addressQualifier_ == CL_KERNEL_ARG_ADDRESS_LOCAL) {
- desc.size_ = 0;
- } else {
- desc.size_ = arguments_[i]->size_;
- }
+ desc.size_ = arguments_[i]->size_;
// Make offset alignment to match CPU metadata, since
// in multidevice config abstraction layer has a single signature
// and CPU sends the paramaters as they are allocated in memory
size_t size = desc.size_;
- if (size == 0) {
- // Local memory for CPU
- size = sizeof(cl_mem);
- }
+
// Check if HSAIL expects data by reference and allocate it behind
if (arguments_[i]->type_ == HSAIL_ARGTYPE_REFERENCE) {
desc.offset_ = offsetStruct;
@@ -1348,22 +1339,13 @@ void LightningKernel::initArgList(const KernelMD& kernelMD) {
desc.typeName_ = lcArg.mTypeName.c_str();
desc.info_.oclObject_ = GetOclArgumentType(arg);
desc.info_.arrayIndex_ = arg->pointeeAlignment_;
-
- // Make a check if it is local or global
- if (desc.addressQualifier_ == CL_KERNEL_ARG_ADDRESS_LOCAL) {
- desc.size_ = 0;
- } else {
- desc.size_ = arg->size_;
- }
+ desc.size_ = arg->size_;
// Make offset alignment to match CPU metadata, since
// in multidevice config abstraction layer has a single signature
// and CPU sends the parameters as they are allocated in memory
size_t size = desc.size_;
- if (size == 0) {
- // Local memory for CPU
- size = sizeof(cl_mem);
- }
+
// Check if HSAIL expects data by reference and allocate it behind
if (arguments_[i]->type_ == HSAIL_ARGTYPE_REFERENCE) {
desc.offset_ = offsetStruct;
diff --git a/rocclr/runtime/device/pal/palvirtual.cpp b/rocclr/runtime/device/pal/palvirtual.cpp
index d441dc981b..59b4ff3953 100644
--- a/rocclr/runtime/device/pal/palvirtual.cpp
+++ b/rocclr/runtime/device/pal/palvirtual.cpp
@@ -3041,14 +3041,24 @@ bool VirtualGPU::processMemObjectsHSA(const amd::Kernel& kernel, const_address p
// Find if current argument is a buffer
if (desc.type_ == T_POINTER) {
// If it is a local pointer
- if (desc.size_ == 0) {
+ if (desc.addressQualifier_ == CL_KERNEL_ARG_ADDRESS_LOCAL) {
ldsAddress = amd::alignUp(ldsAddress, desc.info_.arrayIndex_);
- // Save the original LDS size
- size_t ldsSize = *reinterpret_cast(params + desc.offset_);
- // Patch the LDS address in the original arguments with an LDS address(offset)
- WriteAqlArgAt(const_cast(params), &ldsAddress, sizeof(void*), desc.offset_);
- // Add the original size
- ldsAddress += ldsSize;
+ if (desc.size_ == 8) {
+ // Save the original LDS size
+ uint64_t ldsSize = *reinterpret_cast(params + desc.offset_);
+ // Patch the LDS address in the original arguments with an LDS address(offset)
+ WriteAqlArgAt(const_cast(params), &ldsAddress, desc.size_, desc.offset_);
+ // Add the original size
+ ldsAddress += ldsSize;
+ } else {
+ // Save the original LDS size
+ uint32_t ldsSize = *reinterpret_cast(params + desc.offset_);
+ // Patch the LDS address in the original arguments with an LDS address(offset)
+ uint32_t ldsAddr = ldsAddress;
+ WriteAqlArgAt(const_cast(params), &ldsAddr, desc.size_, desc.offset_);
+ // Add the original size
+ ldsAddress += ldsSize;
+ }
} else {
Memory* gpuMem = nullptr;
amd::Memory* mem = nullptr;
diff --git a/rocclr/runtime/device/rocm/rocblit.hpp b/rocclr/runtime/device/rocm/rocblit.hpp
index fbb1442637..0b556ea864 100644
--- a/rocclr/runtime/device/rocm/rocblit.hpp
+++ b/rocclr/runtime/device/rocm/rocblit.hpp
@@ -441,13 +441,14 @@ inline void KernelBlitManager::setArgument(amd::Kernel* kernel, size_t index, si
const amd::KernelParameterDescriptor& desc = kernel->signature().at(index);
void* param = kernel->parameters().values() + desc.offset_;
- assert((desc.type_ == T_POINTER || value != NULL || desc.size_ == 0) &&
- "not a valid local mem arg");
+ assert((desc.type_ == T_POINTER || value != NULL ||
+ (desc.addressQualifier_ == CL_KERNEL_ARG_ADDRESS_LOCAL)) &&
+ "not a valid local mem arg");
uint32_t uint32_value = 0;
uint64_t uint64_value = 0;
- if (desc.type_ == T_POINTER && desc.size_ != 0) {
+ if (desc.type_ == T_POINTER && (desc.addressQualifier_ != CL_KERNEL_ARG_ADDRESS_LOCAL)) {
if ((value == NULL) || (static_cast(value) == NULL)) {
LP64_SWITCH(uint32_value, uint64_value) = 0;
reinterpret_cast(kernel->parameters().values() +
@@ -461,28 +462,27 @@ inline void KernelBlitManager::setArgument(amd::Kernel* kernel, size_t index, si
}
} else if (desc.type_ == T_SAMPLER) {
assert(false && "No sampler support in blit manager! Use internal samplers!");
- } else
+ } else {
switch (desc.size_) {
- case 1:
- uint32_value = *static_cast(value);
- break;
- case 2:
- uint32_value = *static_cast(value);
- break;
case 4:
- uint32_value = *static_cast(value);
+ if (desc.addressQualifier_ == CL_KERNEL_ARG_ADDRESS_LOCAL) {
+ uint32_value = size;
+ } else {
+ uint32_value = *static_cast(value);
+ }
break;
case 8:
- uint64_value = *static_cast(value);
+ if (desc.addressQualifier_ == CL_KERNEL_ARG_ADDRESS_LOCAL) {
+ uint64_value = size;
+ } else {
+ uint64_value = *static_cast(value);
+ }
break;
default:
break;
}
-
+ }
switch (desc.size_) {
- case 0 /*local mem*/:
- *static_cast(param) = size;
- break;
case sizeof(uint32_t):
*static_cast(param) = uint32_value;
break;
diff --git a/rocclr/runtime/device/rocm/rockernel.cpp b/rocclr/runtime/device/rocm/rockernel.cpp
index 7cf8fb9534..68e6d96944 100644
--- a/rocclr/runtime/device/rocm/rockernel.cpp
+++ b/rocclr/runtime/device/rocm/rockernel.cpp
@@ -559,22 +559,13 @@ void HSAILKernel::initArguments(const aclArgData* aclArg) {
flags_.imageWrite_ = true;
}
}
-
- // Make a check if it is local or global
- if (desc.addressQualifier_ == CL_KERNEL_ARG_ADDRESS_LOCAL) {
- desc.size_ = 0;
- } else {
- desc.size_ = arg->size_;
- }
+ desc.size_ = arg->size_;
// Make offset alignment to match CPU metadata, since
// in multidevice config abstraction layer has a single signature
// and CPU sends the parameters as they are allocated in memory
size_t size = desc.size_;
- if (size == 0) {
- // Local memory for CPU
- size = sizeof(cl_mem);
- }
+
offset = amd::alignUp(offset, std::min(size, size_t(16)));
desc.offset_ = offset;
offset += amd::alignUp(size, sizeof(uint32_t));
@@ -638,22 +629,13 @@ void LightningKernel::initArguments(const KernelMD& kernelMD) {
flags_.imageWrite_ = true;
}
}
-
- // Make a check if it is local or global
- if (desc.addressQualifier_ == CL_KERNEL_ARG_ADDRESS_LOCAL) {
- desc.size_ = 0;
- } else {
- desc.size_ = arg->size_;
- }
+ desc.size_ = arg->size_;
// Make offset alignment to match CPU metadata, since
// in multidevice config abstraction layer has a single signature
// and CPU sends the parameters as they are allocated in memory
size_t size = desc.size_;
- if (size == 0) {
- // Local memory for CPU
- size = sizeof(cl_mem);
- }
+
offset = (size_t)amd::alignUp(offset, std::min(size, size_t(16)));
desc.offset_ = offset;
offset += amd::alignUp(size, sizeof(uint32_t));
diff --git a/rocclr/runtime/platform/command.cpp b/rocclr/runtime/platform/command.cpp
index 7e5a620ac2..0ebdad31ba 100644
--- a/rocclr/runtime/platform/command.cpp
+++ b/rocclr/runtime/platform/command.cpp
@@ -395,7 +395,8 @@ cl_int NDRangeKernelCommand::captureAndValidate() {
}
cl_int error;
- parameters_ = kernel().parameters().capture(device, &error);
+ cl_ulong lclMemSize = kernel().getDeviceKernel(device)->workGroupInfo()->localMemSize_;
+ parameters_ = kernel().parameters().capture(device, lclMemSize, &error);
return error;
}
diff --git a/rocclr/runtime/platform/kernel.cpp b/rocclr/runtime/platform/kernel.cpp
index 845266efc6..1de190a514 100644
--- a/rocclr/runtime/platform/kernel.cpp
+++ b/rocclr/runtime/platform/kernel.cpp
@@ -55,9 +55,14 @@ size_t KernelParameters::localMemSize(size_t minDataTypeAlignment) const {
for (size_t i = 0; i < signature_.numParameters(); ++i) {
const KernelParameterDescriptor& desc = signature_.at(i);
- if (desc.size_ == 0) {
- memSize = alignUp(memSize, minDataTypeAlignment) +
- *reinterpret_cast(values_ + desc.offset_);
+ if (desc.addressQualifier_ == CL_KERNEL_ARG_ADDRESS_LOCAL) {
+ if (desc.size_ == 8) {
+ memSize = alignUp(memSize, minDataTypeAlignment) +
+ *reinterpret_cast(values_ + desc.offset_);
+ } else {
+ memSize = alignUp(memSize, minDataTypeAlignment) +
+ *reinterpret_cast(values_ + desc.offset_);
+ }
}
}
return memSize;
@@ -67,13 +72,14 @@ void KernelParameters::set(size_t index, size_t size, const void* value, bool sv
KernelParameterDescriptor& desc = signature_.params()[index];
void* param = values_ + desc.offset_;
- assert((desc.type_ == T_POINTER || value != NULL || desc.size_ == 0) &&
- "not a valid local mem arg");
+ assert((desc.type_ == T_POINTER || value != NULL ||
+ (desc.addressQualifier_ == CL_KERNEL_ARG_ADDRESS_LOCAL)) &&
+ "not a valid local mem arg");
uint32_t uint32_value = 0;
uint64_t uint64_value = 0;
- if (desc.type_ == T_POINTER && desc.size_ != 0) {
+ if (desc.type_ == T_POINTER && (desc.addressQualifier_ != CL_KERNEL_ARG_ADDRESS_LOCAL)) {
if (svmBound) {
desc.info_.rawPointer_ = true;
LP64_SWITCH(uint32_value, uint64_value) = *(LP64_SWITCH(uint32_t*, uint64_t*))value;
@@ -81,7 +87,6 @@ void KernelParameters::set(size_t index, size_t size, const void* value, bool sv
*reinterpret_cast(value));
} else if ((value == NULL) || (static_cast(value) == NULL)) {
desc.info_.rawPointer_ = false;
- LP64_SWITCH(uint32_value, uint64_value) = 0;
memoryObjects_[desc.info_.arrayIndex_] = nullptr;
} else {
desc.info_.rawPointer_ = false;
@@ -96,28 +101,28 @@ void KernelParameters::set(size_t index, size_t size, const void* value, bool sv
// convert cl_command_queue to amd::DeviceQueue*
queueObjects_[desc.info_.arrayIndex_] =
as_amd(*static_cast(value))->asDeviceQueue();
- } else
+ } else {
switch (desc.size_) {
- case 1:
- uint32_value = *static_cast(value);
- break;
- case 2:
- uint32_value = *static_cast(value);
- break;
case 4:
- uint32_value = *static_cast(value);
+ if (desc.addressQualifier_ == CL_KERNEL_ARG_ADDRESS_LOCAL) {
+ uint32_value = size;
+ } else {
+ uint32_value = *static_cast(value);
+ }
break;
case 8:
- uint64_value = *static_cast(value);
+ if (desc.addressQualifier_ == CL_KERNEL_ARG_ADDRESS_LOCAL) {
+ uint64_value = size;
+ } else {
+ uint64_value = *static_cast(value);
+ }
break;
default:
break;
}
+ }
switch (desc.size_) {
- case 0 /*local mem*/:
- *static_cast(param) = size;
- break;
case sizeof(uint32_t):
*static_cast(param) = uint32_value;
break;
@@ -132,7 +137,7 @@ void KernelParameters::set(size_t index, size_t size, const void* value, bool sv
desc.info_.defined_ = true;
}
-address KernelParameters::capture(const Device& device, cl_int* error) {
+address KernelParameters::capture(const Device& device, cl_ulong lclMemSize, cl_int* error) {
*error = CL_SUCCESS;
//! Information about which arguments are SVM pointers is stored after
// the actual parameters, but only if the device has any SVM capability
@@ -146,7 +151,7 @@ address KernelParameters::capture(const Device& device, cl_int* error) {
for (size_t i = 0; i < signature_.numParameters(); ++i) {
const KernelParameterDescriptor& desc = signature_.at(i);
- if (desc.type_ == T_POINTER && desc.size_ != 0) {
+ if (desc.type_ == T_POINTER && (desc.addressQualifier_ != CL_KERNEL_ARG_ADDRESS_LOCAL)) {
Memory* memArg = memoryObjects_[desc.info_.arrayIndex_];
if (memArg != nullptr) {
memArg->retain();
@@ -154,8 +159,7 @@ address KernelParameters::capture(const Device& device, cl_int* error) {
if (nullptr == devMem) {
LogPrintfError("Can't allocate memory size - 0x%08X bytes!", memArg->getSize());
*error = CL_MEM_OBJECT_ALLOCATION_FAILURE;
- AlignedMemory::deallocate(mem);
- return nullptr;
+ break;
}
// Write GPU VA addreess to the arguments
if (!desc.info_.rawPointer_) {
@@ -181,6 +185,14 @@ address KernelParameters::capture(const Device& device, cl_int* error) {
// todo: It's uint64_t type
*reinterpret_cast(mem + desc.offset_) = 0;
}
+ } else if (desc.addressQualifier_ == CL_KERNEL_ARG_ADDRESS_LOCAL) {
+ if (desc.size_ == 8) {
+ lclMemSize = alignUp(lclMemSize, device.info().minDataTypeAlignSize_) +
+ *reinterpret_cast(values_ + desc.offset_);
+ } else {
+ lclMemSize = alignUp(lclMemSize, device.info().minDataTypeAlignSize_) +
+ *reinterpret_cast(values_ + desc.offset_);
+ }
}
}
@@ -192,7 +204,16 @@ address KernelParameters::capture(const Device& device, cl_int* error) {
} else {
*error = CL_OUT_OF_HOST_MEMORY;
}
+ // Validate the local memory oversubscription
+ if (lclMemSize > device.info().localMemSize_) {
+ *error = CL_OUT_OF_RESOURCES;
+ }
+ // Check if capture was successful
+ if (CL_SUCCESS != *error) {
+ AlignedMemory::deallocate(mem);
+ mem = nullptr;
+ }
return mem;
}
@@ -266,7 +287,7 @@ KernelSignature::KernelSignature(const std::vector& p
last = i;
}
// Collect all OCL memory objects
- if (desc.type_ == T_POINTER && desc.size_ != 0) {
+ if (desc.type_ == T_POINTER && (desc.addressQualifier_ != CL_KERNEL_ARG_ADDRESS_LOCAL)) {
params_[i].info_.arrayIndex_ = numMemories_;
++numMemories_;
}
diff --git a/rocclr/runtime/platform/kernel.hpp b/rocclr/runtime/platform/kernel.hpp
index e2377c7ee1..f03cd03ed4 100644
--- a/rocclr/runtime/platform/kernel.hpp
+++ b/rocclr/runtime/platform/kernel.hpp
@@ -193,7 +193,7 @@ class KernelParameters : protected HeapObject {
size_t localMemSize(size_t minDataTypeAlignment) const;
//! Capture the state of the parameters and return the stack base pointer.
- address capture(const Device& device, cl_int* error);
+ address capture(const Device& device, cl_ulong lclMemSize, cl_int* error);
//! Release the captured state of the parameters.
void release(address parameters, const amd::Device& device) const;