Pass canonized gpuAddress in setCpuPtrAndGpuAddress

Related-To: NEO-6523
Signed-off-by: Krzysztof Gibala <krzysztof.gibala@intel.com>
This commit is contained in:
Krzysztof Gibala
2022-06-06 20:34:20 +00:00
committed by Compute-Runtime-Automation
parent c51ce2a35c
commit 77dde01503
13 changed files with 90 additions and 35 deletions

View File

@ -147,8 +147,11 @@ TEST(GraphicsAllocationTest, WhenGettingAddressesThenAddressesAreCorrect) {
cpuPtr = (void *)65535;
gpuAddr = 1ULL;
gfxAllocation.setCpuPtrAndGpuAddress(cpuPtr, gpuAddr);
EXPECT_EQ(gpuAddr, gfxAllocation.getGpuAddress());
auto gmmHelper = std::make_unique<GmmHelper>(nullptr, defaultHwInfo.get());
auto canonizedGpuAddress = gmmHelper->canonize(gpuAddr);
gfxAllocation.setCpuPtrAndGpuAddress(cpuPtr, canonizedGpuAddress);
EXPECT_EQ(canonizedGpuAddress, gfxAllocation.getGpuAddress());
EXPECT_EQ(cpuPtr, gfxAllocation.getUnderlyingBuffer());
}

View File

