mirror of
https://github.com/intel/compute-runtime.git
synced 2025-11-10 05:49:51 +08:00
Improve error handling in clCreateKernel
return nullptr when kernel initialization fails Signed-off-by: Mateusz Jablonski <mateusz.jablonski@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
84a0813dfa
commit
d2ac316e47
@@ -38,6 +38,9 @@ class MultiDeviceKernel : public BaseObject<_cl_kernel> {
|
||||
continue;
|
||||
}
|
||||
kernels[rootDeviceIndex] = Kernel::create<kernel_t, program_t>(program, *kernelInfos[rootDeviceIndex], *pDevice, errcodeRet);
|
||||
if (!kernels[rootDeviceIndex]) {
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
auto pMultiDeviceKernel = new multi_device_kernel_t(std::move(kernels), kernelInfos);
|
||||
|
||||
|
||||
@@ -3191,6 +3191,23 @@ TEST(KernelCreateTest, whenInitFailedThenReturnNull) {
|
||||
EXPECT_EQ(nullptr, ret);
|
||||
}
|
||||
|
||||
TEST(MultiDeviceKernelCreateTest, whenInitFailedThenReturnNullAndPropagateErrorCode) {
|
||||
MockContext context;
|
||||
auto pKernelInfo = std::make_unique<MockKernelInfo>();
|
||||
pKernelInfo->kernelDescriptor.kernelAttributes.simdSize = 0;
|
||||
|
||||
KernelInfoContainer kernelInfos;
|
||||
kernelInfos.push_back(pKernelInfo.get());
|
||||
|
||||
MockProgram program(&context, false, context.getDevices());
|
||||
|
||||
int32_t retVal = CL_SUCCESS;
|
||||
auto pMultiDeviceKernel = MultiDeviceKernel::create<MockKernel>(&program, kernelInfos, &retVal);
|
||||
|
||||
EXPECT_EQ(nullptr, pMultiDeviceKernel);
|
||||
EXPECT_EQ(CL_INVALID_KERNEL, retVal);
|
||||
}
|
||||
|
||||
TEST(ArgTypeTraits, GivenDefaultInitializedArgTypeMetadataThenAddressSpaceIsGlobal) {
|
||||
ArgTypeTraits metadata;
|
||||
EXPECT_EQ(NEO::KernelArgMetadata::AddrGlobal, metadata.addressQualifier);
|
||||
|
||||
Reference in New Issue
Block a user