mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-19 06:24:51 +08:00
fix: allow nullptr addresses while creating cb event.
Signed-off-by: Michal Mrozek <michal.mrozek@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
279dc77e9e
commit
f7b6dfff52
@@ -49,23 +49,26 @@ zexCounterBasedEventCreate(ze_context_handle_t hContext, ze_device_handle_t hDev
|
||||
|
||||
auto device = Device::fromHandle(hDevice);
|
||||
|
||||
if (!hDevice || !deviceAddress || !hostAddress || !desc || !phEvent) {
|
||||
if (!hDevice || !desc || !phEvent) {
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
NEO::SvmAllocationData *externalHostAllocData = nullptr;
|
||||
bool allocFound = device->getDriverHandle()->findAllocationDataForRange(hostAddress, sizeof(uint64_t), externalHostAllocData);
|
||||
|
||||
if (!allocFound) {
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
if (hostAddress) {
|
||||
bool allocFound = device->getDriverHandle()->findAllocationDataForRange(hostAddress, sizeof(uint64_t), externalHostAllocData);
|
||||
if (!allocFound) {
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
}
|
||||
|
||||
auto allocation = externalHostAllocData->gpuAllocations.getGraphicsAllocation(device->getRootDeviceIndex());
|
||||
|
||||
auto inOrderExecInfo = NEO::InOrderExecInfo::createFromExternalAllocation(*device->getNEODevice(), castToUint64(deviceAddress), allocation, hostAddress, completionValue);
|
||||
|
||||
*phEvent = Event::create<uint64_t>(eventDescriptor, desc, device);
|
||||
Event::fromHandle(*phEvent)->updateInOrderExecState(inOrderExecInfo, completionValue, 0);
|
||||
|
||||
if (hostAddress && deviceAddress) {
|
||||
NEO::GraphicsAllocation *allocation = nullptr;
|
||||
allocation = externalHostAllocData->gpuAllocations.getGraphicsAllocation(device->getRootDeviceIndex());
|
||||
auto inOrderExecInfo = NEO::InOrderExecInfo::createFromExternalAllocation(*device->getNEODevice(), castToUint64(deviceAddress), allocation, hostAddress, completionValue);
|
||||
Event::fromHandle(*phEvent)->updateInOrderExecState(inOrderExecInfo, completionValue, 0);
|
||||
}
|
||||
|
||||
return ZE_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -3977,14 +3977,27 @@ HWTEST2_F(InOrderCmdListTests, givenCorrectInputParamsWhenCreatingCbEventThenRet
|
||||
|
||||
EXPECT_EQ(ZE_RESULT_ERROR_INVALID_ARGUMENT, zexCounterBasedEventCreate(context, device, gpuAddress, hostAddress, counterValue, &eventDesc, nullptr));
|
||||
EXPECT_EQ(ZE_RESULT_ERROR_INVALID_ARGUMENT, zexCounterBasedEventCreate(context, device, gpuAddress, hostAddress, counterValue, nullptr, &handle));
|
||||
EXPECT_EQ(ZE_RESULT_ERROR_INVALID_ARGUMENT, zexCounterBasedEventCreate(context, device, gpuAddress, nullptr, counterValue, &eventDesc, &handle));
|
||||
EXPECT_EQ(ZE_RESULT_ERROR_INVALID_ARGUMENT, zexCounterBasedEventCreate(context, device, nullptr, hostAddress, counterValue, &eventDesc, &handle));
|
||||
EXPECT_EQ(ZE_RESULT_ERROR_INVALID_ARGUMENT, zexCounterBasedEventCreate(context, nullptr, gpuAddress, hostAddress, counterValue, &eventDesc, &handle));
|
||||
EXPECT_EQ(ZE_RESULT_ERROR_INVALID_ARGUMENT, zexCounterBasedEventCreate(context, device, gpuAddress, &counterValue, counterValue, &eventDesc, &handle));
|
||||
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, zexCounterBasedEventCreate(context, device, gpuAddress, nullptr, counterValue, &eventDesc, &handle));
|
||||
auto eventObj = Event::fromHandle(handle);
|
||||
EXPECT_EQ(nullptr, eventObj->getInOrderExecInfo());
|
||||
zeEventDestroy(handle);
|
||||
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, zexCounterBasedEventCreate(context, device, nullptr, hostAddress, counterValue, &eventDesc, &handle));
|
||||
eventObj = Event::fromHandle(handle);
|
||||
EXPECT_EQ(nullptr, eventObj->getInOrderExecInfo());
|
||||
zeEventDestroy(handle);
|
||||
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, zexCounterBasedEventCreate(context, device, nullptr, nullptr, counterValue, &eventDesc, &handle));
|
||||
eventObj = Event::fromHandle(handle);
|
||||
EXPECT_EQ(nullptr, eventObj->getInOrderExecInfo());
|
||||
zeEventDestroy(handle);
|
||||
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, zexCounterBasedEventCreate(context, device, gpuAddress, hostAddress, counterValue, &eventDesc, &handle));
|
||||
|
||||
auto eventObj = Event::fromHandle(handle);
|
||||
eventObj = Event::fromHandle(handle);
|
||||
|
||||
ASSERT_NE(nullptr, eventObj);
|
||||
ASSERT_NE(nullptr, eventObj->getInOrderExecInfo().get());
|
||||
|
||||
Reference in New Issue
Block a user