refactor: pass reference to pointer as arg to findAllocationDataForRange

Signed-off-by: Mateusz Jablonski <mateusz.jablonski@intel.com>
This commit is contained in:
Mateusz Jablonski
2023-09-27 11:27:05 +00:00
committed by Compute-Runtime-Automation
parent 3911f6745f
commit 64fd270d56
10 changed files with 58 additions and 64 deletions

View File

@@ -1801,7 +1801,7 @@ ze_result_t CommandListCoreFamily<gfxCoreFamily>::appendMemoryFill(void *ptr,
bool hostPointerNeedsFlush = false;
NEO::SvmAllocationData *allocData = nullptr;
bool dstAllocFound = device->getDriverHandle()->findAllocationDataForRange(ptr, size, &allocData);
bool dstAllocFound = device->getDriverHandle()->findAllocationDataForRange(ptr, size, allocData);
if (dstAllocFound) {
if (allocData->memoryType == InternalMemoryType::HOST_UNIFIED_MEMORY ||
allocData->memoryType == InternalMemoryType::SHARED_UNIFIED_MEMORY) {
@@ -2129,7 +2129,7 @@ inline AlignedAllocationData CommandListCoreFamily<gfxCoreFamily>::getAlignedAll
NEO::SvmAllocationData *allocData = nullptr;
void *ptr = const_cast<void *>(buffer);
bool srcAllocFound = device->getDriverHandle()->findAllocationDataForRange(ptr,
bufferSize, &allocData);
bufferSize, allocData);
NEO::GraphicsAllocation *alloc = nullptr;
uintptr_t sourcePtr = reinterpret_cast<uintptr_t>(ptr);
@@ -2981,8 +2981,8 @@ bool CommandListCoreFamily<gfxCoreFamily>::isAppendSplitNeeded(void *dstPtr, con
NEO::SvmAllocationData *srcAllocData = nullptr;
NEO::SvmAllocationData *dstAllocData = nullptr;
bool srcAllocFound = this->device->getDriverHandle()->findAllocationDataForRange(const_cast<void *>(srcPtr), size, &srcAllocData);
bool dstAllocFound = this->device->getDriverHandle()->findAllocationDataForRange(dstPtr, size, &dstAllocData);
bool srcAllocFound = this->device->getDriverHandle()->findAllocationDataForRange(const_cast<void *>(srcPtr), size, srcAllocData);
bool dstAllocFound = this->device->getDriverHandle()->findAllocationDataForRange(dstPtr, size, dstAllocData);
auto srcMemoryPool = getMemoryPoolFromAllocDataForSplit(srcAllocFound, srcAllocData);
auto dstMemoryPool = getMemoryPoolFromAllocDataForSplit(dstAllocFound, dstAllocData);

View File

@@ -523,8 +523,8 @@ ze_result_t CommandListCoreFamilyImmediate<gfxCoreFamily>::appendMemoryCopy(
ze_result_t ret;
CpuMemCopyInfo cpuMemCopyInfo(dstptr, srcptr, size);
this->device->getDriverHandle()->findAllocationDataForRange(const_cast<void *>(srcptr), size, &cpuMemCopyInfo.srcAllocData);
this->device->getDriverHandle()->findAllocationDataForRange(dstptr, size, &cpuMemCopyInfo.dstAllocData);
this->device->getDriverHandle()->findAllocationDataForRange(const_cast<void *>(srcptr), size, cpuMemCopyInfo.srcAllocData);
this->device->getDriverHandle()->findAllocationDataForRange(dstptr, size, cpuMemCopyInfo.dstAllocData);
if (preferCopyThroughLockedPtr(cpuMemCopyInfo, numWaitEvents, phWaitEvents)) {
ret = performCpuMemcpy(cpuMemCopyInfo, hSignalEvent, numWaitEvents, phWaitEvents);
if (ret == ZE_RESULT_SUCCESS || ret == ZE_RESULT_ERROR_DEVICE_LOST) {

View File

@@ -450,7 +450,7 @@ ze_result_t ContextImp::makeMemoryResident(ze_device_handle_t hDevice, void *ptr
if (allocation == nullptr) {
NEO::SvmAllocationData *allocData = nullptr;
DriverHandleImp *driverHandleImp = static_cast<DriverHandleImp *>(this->driverHandle);
bool foundBuffer = driverHandleImp->findAllocationDataForRange(ptr, size, &allocData);
bool foundBuffer = driverHandleImp->findAllocationDataForRange(ptr, size, allocData);
if (foundBuffer) {
uintptr_t alignedPtr = reinterpret_cast<uintptr_t>(ptr);
allocation = driverHandleImp->getPeerAllocation(device, allocData, ptr, &alignedPtr, nullptr);

View File

@@ -50,7 +50,7 @@ struct DriverHandle : BaseDriver {
virtual ze_result_t checkMemoryAccessFromDevice(Device *device, const void *ptr) = 0;
virtual bool findAllocationDataForRange(const void *buffer,
size_t size,
NEO::SvmAllocationData **allocData) = 0;
NEO::SvmAllocationData *&allocData) = 0;
virtual std::vector<NEO::SvmAllocationData *> findAllocationsWithinRange(const void *buffer,
size_t size,
bool *allocationRangeCovered) = 0;

View File

@@ -427,7 +427,7 @@ ze_result_t DriverHandleImp::getDevice(uint32_t *pCount, ze_device_handle_t *phD
bool DriverHandleImp::findAllocationDataForRange(const void *buffer,
size_t size,
NEO::SvmAllocationData **allocData) {
NEO::SvmAllocationData *&allocData) {
size_t offset = 0;
if (size > 0) {
@@ -439,12 +439,10 @@ bool DriverHandleImp::findAllocationDataForRange(const void *buffer,
NEO::SvmAllocationData *beginAllocData = svmAllocsManager->getSVMAlloc(baseAddress);
NEO::SvmAllocationData *endAllocData = svmAllocsManager->getSVMAlloc(baseAddress + offset);
if (allocData) {
if (beginAllocData) {
*allocData = beginAllocData;
} else {
*allocData = endAllocData;
}
if (beginAllocData) {
allocData = beginAllocData;
} else {
allocData = endAllocData;
}
// Return true if the whole range requested is covered by the same allocation
@@ -457,7 +455,7 @@ bool DriverHandleImp::findAllocationDataForRange(const void *buffer,
auto allocDataVec = findAllocationsWithinRange(buffer, size, &allocationRangeCovered);
for (const auto &mappedAllocationData : allocDataVec) {
if (mappedAllocationData->virtualReservationData) {
*allocData = mappedAllocationData;
allocData = mappedAllocationData;
return true;
}
}
@@ -560,7 +558,7 @@ NEO::GraphicsAllocation *DriverHandleImp::getDriverSystemMemoryAllocation(void *
uint32_t rootDeviceIndex,
uintptr_t *gpuAddress) {
NEO::SvmAllocationData *allocData = nullptr;
bool allocFound = findAllocationDataForRange(ptr, size, &allocData);
bool allocFound = findAllocationDataForRange(ptr, size, allocData);
if (allocFound) {
if (gpuAddress != nullptr) {
*gpuAddress = reinterpret_cast<uintptr_t>(ptr);

View File

@@ -58,7 +58,7 @@ struct DriverHandleImp : public DriverHandle {
ze_result_t initialize(std::vector<std::unique_ptr<NEO::Device>> neoDevices);
bool findAllocationDataForRange(const void *buffer,
size_t size,
NEO::SvmAllocationData **allocData) override;
NEO::SvmAllocationData *&allocData) override;
std::vector<NEO::SvmAllocationData *> findAllocationsWithinRange(const void *buffer,
size_t size,
bool *allocationRangeCovered) override;

View File

@@ -356,12 +356,10 @@ void ImmediateCmdListSharedHeapsFlushTaskFixtureInit::validateDispatchFlags(bool
bool AppendFillFixture::MockDriverFillHandle::findAllocationDataForRange(const void *buffer,
size_t size,
NEO::SvmAllocationData **allocData) {
NEO::SvmAllocationData *&allocData) {
mockAllocation.reset(new NEO::MockGraphicsAllocation(const_cast<void *>(buffer), size));
data.gpuAllocations.addAllocation(mockAllocation.get());
if (allocData) {
*allocData = &data;
}
allocData = &data;
return true;
}

View File

@@ -204,7 +204,7 @@ class AppendFillFixture : public DeviceFixture {
public:
bool findAllocationDataForRange(const void *buffer,
size_t size,
NEO::SvmAllocationData **allocData) override;
NEO::SvmAllocationData *&allocData) override;
const uint32_t rootDeviceIndex = 0u;
std::unique_ptr<NEO::GraphicsAllocation> mockAllocation;

View File

@@ -1927,9 +1927,9 @@ HWTEST2_F(AppendMemoryLockedCopyTest, givenImmediateCommandListAndNonUsmHostPtrW
cmdList.copyThroughLockedPtrEnabled = true;
cmdList.initialize(device, NEO::EngineGroupType::RenderCompute, 0u);
CpuMemCopyInfo cpuMemCopyInfo(devicePtr, nonUsmHostPtr, 1024);
auto srcFound = device->getDriverHandle()->findAllocationDataForRange(nonUsmHostPtr, 1024, &cpuMemCopyInfo.srcAllocData);
auto srcFound = device->getDriverHandle()->findAllocationDataForRange(nonUsmHostPtr, 1024, cpuMemCopyInfo.srcAllocData);
ASSERT_FALSE(srcFound);
auto dstFound = device->getDriverHandle()->findAllocationDataForRange(devicePtr, 1024, &cpuMemCopyInfo.dstAllocData);
auto dstFound = device->getDriverHandle()->findAllocationDataForRange(devicePtr, 1024, cpuMemCopyInfo.dstAllocData);
ASSERT_TRUE(dstFound);
EXPECT_TRUE(cmdList.preferCopyThroughLockedPtr(cpuMemCopyInfo, 0, nullptr));
}
@@ -1939,9 +1939,9 @@ HWTEST2_F(AppendMemoryLockedCopyTest, givenImmediateCommandListAndNonUsmHostPtrW
cmdList.copyThroughLockedPtrEnabled = true;
cmdList.initialize(device, NEO::EngineGroupType::RenderCompute, 0u);
CpuMemCopyInfo cpuMemCopyInfo(nonUsmHostPtr, devicePtr, 1024);
auto srcFound = device->getDriverHandle()->findAllocationDataForRange(devicePtr, 1024, &cpuMemCopyInfo.srcAllocData);
auto srcFound = device->getDriverHandle()->findAllocationDataForRange(devicePtr, 1024, cpuMemCopyInfo.srcAllocData);
ASSERT_TRUE(srcFound);
auto dstFound = device->getDriverHandle()->findAllocationDataForRange(nonUsmHostPtr, 1024, &cpuMemCopyInfo.dstAllocData);
auto dstFound = device->getDriverHandle()->findAllocationDataForRange(nonUsmHostPtr, 1024, cpuMemCopyInfo.dstAllocData);
ASSERT_FALSE(dstFound);
EXPECT_TRUE(cmdList.preferCopyThroughLockedPtr(cpuMemCopyInfo, 0, nullptr));
}
@@ -1951,9 +1951,9 @@ HWTEST2_F(AppendMemoryLockedCopyTest, givenImmediateCommandListAndUsmHostPtrWhen
cmdList.copyThroughLockedPtrEnabled = true;
cmdList.initialize(device, NEO::EngineGroupType::RenderCompute, 0u);
CpuMemCopyInfo cpuMemCopyInfo(devicePtr, hostPtr, 1024);
auto srcFound = device->getDriverHandle()->findAllocationDataForRange(hostPtr, 1024, &cpuMemCopyInfo.srcAllocData);
auto srcFound = device->getDriverHandle()->findAllocationDataForRange(hostPtr, 1024, cpuMemCopyInfo.srcAllocData);
ASSERT_TRUE(srcFound);
auto dstFound = device->getDriverHandle()->findAllocationDataForRange(devicePtr, 1024, &cpuMemCopyInfo.dstAllocData);
auto dstFound = device->getDriverHandle()->findAllocationDataForRange(devicePtr, 1024, cpuMemCopyInfo.dstAllocData);
ASSERT_TRUE(dstFound);
EXPECT_TRUE(cmdList.preferCopyThroughLockedPtr(cpuMemCopyInfo, 0, nullptr));
}
@@ -1963,9 +1963,9 @@ HWTEST2_F(AppendMemoryLockedCopyTest, givenImmediateCommandListAndUsmHostPtrWhen
cmdList.copyThroughLockedPtrEnabled = true;
cmdList.initialize(device, NEO::EngineGroupType::RenderCompute, 0u);
CpuMemCopyInfo cpuMemCopyInfo(devicePtr, hostPtr, 1024);
auto srcFound = device->getDriverHandle()->findAllocationDataForRange(hostPtr, 1024, &cpuMemCopyInfo.srcAllocData);
auto srcFound = device->getDriverHandle()->findAllocationDataForRange(hostPtr, 1024, cpuMemCopyInfo.srcAllocData);
ASSERT_TRUE(srcFound);
auto dstFound = device->getDriverHandle()->findAllocationDataForRange(devicePtr, 1024, &cpuMemCopyInfo.dstAllocData);
auto dstFound = device->getDriverHandle()->findAllocationDataForRange(devicePtr, 1024, cpuMemCopyInfo.dstAllocData);
ASSERT_TRUE(dstFound);
ze_event_pool_desc_t eventPoolDesc = {};
@@ -2003,9 +2003,9 @@ HWTEST2_F(AppendMemoryLockedCopyTest, givenImmediateCommandListAndUsmHostPtrWhen
cmdList.copyThroughLockedPtrEnabled = true;
cmdList.initialize(device, NEO::EngineGroupType::RenderCompute, 0u);
CpuMemCopyInfo cpuMemCopyInfo(hostPtr, devicePtr, 1024);
auto srcFound = device->getDriverHandle()->findAllocationDataForRange(hostPtr, 1024, &cpuMemCopyInfo.srcAllocData);
auto srcFound = device->getDriverHandle()->findAllocationDataForRange(hostPtr, 1024, cpuMemCopyInfo.srcAllocData);
ASSERT_TRUE(srcFound);
auto dstFound = device->getDriverHandle()->findAllocationDataForRange(devicePtr, 1024, &cpuMemCopyInfo.dstAllocData);
auto dstFound = device->getDriverHandle()->findAllocationDataForRange(devicePtr, 1024, cpuMemCopyInfo.dstAllocData);
ASSERT_TRUE(dstFound);
ze_event_pool_desc_t eventPoolDesc = {};
@@ -2043,9 +2043,9 @@ HWTEST2_F(AppendMemoryLockedCopyTest, givenImmediateCommandListWhenIsSuitableUSM
cmdList.copyThroughLockedPtrEnabled = true;
cmdList.initialize(device, NEO::EngineGroupType::RenderCompute, 0u);
CpuMemCopyInfo cpuMemCopyInfo(devicePtr, nonUsmHostPtr, 1024);
auto srcFound = device->getDriverHandle()->findAllocationDataForRange(nonUsmHostPtr, 1024, &cpuMemCopyInfo.srcAllocData);
auto srcFound = device->getDriverHandle()->findAllocationDataForRange(nonUsmHostPtr, 1024, cpuMemCopyInfo.srcAllocData);
EXPECT_FALSE(srcFound);
auto dstFound = device->getDriverHandle()->findAllocationDataForRange(devicePtr, 1024, &cpuMemCopyInfo.dstAllocData);
auto dstFound = device->getDriverHandle()->findAllocationDataForRange(devicePtr, 1024, cpuMemCopyInfo.dstAllocData);
EXPECT_TRUE(dstFound);
EXPECT_FALSE(cmdList.isSuitableUSMDeviceAlloc(cpuMemCopyInfo.srcAllocData));
EXPECT_TRUE(cmdList.isSuitableUSMDeviceAlloc(cpuMemCopyInfo.dstAllocData));
@@ -2057,9 +2057,9 @@ HWTEST2_F(AppendMemoryLockedCopyTest, givenImmediateCommandListWhenIsSuitableUSM
cmdList.initialize(device, NEO::EngineGroupType::RenderCompute, 0u);
NEO::SvmAllocationData *srcAllocData;
NEO::SvmAllocationData *dstAllocData;
auto srcFound = device->getDriverHandle()->findAllocationDataForRange(hostPtr, 1024, &srcAllocData);
auto srcFound = device->getDriverHandle()->findAllocationDataForRange(hostPtr, 1024, srcAllocData);
EXPECT_TRUE(srcFound);
auto dstFound = device->getDriverHandle()->findAllocationDataForRange(devicePtr, 1024, &dstAllocData);
auto dstFound = device->getDriverHandle()->findAllocationDataForRange(devicePtr, 1024, dstAllocData);
EXPECT_TRUE(dstFound);
EXPECT_TRUE(cmdList.isSuitableUSMHostAlloc(srcAllocData));
EXPECT_FALSE(cmdList.isSuitableUSMHostAlloc(dstAllocData));
@@ -2072,11 +2072,11 @@ HWTEST2_F(AppendMemoryLockedCopyTest, givenImmediateCommandListWhenIsSuitableUSM
NEO::SvmAllocationData *hostAllocData;
NEO::SvmAllocationData *deviceAllocData;
NEO::SvmAllocationData *sharedAllocData;
auto hostAllocFound = device->getDriverHandle()->findAllocationDataForRange(hostPtr, 1024, &hostAllocData);
auto hostAllocFound = device->getDriverHandle()->findAllocationDataForRange(hostPtr, 1024, hostAllocData);
EXPECT_TRUE(hostAllocFound);
auto deviceAllocFound = device->getDriverHandle()->findAllocationDataForRange(devicePtr, 1024, &deviceAllocData);
auto deviceAllocFound = device->getDriverHandle()->findAllocationDataForRange(devicePtr, 1024, deviceAllocData);
EXPECT_TRUE(deviceAllocFound);
auto sharedAllocFound = device->getDriverHandle()->findAllocationDataForRange(sharedPtr, 1024, &sharedAllocData);
auto sharedAllocFound = device->getDriverHandle()->findAllocationDataForRange(sharedPtr, 1024, sharedAllocData);
EXPECT_TRUE(sharedAllocFound);
EXPECT_FALSE(cmdList.isSuitableUSMSharedAlloc(hostAllocData));
EXPECT_FALSE(cmdList.isSuitableUSMSharedAlloc(deviceAllocData));
@@ -2104,7 +2104,7 @@ HWTEST2_F(LocalMemoryMultiSubDeviceTest, givenImmediateCommandListWhenIsSuitable
context->allocDeviceMem(device->toHandle(), &deviceDesc, 2 * MemoryConstants::megaByte, 1u, &devicePtr);
NEO::SvmAllocationData *allocData;
auto allocFound = device->getDriverHandle()->findAllocationDataForRange(devicePtr, 2 * MemoryConstants::megaByte, &allocData);
auto allocFound = device->getDriverHandle()->findAllocationDataForRange(devicePtr, 2 * MemoryConstants::megaByte, allocData);
EXPECT_TRUE(allocFound);
EXPECT_FALSE(cmdList.isSuitableUSMDeviceAlloc(allocData));
context->freeMem(devicePtr);
@@ -2131,9 +2131,9 @@ HWTEST2_F(AppendMemoryLockedCopyTest, givenImmediateCommandListAndForcingLockPtr
cmdList.copyThroughLockedPtrEnabled = false;
cmdList.initialize(device, NEO::EngineGroupType::RenderCompute, 0u);
CpuMemCopyInfo cpuMemCopyInfo(devicePtr, nonUsmHostPtr, 1024);
auto srcFound = device->getDriverHandle()->findAllocationDataForRange(nonUsmHostPtr, 1024, &cpuMemCopyInfo.srcAllocData);
auto srcFound = device->getDriverHandle()->findAllocationDataForRange(nonUsmHostPtr, 1024, cpuMemCopyInfo.srcAllocData);
ASSERT_FALSE(srcFound);
auto dstFound = device->getDriverHandle()->findAllocationDataForRange(devicePtr, 1024, &cpuMemCopyInfo.dstAllocData);
auto dstFound = device->getDriverHandle()->findAllocationDataForRange(devicePtr, 1024, cpuMemCopyInfo.dstAllocData);
ASSERT_TRUE(dstFound);
EXPECT_TRUE(cmdList.preferCopyThroughLockedPtr(cpuMemCopyInfo, 0, nullptr));
}
@@ -2153,15 +2153,15 @@ HWTEST2_F(AppendMemoryLockedCopyTest, givenImmediateCommandListWhenGetTransferTy
NEO::SvmAllocationData *sharedUSMAllocData;
NEO::SvmAllocationData *notSpecifiedAllocData;
const auto hostUSMFound = device->getDriverHandle()->findAllocationDataForRange(hostPtr, 1024, &hostUSMAllocData);
const auto hostUSMFound = device->getDriverHandle()->findAllocationDataForRange(hostPtr, 1024, hostUSMAllocData);
EXPECT_TRUE(hostUSMFound);
const auto hostNonUSMFound = device->getDriverHandle()->findAllocationDataForRange(nonUsmHostPtr, 1024, &hostNonUSMAllocData);
const auto hostNonUSMFound = device->getDriverHandle()->findAllocationDataForRange(nonUsmHostPtr, 1024, hostNonUSMAllocData);
EXPECT_FALSE(hostNonUSMFound);
const auto deviceUSMFound = device->getDriverHandle()->findAllocationDataForRange(devicePtr, 1024, &deviceUSMAllocData);
const auto deviceUSMFound = device->getDriverHandle()->findAllocationDataForRange(devicePtr, 1024, deviceUSMAllocData);
EXPECT_TRUE(deviceUSMFound);
const auto sharedUSMFound = device->getDriverHandle()->findAllocationDataForRange(sharedPtr, 1024, &sharedUSMAllocData);
const auto sharedUSMFound = device->getDriverHandle()->findAllocationDataForRange(sharedPtr, 1024, sharedUSMAllocData);
EXPECT_TRUE(sharedUSMFound);
const auto hostUSM2Found = device->getDriverHandle()->findAllocationDataForRange(hostPtr2, 1024, &notSpecifiedAllocData);
const auto hostUSM2Found = device->getDriverHandle()->findAllocationDataForRange(hostPtr2, 1024, notSpecifiedAllocData);
EXPECT_TRUE(hostUSM2Found);
notSpecifiedAllocData->memoryType = NOT_SPECIFIED;
@@ -2238,7 +2238,7 @@ HWTEST2_F(AppendMemoryLockedCopyTest, givenImmediateCommandListAndNonUsmHostPtrW
cmdList.initialize(device, NEO::EngineGroupType::RenderCompute, 0u);
NEO::SvmAllocationData *allocData;
device->getDriverHandle()->findAllocationDataForRange(devicePtr, 1024, &allocData);
device->getDriverHandle()->findAllocationDataForRange(devicePtr, 1024, allocData);
auto dstAlloc = allocData->gpuAllocations.getGraphicsAllocation(device->getRootDeviceIndex());
EXPECT_EQ(nullptr, dstAlloc->getLockedPtr());
@@ -2254,7 +2254,7 @@ HWTEST2_F(AppendMemoryLockedCopyTest, givenImmediateCommandListAndNonUsmHostPtrW
cmdList.initialize(device, NEO::EngineGroupType::RenderCompute, 0u);
NEO::SvmAllocationData *allocData;
device->getDriverHandle()->findAllocationDataForRange(devicePtr, 1024, &allocData);
device->getDriverHandle()->findAllocationDataForRange(devicePtr, 1024, allocData);
auto dstAlloc = allocData->gpuAllocations.getGraphicsAllocation(device->getRootDeviceIndex());
EXPECT_EQ(nullptr, dstAlloc->getLockedPtr());
@@ -2276,11 +2276,11 @@ HWTEST2_F(AppendMemoryLockedCopyTest, givenForceModeWhenCopyIsCalledThenBothAllo
void *devicePtr2 = nullptr;
context->allocDeviceMem(device->toHandle(), &deviceDesc, sz, 1u, &devicePtr2);
NEO::SvmAllocationData *allocData2;
device->getDriverHandle()->findAllocationDataForRange(devicePtr2, 1024, &allocData2);
device->getDriverHandle()->findAllocationDataForRange(devicePtr2, 1024, allocData2);
auto dstAlloc2 = allocData2->gpuAllocations.getGraphicsAllocation(device->getRootDeviceIndex());
NEO::SvmAllocationData *allocData;
device->getDriverHandle()->findAllocationDataForRange(devicePtr, 1024, &allocData);
device->getDriverHandle()->findAllocationDataForRange(devicePtr, 1024, allocData);
auto dstAlloc = allocData->gpuAllocations.getGraphicsAllocation(device->getRootDeviceIndex());
EXPECT_EQ(nullptr, dstAlloc->getLockedPtr());
@@ -2305,11 +2305,11 @@ HWTEST2_F(AppendMemoryLockedCopyTest, givenForceModeWhenCopyIsCalledFromHostUsmT
void *hostPtr = nullptr;
context->allocHostMem(&hostDesc, sz, 1u, &hostPtr);
NEO::SvmAllocationData *hostAlloc;
device->getDriverHandle()->findAllocationDataForRange(hostPtr, 1024, &hostAlloc);
device->getDriverHandle()->findAllocationDataForRange(hostPtr, 1024, hostAlloc);
auto hostAlloction = hostAlloc->gpuAllocations.getGraphicsAllocation(device->getRootDeviceIndex());
NEO::SvmAllocationData *allocData;
device->getDriverHandle()->findAllocationDataForRange(devicePtr, 1024, &allocData);
device->getDriverHandle()->findAllocationDataForRange(devicePtr, 1024, allocData);
auto dstAlloc = allocData->gpuAllocations.getGraphicsAllocation(device->getRootDeviceIndex());
EXPECT_EQ(nullptr, dstAlloc->getLockedPtr());
@@ -2328,7 +2328,7 @@ HWTEST2_F(AppendMemoryLockedCopyTest, givenImmediateCommandListAndNonUsmHostPtrW
cmdList.initialize(device, NEO::EngineGroupType::RenderCompute, 0u);
NEO::SvmAllocationData *allocData;
device->getDriverHandle()->findAllocationDataForRange(devicePtr, 1024, &allocData);
device->getDriverHandle()->findAllocationDataForRange(devicePtr, 1024, allocData);
auto dstAlloc = allocData->gpuAllocations.getGraphicsAllocation(device->getRootDeviceIndex());
device->getDriverHandle()->getMemoryManager()->lockResource(dstAlloc);
@@ -2350,7 +2350,7 @@ HWTEST2_F(AppendMemoryLockedCopyTest, givenImmediateCommandListAndNonUsmHostPtrW
EXPECT_EQ(res, ZE_RESULT_SUCCESS);
NEO::SvmAllocationData *allocData;
device->getDriverHandle()->findAllocationDataForRange(devicePtr, 1024, &allocData);
device->getDriverHandle()->findAllocationDataForRange(devicePtr, 1024, allocData);
auto dstAlloc = allocData->gpuAllocations.getGraphicsAllocation(device->getRootDeviceIndex());
auto lockedPtr = reinterpret_cast<char *>(dstAlloc->getLockedPtr());
@@ -2596,7 +2596,7 @@ HWTEST2_F(AppendMemoryLockedCopyTest, givenImmediateCommandListAndFailedToLockPt
ASSERT_EQ(cmdList.appendMemoryCopyKernelWithGACalled, 0u);
NEO::SvmAllocationData *dstAllocData;
ASSERT_TRUE(device->getDriverHandle()->findAllocationDataForRange(devicePtr, 1 * MemoryConstants::megaByte, &dstAllocData));
ASSERT_TRUE(device->getDriverHandle()->findAllocationDataForRange(devicePtr, 1 * MemoryConstants::megaByte, dstAllocData));
ASSERT_NE(dstAllocData, nullptr);
auto mockMemoryManager = static_cast<MockMemoryManager *>(device->getDriverHandle()->getMemoryManager());
auto graphicsAllocation = dstAllocData->gpuAllocations.getGraphicsAllocation(device->getRootDeviceIndex());
@@ -2776,7 +2776,7 @@ HWTEST2_F(AppendMemoryLockedCopyTest, givenAllocationDataWhenFailingToObtainLock
cmdList.initialize(device, NEO::EngineGroupType::RenderCompute, 0u);
NEO::SvmAllocationData *dstAllocData = nullptr;
EXPECT_TRUE(device->getDriverHandle()->findAllocationDataForRange(devicePtr, 1024, &dstAllocData));
EXPECT_TRUE(device->getDriverHandle()->findAllocationDataForRange(devicePtr, 1024, dstAllocData));
ASSERT_NE(dstAllocData, nullptr);
auto graphicsAllocation = dstAllocData->gpuAllocations.getGraphicsAllocation(device->getRootDeviceIndex());
ASSERT_FALSE(graphicsAllocation->isLocked());
@@ -2802,8 +2802,8 @@ HWTEST2_F(AppendMemoryLockedCopyTest, givenFailedToObtainLockedPtrWhenPerforming
MockCommandListImmediateHw<gfxCoreFamily> cmdList;
cmdList.initialize(device, NEO::EngineGroupType::RenderCompute, 0u);
CpuMemCopyInfo cpuMemCopyInfo(nullptr, nullptr, 1024);
auto srcFound = device->getDriverHandle()->findAllocationDataForRange(nonUsmHostPtr, 1024, &cpuMemCopyInfo.srcAllocData);
auto dstFound = device->getDriverHandle()->findAllocationDataForRange(devicePtr, 1024, &cpuMemCopyInfo.dstAllocData);
auto srcFound = device->getDriverHandle()->findAllocationDataForRange(nonUsmHostPtr, 1024, cpuMemCopyInfo.srcAllocData);
auto dstFound = device->getDriverHandle()->findAllocationDataForRange(devicePtr, 1024, cpuMemCopyInfo.dstAllocData);
ASSERT_TRUE(srcFound != dstFound);
ze_result_t returnValue = ZE_RESULT_SUCCESS;

View File

@@ -47,14 +47,12 @@ class MockDriverHandle : public L0::DriverHandleImp {
public:
bool findAllocationDataForRange(const void *buffer,
size_t size,
NEO::SvmAllocationData **allocData) override {
NEO::SvmAllocationData *&allocData) override {
mockAllocation.reset(new NEO::MockGraphicsAllocation(rootDeviceIndex, NEO::AllocationType::INTERNAL_HOST_MEMORY,
reinterpret_cast<void *>(0x1234), 0x1000, 0, sizeof(uint32_t),
MemoryPool::System4KBPages, MemoryManager::maxOsContextCount));
data.gpuAllocations.addAllocation(mockAllocation.get());
if (allocData) {
*allocData = &data;
}
allocData = &data;
return true;
}
const uint32_t rootDeviceIndex = 0u;