Correct clCreateProgramWithBinary

store proper devices
validate input devices, lengths and binary
return correct binaries

Related-To: NEO-5001
Change-Id: I3822c291a4430e64afe54f1486b0014f16de3d64
Signed-off-by: Mateusz Jablonski <mateusz.jablonski@intel.com>
This commit is contained in:
Mateusz Jablonski
2020-10-21 10:25:03 +02:00
committed by sys_ocldev
parent 4c2d92890f
commit 8afdb2d981
18 changed files with 383 additions and 105 deletions

View File

@@ -1344,16 +1344,32 @@ cl_program CL_API_CALL clCreateProgramWithBinary(cl_context context,
"lengths", lengths,
"binaries", binaries,
"binaryStatus", binaryStatus);
retVal = validateObjects(context, deviceList, *deviceList, binaries, *binaries, lengths, *lengths);
Context *pContext = nullptr;
retVal = validateObjects(WithCastToInternal(context, &pContext), deviceList, numDevices, binaries, lengths);
cl_program program = nullptr;
ClDeviceVector deviceVector;
if (retVal == CL_SUCCESS) {
for (auto i = 0u; i < numDevices; i++) {
auto device = castToObject<ClDevice>(deviceList[i]);
if (!device || !pContext->isDeviceAssociated(*device)) {
retVal = CL_INVALID_DEVICE;
break;
}
if (lengths[i] == 0 || binaries[i] == nullptr) {
retVal = CL_INVALID_VALUE;
break;
}
deviceVector.push_back(device);
}
}
NEO::FileLoggerInstance().dumpBinaryProgram(numDevices, lengths, binaries);
if (CL_SUCCESS == retVal) {
program = Program::create(
context,
numDevices,
deviceList,
pContext,
deviceVector,
lengths,
binaries,
binaryStatus,