mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-21 09:14:47 +08:00
fix: respect arg size when setting kernel arg in OCL path
Fixes: #777 https://github.com/intel/compute-runtime/issues/777 Signed-off-by: Mateusz Jablonski <mateusz.jablonski@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
8154c21697
commit
c10ff0f3c6
@@ -1714,17 +1714,16 @@ cl_int Kernel::setArgImmediate(uint32_t argIndex,
|
||||
const auto &argAsVal = kernelInfo.kernelDescriptor.payloadMappings.explicitArgs[argIndex].as<ArgDescValue>();
|
||||
for (const auto &element : argAsVal.elements) {
|
||||
DEBUG_BREAK_IF(element.size <= 0);
|
||||
if (static_cast<size_t>(element.sourceOffset + element.size) > argSize) {
|
||||
return CL_INVALID_ARG_SIZE;
|
||||
}
|
||||
|
||||
auto pDst = ptrOffset(crossThreadData, element.offset);
|
||||
auto pSrc = ptrOffset(argVal, element.sourceOffset);
|
||||
|
||||
DEBUG_BREAK_IF(!(ptrOffset(pDst, element.size) <= crossThreadDataEnd));
|
||||
auto dstAvailableSpace = crossThreadDataEnd - pDst;
|
||||
|
||||
if (element.sourceOffset < argSize) {
|
||||
size_t maxBytesToCopy = argSize - element.sourceOffset;
|
||||
size_t bytesToCopy = std::min(static_cast<size_t>(element.size), maxBytesToCopy);
|
||||
memcpy_s(pDst, element.size, pSrc, bytesToCopy);
|
||||
}
|
||||
memcpy_s(pDst, dstAvailableSpace, pSrc, element.size);
|
||||
}
|
||||
|
||||
retVal = CL_SUCCESS;
|
||||
|
||||
Reference in New Issue
Block a user