Skip to content

Commit cee5877

Browse files
committed
Fix zer tracing check and get last error given ddi failed
Signed-off-by: Neil R. Spruit <[email protected]>
1 parent fd91f14 commit cee5877

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

scripts/templates/ldrddi_driver_ddi.cpp.mako

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,9 @@ namespace loader_driver_ddi
103103
// Check if the default driver supports DDI Handles
104104
if (loader::context->defaultZerDriverHandle == nullptr) {
105105
%if ret_type == 'ze_result_t':
106+
if (loader::context->zeDrivers.front().zerddiInitResult == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) {
107+
return ${X}_RESULT_ERROR_UNSUPPORTED_FEATURE;
108+
}
106109
return ${X}_RESULT_ERROR_UNINITIALIZED;
107110
%else:
108111
if (loader::context->zeDrivers.front().zerddiInitResult == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) {

source/loader/zer_ldrddi_driver_ddi.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ namespace loader_driver_ddi
2929

3030
// Check if the default driver supports DDI Handles
3131
if (loader::context->defaultZerDriverHandle == nullptr) {
32+
if (loader::context->zeDrivers.front().zerddiInitResult == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) {
33+
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
34+
}
3235
return ZE_RESULT_ERROR_UNINITIALIZED;
3336
}
3437
auto dditable = reinterpret_cast<ze_handle_t*>( loader::context->defaultZerDriverHandle )->pRuntime;

test/loader_tracing_layer.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -978,8 +978,9 @@ namespace
978978
const char *errorString = nullptr;
979979
ze_result_t result = zerGetLastErrorDescription(&errorString);
980980
EXPECT_EQ(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE, result);
981-
EXPECT_EQ(0, tracingData.getZerPrologueCallCount("zerGetLastErrorDescription"));
982-
EXPECT_EQ(0, tracingData.getZerEpilogueCallCount("zerGetLastErrorDescription"));
981+
// ZER callbacks should still be called in the tracing layer even if the driver ends up not supporting ZER APIs
982+
EXPECT_EQ(1, tracingData.getZerPrologueCallCount("zerGetLastErrorDescription"));
983+
EXPECT_EQ(1, tracingData.getZerEpilogueCallCount("zerGetLastErrorDescription"));
983984

984985
callBasicZeApis(drivers);
985986
verifyBasicZeApisCalledBothCallbackTypes(1);
@@ -993,8 +994,9 @@ namespace
993994
errorString = nullptr;
994995
result = zerGetLastErrorDescription(&errorString);
995996
EXPECT_EQ(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE, result);
996-
EXPECT_EQ(0, tracingData.getZerPrologueCallCount("zerGetLastErrorDescription"));
997-
EXPECT_EQ(0, tracingData.getZerEpilogueCallCount("zerGetLastErrorDescription"));
997+
// ZER callbacks should still be called in the tracing layer even if the driver ends up not supporting ZER APIs
998+
EXPECT_EQ(2, tracingData.getZerPrologueCallCount("zerGetLastErrorDescription"));
999+
EXPECT_EQ(2, tracingData.getZerEpilogueCallCount("zerGetLastErrorDescription"));
9981000

9991001
uint32_t deviceCount = 1;
10001002
std::vector<ze_device_handle_t> devices(deviceCount);

0 commit comments

Comments
 (0)