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
This commit is contained in:
@@ -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<const cl_mem*>(value) == NULL)) {
|
||||
LP64_SWITCH(uint32_value, uint64_value) = 0;
|
||||
reinterpret_cast<Memory**>(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<const uint8_t*>(value);
|
||||
break;
|
||||
case 2:
|
||||
uint32_value = *static_cast<const uint16_t*>(value);
|
||||
break;
|
||||
case 4:
|
||||
uint32_value = *static_cast<const uint32_t*>(value);
|
||||
if (desc.addressQualifier_ == CL_KERNEL_ARG_ADDRESS_LOCAL) {
|
||||
uint32_value = size;
|
||||
} else {
|
||||
uint32_value = *static_cast<const uint32_t*>(value);
|
||||
}
|
||||
break;
|
||||
case 8:
|
||||
uint64_value = *static_cast<const uint64_t*>(value);
|
||||
if (desc.addressQualifier_ == CL_KERNEL_ARG_ADDRESS_LOCAL) {
|
||||
uint64_value = size;
|
||||
} else {
|
||||
uint64_value = *static_cast<const uint64_t*>(value);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
switch (desc.size_) {
|
||||
case 0 /*local mem*/:
|
||||
*static_cast<size_t*>(param) = size;
|
||||
break;
|
||||
case sizeof(uint32_t):
|
||||
*static_cast<uint32_t*>(param) = uint32_value;
|
||||
break;
|
||||
|
||||
@@ -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<const size_t*>(paramaddr);
|
||||
WriteAqlArg(&aqlArgBuf, &ldsAddress, desc.size_);
|
||||
if (desc.size_ == 8) {
|
||||
ldsAddress += *reinterpret_cast<const uint64_t*>(paramaddr);
|
||||
} else {
|
||||
ldsAddress += *reinterpret_cast<const uint32_t*>(paramaddr);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case HSAIL_ARGTYPE_VALUE:
|
||||
|
||||
@@ -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<const cl_mem*>(value) == NULL)) {
|
||||
reinterpret_cast<Memory**>(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<const uint8_t*>(value);
|
||||
break;
|
||||
case 2:
|
||||
uint32_value = *static_cast<const uint16_t*>(value);
|
||||
break;
|
||||
switch (desc.size_) {
|
||||
case 4:
|
||||
uint32_value = *static_cast<const uint32_t*>(value);
|
||||
if (desc.addressQualifier_ == CL_KERNEL_ARG_ADDRESS_LOCAL) {
|
||||
uint32_value = size;
|
||||
} else {
|
||||
uint32_value = *static_cast<const uint32_t*>(value);
|
||||
}
|
||||
break;
|
||||
case 8:
|
||||
uint64_value = *static_cast<const uint64_t*>(value);
|
||||
if (desc.addressQualifier_ == CL_KERNEL_ARG_ADDRESS_LOCAL) {
|
||||
uint64_value = size;
|
||||
} else {
|
||||
uint64_value = *static_cast<const uint64_t*>(value);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
switch (argSize) {
|
||||
case 0 /*local mem*/:
|
||||
*static_cast<size_t*>(param) = size;
|
||||
break;
|
||||
case sizeof(uint32_t):
|
||||
*static_cast<uint32_t*>(param) = uint32_value;
|
||||
break;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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<const size_t*>(params + desc.offset_);
|
||||
// Patch the LDS address in the original arguments with an LDS address(offset)
|
||||
WriteAqlArgAt(const_cast<address>(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<const uint64_t*>(params + desc.offset_);
|
||||
// Patch the LDS address in the original arguments with an LDS address(offset)
|
||||
WriteAqlArgAt(const_cast<address>(params), &ldsAddress, desc.size_, desc.offset_);
|
||||
// Add the original size
|
||||
ldsAddress += ldsSize;
|
||||
} else {
|
||||
// Save the original LDS size
|
||||
uint32_t ldsSize = *reinterpret_cast<const uint32_t*>(params + desc.offset_);
|
||||
// Patch the LDS address in the original arguments with an LDS address(offset)
|
||||
uint32_t ldsAddr = ldsAddress;
|
||||
WriteAqlArgAt(const_cast<address>(params), &ldsAddr, desc.size_, desc.offset_);
|
||||
// Add the original size
|
||||
ldsAddress += ldsSize;
|
||||
}
|
||||
} else {
|
||||
Memory* gpuMem = nullptr;
|
||||
amd::Memory* mem = nullptr;
|
||||
|
||||
@@ -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<const cl_mem*>(value) == NULL)) {
|
||||
LP64_SWITCH(uint32_value, uint64_value) = 0;
|
||||
reinterpret_cast<Memory**>(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<const uint8_t*>(value);
|
||||
break;
|
||||
case 2:
|
||||
uint32_value = *static_cast<const uint16_t*>(value);
|
||||
break;
|
||||
case 4:
|
||||
uint32_value = *static_cast<const uint32_t*>(value);
|
||||
if (desc.addressQualifier_ == CL_KERNEL_ARG_ADDRESS_LOCAL) {
|
||||
uint32_value = size;
|
||||
} else {
|
||||
uint32_value = *static_cast<const uint32_t*>(value);
|
||||
}
|
||||
break;
|
||||
case 8:
|
||||
uint64_value = *static_cast<const uint64_t*>(value);
|
||||
if (desc.addressQualifier_ == CL_KERNEL_ARG_ADDRESS_LOCAL) {
|
||||
uint64_value = size;
|
||||
} else {
|
||||
uint64_value = *static_cast<const uint64_t*>(value);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
switch (desc.size_) {
|
||||
case 0 /*local mem*/:
|
||||
*static_cast<size_t*>(param) = size;
|
||||
break;
|
||||
case sizeof(uint32_t):
|
||||
*static_cast<uint32_t*>(param) = uint32_value;
|
||||
break;
|
||||
|
||||
@@ -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));
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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<const size_t*>(values_ + desc.offset_);
|
||||
if (desc.addressQualifier_ == CL_KERNEL_ARG_ADDRESS_LOCAL) {
|
||||
if (desc.size_ == 8) {
|
||||
memSize = alignUp(memSize, minDataTypeAlignment) +
|
||||
*reinterpret_cast<const uint64_t*>(values_ + desc.offset_);
|
||||
} else {
|
||||
memSize = alignUp(memSize, minDataTypeAlignment) +
|
||||
*reinterpret_cast<const uint32_t*>(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<const void* const*>(value));
|
||||
} else if ((value == NULL) || (static_cast<const cl_mem*>(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<const cl_command_queue*>(value))->asDeviceQueue();
|
||||
} else
|
||||
} else {
|
||||
switch (desc.size_) {
|
||||
case 1:
|
||||
uint32_value = *static_cast<const uint8_t*>(value);
|
||||
break;
|
||||
case 2:
|
||||
uint32_value = *static_cast<const uint16_t*>(value);
|
||||
break;
|
||||
case 4:
|
||||
uint32_value = *static_cast<const uint32_t*>(value);
|
||||
if (desc.addressQualifier_ == CL_KERNEL_ARG_ADDRESS_LOCAL) {
|
||||
uint32_value = size;
|
||||
} else {
|
||||
uint32_value = *static_cast<const uint32_t*>(value);
|
||||
}
|
||||
break;
|
||||
case 8:
|
||||
uint64_value = *static_cast<const uint64_t*>(value);
|
||||
if (desc.addressQualifier_ == CL_KERNEL_ARG_ADDRESS_LOCAL) {
|
||||
uint64_value = size;
|
||||
} else {
|
||||
uint64_value = *static_cast<const uint64_t*>(value);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
switch (desc.size_) {
|
||||
case 0 /*local mem*/:
|
||||
*static_cast<size_t*>(param) = size;
|
||||
break;
|
||||
case sizeof(uint32_t):
|
||||
*static_cast<uint32_t*>(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<uintptr_t*>(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<const uint64_t*>(values_ + desc.offset_);
|
||||
} else {
|
||||
lclMemSize = alignUp(lclMemSize, device.info().minDataTypeAlignSize_) +
|
||||
*reinterpret_cast<const uint32_t*>(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<KernelParameterDescriptor>& 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_;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
Viittaa uudesa ongelmassa
Block a user