Propagate errors in ModuleImp::createKernel

Change-Id: I71612013e27315841103ceaf1de9ea11c1876ac6
Signed-off-by: Jim Snow <jim.m.snow@intel.com>
This commit is contained in:
Jim Snow
2020-05-01 15:39:55 -07:00
parent a5793fc654
commit f0c7f5f5de
2 changed files with 37 additions and 4 deletions

View File

@@ -383,9 +383,14 @@ void ModuleImp::updateBuildLog(NEO::Device *neoDevice) {
ze_result_t ModuleImp::createKernel(const ze_kernel_desc_t *desc,
ze_kernel_handle_t *phFunction) {
ze_result_t res = ZE_RESULT_SUCCESS;
*phFunction = Kernel::create(productFamily, this, desc, &res)->toHandle();
return ZE_RESULT_SUCCESS;
ze_result_t res;
auto kernel = Kernel::create(productFamily, this, desc, &res);
if (res == ZE_RESULT_SUCCESS) {
*phFunction = kernel->toHandle();
}
return res;
}
ze_result_t ModuleImp::getNativeBinary(size_t *pSize, uint8_t *pModuleNativeBinary) {

View File

@@ -26,5 +26,33 @@ HWTEST_F(ModuleTest, givenBinaryWithDebugDataWhenModuleCreatedFromNativeBinaryTh
EXPECT_NE(0u, size);
}
HWTEST_F(ModuleTest, givenKernelCreateReturnsSuccess) {
ze_kernel_handle_t kernelHandle;
ze_kernel_desc_t kernelDesc = {};
kernelDesc.version = ZE_KERNEL_DESC_VERSION_CURRENT;
kernelDesc.flags = ZE_KERNEL_FLAG_NONE;
kernelDesc.pKernelName = kernelName.c_str();
ze_result_t res = module->createKernel(&kernelDesc, &kernelHandle);
EXPECT_EQ(ZE_RESULT_SUCCESS, res);
Kernel::fromHandle(kernelHandle)->destroy();
}
HWTEST_F(ModuleTest, givenKernelCreateWithIncorrectKernelNameReturnsFailure) {
ze_kernel_handle_t kernelHandle;
ze_kernel_desc_t kernelDesc = {};
kernelDesc.version = ZE_KERNEL_DESC_VERSION_CURRENT;
kernelDesc.flags = ZE_KERNEL_FLAG_NONE;
kernelDesc.pKernelName = "nonexistent_function";
ze_result_t res = module->createKernel(&kernelDesc, &kernelHandle);
EXPECT_EQ(ZE_RESULT_ERROR_INVALID_ARGUMENT, res);
}
} // namespace ult
} // namespace L0
} // namespace L0