Skip to content

Commit bc855e4

Browse files
Jaime ArteagaCompute-Runtime-Automation
authored andcommitted
Add support for zeContextGetStatus()
Change-Id: Idf6d7bf462d74720f2e21abad7eaecb297388ff4 Signed-off-by: Jaime Arteaga <[email protected]>
1 parent 7c086c9 commit bc855e4

File tree

2 files changed

+23
-6
lines changed

2 files changed

+23
-6
lines changed

level_zero/core/source/context/context_imp.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
#include "shared/source/memory_manager/memory_operations_handler.h"
1111

12-
#include "level_zero/core/source/device/device.h"
12+
#include "level_zero/core/source/device/device_imp.h"
1313
#include "level_zero/core/source/image/image.h"
1414
#include "level_zero/core/source/memory/memory_operations_helper.h"
1515

@@ -22,7 +22,14 @@ ze_result_t ContextImp::destroy() {
2222
}
2323

2424
ze_result_t ContextImp::getStatus() {
25-
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
25+
DriverHandleImp *driverHandleImp = static_cast<DriverHandleImp *>(this->driverHandle);
26+
for (auto device : driverHandleImp->devices) {
27+
DeviceImp *deviceImp = static_cast<DeviceImp *>(device);
28+
if (deviceImp->resourcesReleased) {
29+
return ZE_RESULT_ERROR_DEVICE_LOST;
30+
}
31+
}
32+
return ZE_RESULT_SUCCESS;
2633
}
2734

2835
DriverHandle *ContextImp::getDriverHandle() {

level_zero/core/test/unit_tests/sources/context/test_context.cpp

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@
1616
namespace L0 {
1717
namespace ult {
1818

19-
using ContextTest = Test<DeviceFixture>;
20-
21-
TEST_F(ContextTest, givenCallToContextGetStatusThenUnsupportedIsReturned) {
19+
using ContextGetStatusTest = Test<DeviceFixture>;
20+
TEST_F(ContextGetStatusTest,
21+
givenCallToContextGetStatusThenCorrectErrorCodeIsReturnedWhenResourcesHaveBeenReleased) {
2222
ze_context_handle_t hContext;
2323
ze_context_desc_t desc;
2424
ze_result_t res = driverHandle->createContext(&desc, &hContext);
@@ -27,11 +27,21 @@ TEST_F(ContextTest, givenCallToContextGetStatusThenUnsupportedIsReturned) {
2727
L0::Context *context = L0::Context::fromHandle(hContext);
2828

2929
res = context->getStatus();
30-
EXPECT_EQ(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE, res);
30+
EXPECT_EQ(ZE_RESULT_SUCCESS, res);
31+
32+
for (auto device : driverHandle->devices) {
33+
L0::DeviceImp *deviceImp = static_cast<DeviceImp *>(device);
34+
deviceImp->releaseResources();
35+
}
36+
37+
res = context->getStatus();
38+
EXPECT_EQ(ZE_RESULT_ERROR_DEVICE_LOST, res);
3139

3240
context->destroy();
3341
}
3442

43+
using ContextTest = Test<DeviceFixture>;
44+
3545
TEST_F(ContextTest, whenCreatingAndDestroyingContextThenSuccessIsReturned) {
3646
ze_context_handle_t hContext;
3747
ze_context_desc_t desc;

0 commit comments

Comments
 (0)