Skip to content

Commit dface02

Browse files
Remove mapping on free.
Change-Id: I0ec5783362c9091edf98f893b062faaaad125522 Signed-off-by: Mrozek, Michal <[email protected]>
1 parent 3e4dd67 commit dface02

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

runtime/api/api.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3467,6 +3467,10 @@ cl_int clMemFreeINTEL(
34673467
return CL_INVALID_VALUE;
34683468
}
34693469

3470+
if (neoContext->getSVMAllocsManager()->getSvmMapOperation(ptr)) {
3471+
neoContext->getSVMAllocsManager()->removeSvmMapOperation(ptr);
3472+
}
3473+
34703474
return CL_SUCCESS;
34713475
}
34723476

unit_tests/api/cl_unified_shared_memory_tests.inl

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,22 @@ TEST(clUnifiedSharedMemoryTests, whenClHostMemAllocIntelIsCalledThenItAllocatesH
3838
EXPECT_EQ(CL_SUCCESS, retVal);
3939
}
4040

41+
TEST(clUnifiedSharedMemoryTests, givenMappedAllocationWhenClMemFreeIntelIscalledThenMappingIsRemoved) {
42+
43+
MockContext mockContext;
44+
cl_int retVal = CL_SUCCESS;
45+
auto unifiedMemorySharedAllocation = clSharedMemAllocINTEL(&mockContext, mockContext.getDevice(0u), nullptr, 4, 0, &retVal);
46+
EXPECT_EQ(CL_SUCCESS, retVal);
47+
ASSERT_NE(nullptr, unifiedMemorySharedAllocation);
48+
49+
auto allocationsManager = mockContext.getSVMAllocsManager();
50+
allocationsManager->insertSvmMapOperation(unifiedMemorySharedAllocation, 4u, unifiedMemorySharedAllocation, 0u, false);
51+
52+
retVal = clMemFreeINTEL(&mockContext, unifiedMemorySharedAllocation);
53+
EXPECT_EQ(CL_SUCCESS, retVal);
54+
EXPECT_EQ(nullptr, allocationsManager->getSvmMapOperation(unifiedMemorySharedAllocation));
55+
}
56+
4157
TEST(clUnifiedSharedMemoryTests, whenClDeviceMemAllocINTELisCalledWithWrongContextThenInvalidContextErrorIsReturned) {
4258
cl_int retVal = CL_SUCCESS;
4359
auto ptr = clDeviceMemAllocINTEL(0, 0, nullptr, 0, 0, &retVal);

0 commit comments

Comments
 (0)