@ -1362,7 +1362,9 @@ HWTEST_F(UnifiedSharedMemoryHWTest, givenDeviceUsmAllocationWhenWriteBufferThenC
auto gpuAddress = gpuAllocation->getGpuAddress();
void *gpuPtr = reinterpret_cast<void *>(gpuAddress);
char *shiftedPtr = cpuPtr + 0x10;
gpuAllocation->setCpuPtrAndGpuAddress(shiftedPtr, reinterpret_cast<uint64_t>(shiftedPtr));
auto gmmHelper = mockContext.getDevice(0)->getGmmHelper();
auto canonizedGpuAddress = gmmHelper->canonize(reinterpret_cast<uint64_t>(shiftedPtr));
gpuAllocation->setCpuPtrAndGpuAddress(shiftedPtr, canonizedGpuAddress);
cl_mem_flags flags = 0;
auto status = CL_INVALID_PLATFORM;
@ -1373,7 +1375,8 @@ HWTEST_F(UnifiedSharedMemoryHWTest, givenDeviceUsmAllocationWhenWriteBufferThenC
myCmdQ.enqueueWriteBuffer(buffer, false, 0u, 4096u, deviceMemory, nullptr, 0u, nullptr, nullptr);
EXPECT_EQ(gpuPtr, myCmdQ.srcPtr);
gpuAllocation->setCpuPtrAndGpuAddress(cpuPtr, gpuAddress);
canonizedGpuAddress = gmmHelper->canonize(gpuAddress);
gpuAllocation->setCpuPtrAndGpuAddress(cpuPtr, canonizedGpuAddress);
delete buffer;
clMemFreeINTEL(&mockContext, deviceMemory);
}
@ -1390,7 +1393,9 @@ HWTEST_F(UnifiedSharedMemoryHWTest, givenDeviceUsmAllocationWhenReadBufferThenCp
auto gpuAddress = gpuAllocation->getGpuAddress();
void *gpuPtr = reinterpret_cast<void *>(gpuAddress);
char *shiftedPtr = cpuPtr + 0x10;
gpuAllocation->setCpuPtrAndGpuAddress(shiftedPtr, reinterpret_cast<uint64_t>(shiftedPtr));
auto gmmHelper = mockContext.getDevice(0)->getGmmHelper();
auto canonizedGpuAddress = gmmHelper->canonize(reinterpret_cast<uint64_t>(shiftedPtr));
gpuAllocation->setCpuPtrAndGpuAddress(shiftedPtr, canonizedGpuAddress);
cl_mem_flags flags = 0;
auto status = CL_INVALID_PLATFORM;
@ -1401,7 +1406,8 @@ HWTEST_F(UnifiedSharedMemoryHWTest, givenDeviceUsmAllocationWhenReadBufferThenCp
myCmdQ.enqueueReadBuffer(buffer, false, 0u, 4096u, deviceMemory, nullptr, 0u, nullptr, nullptr);
EXPECT_EQ(gpuPtr, myCmdQ.dstPtr);
gpuAllocation->setCpuPtrAndGpuAddress(cpuPtr, gpuAddress);
canonizedGpuAddress = gmmHelper->canonize(gpuAddress);
gpuAllocation->setCpuPtrAndGpuAddress(cpuPtr, canonizedGpuAddress);
delete buffer;
clMemFreeINTEL(&mockContext, deviceMemory);
}
@ -1417,7 +1423,9 @@ HWTEST_F(UnifiedSharedMemoryHWTest, givenSharedUsmAllocationWhenWriteBufferThenC
auto gpuAddress = gpuAllocation->getGpuAddress();
void *gpuPtr = reinterpret_cast<void *>(gpuAddress);
char *shiftedPtr = cpuPtr + 0x10;
gpuAllocation->setCpuPtrAndGpuAddress(shiftedPtr, reinterpret_cast<uint64_t>(shiftedPtr));
auto gmmHelper = mockContext.getDevice(0)->getGmmHelper();
auto canonizedGpuAddress = gmmHelper->canonize(reinterpret_cast<uint64_t>(shiftedPtr));
gpuAllocation->setCpuPtrAndGpuAddress(shiftedPtr, canonizedGpuAddress);
cl_mem_flags flags = 0;
auto status = CL_INVALID_PLATFORM;
@ -1428,7 +1436,8 @@ HWTEST_F(UnifiedSharedMemoryHWTest, givenSharedUsmAllocationWhenWriteBufferThenC
myCmdQ.enqueueWriteBuffer(buffer, false, 0u, 4096u, sharedMemory, nullptr, 0u, nullptr, nullptr);
EXPECT_EQ(gpuPtr, myCmdQ.srcPtr);
gpuAllocation->setCpuPtrAndGpuAddress(cpuPtr, gpuAddress);
canonizedGpuAddress = gmmHelper->canonize(gpuAddress);
gpuAllocation->setCpuPtrAndGpuAddress(cpuPtr, canonizedGpuAddress);
delete buffer;
clMemFreeINTEL(&mockContext, sharedMemory);
}
@ -1444,7 +1453,9 @@ HWTEST_F(UnifiedSharedMemoryHWTest, givenSharedUsmAllocationWhenReadBufferThenCp
auto gpuAddress = gpuAllocation->getGpuAddress();
void *gpuPtr = reinterpret_cast<void *>(gpuAddress);
char *shiftedPtr = cpuPtr + 0x10;
gpuAllocation->setCpuPtrAndGpuAddress(shiftedPtr, reinterpret_cast<uint64_t>(shiftedPtr));
auto gmmHelper = mockContext.getDevice(0)->getGmmHelper();
auto canonizedGpuAddress = gmmHelper->canonize(reinterpret_cast<uint64_t>(shiftedPtr));
gpuAllocation->setCpuPtrAndGpuAddress(shiftedPtr, canonizedGpuAddress);
cl_mem_flags flags = 0;
auto status = CL_INVALID_PLATFORM;
@ -1455,7 +1466,8 @@ HWTEST_F(UnifiedSharedMemoryHWTest, givenSharedUsmAllocationWhenReadBufferThenCp
myCmdQ.enqueueReadBuffer(buffer, false, 0u, 4096u, sharedMemory, nullptr, 0u, nullptr, nullptr);
EXPECT_EQ(gpuPtr, myCmdQ.dstPtr);
gpuAllocation->setCpuPtrAndGpuAddress(cpuPtr, gpuAddress);
canonizedGpuAddress = gmmHelper->canonize(gpuAddress);
gpuAllocation->setCpuPtrAndGpuAddress(cpuPtr, canonizedGpuAddress);
delete buffer;
clMemFreeINTEL(&mockContext, sharedMemory);
}