mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-04 07:14:10 +08:00
Update clSVMFree
Do nothing when received context does not have a device supporting svm. Related-To: NEO-4368 Change-Id: I612fae138d6c40406a108f5b1e370eccee233236 Signed-off-by: Filip Hazubski <filip.hazubski@intel.com>
This commit is contained in:
committed by
sys_ocldev
parent
b83127e13f
commit
ed59e46c72
@@ -4056,7 +4056,6 @@ void *CL_API_CALL clSVMAlloc(cl_context context,
|
||||
TRACING_EXIT(clSVMAlloc, &pAlloc);
|
||||
return pAlloc;
|
||||
}
|
||||
auto pDevice = pContext->getDevice(0);
|
||||
|
||||
if (flags == 0) {
|
||||
flags = CL_MEM_READ_WRITE;
|
||||
@@ -4077,6 +4076,7 @@ void *CL_API_CALL clSVMAlloc(cl_context context,
|
||||
return pAlloc;
|
||||
}
|
||||
|
||||
auto pDevice = pContext->getDevice(0);
|
||||
if ((size == 0) || (size > pDevice->getDeviceInfo().maxMemAllocSize)) {
|
||||
TRACING_EXIT(clSVMAlloc, &pAlloc);
|
||||
return pAlloc;
|
||||
@@ -4112,10 +4112,23 @@ void CL_API_CALL clSVMFree(cl_context context,
|
||||
TRACING_ENTER(clSVMFree, &context, &svmPointer);
|
||||
DBG_LOG_INPUTS("context", context,
|
||||
"svmPointer", svmPointer);
|
||||
|
||||
Context *pContext = nullptr;
|
||||
if (validateObject(WithCastToInternal(context, &pContext)) == CL_SUCCESS) {
|
||||
pContext->getSVMAllocsManager()->freeSVMAlloc(svmPointer);
|
||||
cl_int retVal = validateObjects(
|
||||
WithCastToInternal(context, &pContext));
|
||||
|
||||
if (retVal != CL_SUCCESS) {
|
||||
TRACING_EXIT(clSVMFree, nullptr);
|
||||
return;
|
||||
}
|
||||
|
||||
auto pClDevice = pContext->getDevice(0);
|
||||
if (!pClDevice->getHardwareInfo().capabilityTable.ftrSvm) {
|
||||
TRACING_EXIT(clSVMFree, nullptr);
|
||||
return;
|
||||
}
|
||||
|
||||
pContext->getSVMAllocsManager()->freeSVMAlloc(svmPointer);
|
||||
TRACING_EXIT(clSVMFree, nullptr);
|
||||
}
|
||||
|
||||
|
||||
@@ -19,4 +19,19 @@ TEST_F(clSVMFreeTests, GivenNullPtrWhenFreeingSvmThenNoAction) {
|
||||
nullptr // void *svm_pointer
|
||||
);
|
||||
}
|
||||
|
||||
TEST_F(clSVMFreeTests, GivenContextWithDeviceNotSupportingSvmWhenFreeingSvmThenNoAction) {
|
||||
HardwareInfo hwInfo = *platformDevices[0];
|
||||
hwInfo.capabilityTable.ftrSvm = false;
|
||||
auto clDevice = std::make_unique<MockClDevice>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(&hwInfo));
|
||||
|
||||
cl_device_id deviceId = clDevice.get();
|
||||
auto context = clUniquePtr(Context::create<MockContext>(nullptr, ClDeviceVector(&deviceId, 1), nullptr, nullptr, retVal));
|
||||
EXPECT_EQ(retVal, CL_SUCCESS);
|
||||
|
||||
clSVMFree(
|
||||
context.get(),
|
||||
reinterpret_cast<void *>(0x1234));
|
||||
}
|
||||
|
||||
} // namespace ULT
|
||||
|
||||
Reference in New Issue
Block a user