Skip to content

Commit 0561ec1

Browse files
Jaime ArteagaCompute-Runtime-Automation
authored andcommitted
Add ULT for changeMemoryOperationStatusToL0ResultType
Signed-off-by: Jaime Arteaga <[email protected]>
1 parent bd32518 commit 0561ec1

File tree

2 files changed

+35
-1
lines changed

2 files changed

+35
-1
lines changed

level_zero/core/source/memory/memory_operations_helper.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2019-2020 Intel Corporation
2+
* Copyright (C) 2019-2021 Intel Corporation
33
*
44
* SPDX-License-Identifier: MIT
55
*
@@ -20,6 +20,8 @@ static ze_result_t changeMemoryOperationStatusToL0ResultType(NEO::MemoryOperatio
2020
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
2121

2222
case NEO::MemoryOperationsStatus::OUT_OF_MEMORY:
23+
return ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY;
24+
2325
case NEO::MemoryOperationsStatus::FAILED:
2426
return ZE_RESULT_ERROR_DEVICE_LOST;
2527

level_zero/core/test/unit_tests/sources/memory/test_memory.cpp

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,15 @@
66
*/
77

88
#include "shared/source/helpers/string.h"
9+
#include "shared/source/memory_manager/memory_operations_status.h"
910
#include "shared/test/common/helpers/debug_manager_state_restore.h"
1011

1112
#include "opencl/test/unit_test/mocks/mock_memory_manager.h"
1213
#include "test.h"
1314

1415
#include "level_zero/core/source/context/context_imp.h"
1516
#include "level_zero/core/source/driver/host_pointer_manager.h"
17+
#include "level_zero/core/source/memory/memory_operations_helper.h"
1618
#include "level_zero/core/test/unit_tests/fixtures/device_fixture.h"
1719
#include "level_zero/core/test/unit_tests/mocks/mock_built_ins.h"
1820

@@ -1488,5 +1490,35 @@ TEST_F(ContextMemoryTest, givenSystemAllocatedPointerThenGetAllocPropertiesRetur
14881490
delete[] ptr;
14891491
}
14901492

1493+
TEST_F(ContextMemoryTest, givenCallTochangeMemoryOperationStatusToL0ResultTypeThenExpectedValueIsReturned) {
1494+
NEO::MemoryOperationsStatus status = NEO::MemoryOperationsStatus::SUCCESS;
1495+
ze_result_t res = changeMemoryOperationStatusToL0ResultType(status);
1496+
EXPECT_EQ(res, ZE_RESULT_SUCCESS);
1497+
1498+
status = NEO::MemoryOperationsStatus::FAILED;
1499+
res = changeMemoryOperationStatusToL0ResultType(status);
1500+
EXPECT_EQ(res, ZE_RESULT_ERROR_DEVICE_LOST);
1501+
1502+
status = NEO::MemoryOperationsStatus::MEMORY_NOT_FOUND;
1503+
res = changeMemoryOperationStatusToL0ResultType(status);
1504+
EXPECT_EQ(res, ZE_RESULT_ERROR_INVALID_ARGUMENT);
1505+
1506+
status = NEO::MemoryOperationsStatus::OUT_OF_MEMORY;
1507+
res = changeMemoryOperationStatusToL0ResultType(status);
1508+
EXPECT_EQ(res, ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY);
1509+
1510+
status = NEO::MemoryOperationsStatus::UNSUPPORTED;
1511+
res = changeMemoryOperationStatusToL0ResultType(status);
1512+
EXPECT_EQ(res, ZE_RESULT_ERROR_UNSUPPORTED_FEATURE);
1513+
1514+
status = NEO::MemoryOperationsStatus::DEVICE_UNINITIALIZED;
1515+
res = changeMemoryOperationStatusToL0ResultType(status);
1516+
EXPECT_EQ(res, ZE_RESULT_ERROR_UNINITIALIZED);
1517+
1518+
status = static_cast<NEO::MemoryOperationsStatus>(static_cast<uint32_t>(NEO::MemoryOperationsStatus::DEVICE_UNINITIALIZED) + 1);
1519+
res = changeMemoryOperationStatusToL0ResultType(status);
1520+
EXPECT_EQ(res, ZE_RESULT_ERROR_UNKNOWN);
1521+
}
1522+
14911523
} // namespace ult
14921524
} // namespace L0

0 commit comments

Comments
 (0)