Use GPU address when patching pipe

Change-Id: I4e4ca7ab2597fa97aa8cd1229382187974b22dde
Signed-off-by: Mateusz Jablonski <mateusz.jablonski@intel.com>
This commit is contained in:
Mateusz Jablonski
2019-06-21 16:22:21 +02:00
parent 3c1c4cf695
commit 30a534a4e4
2 changed files with 21 additions and 1 deletions

View File

@ -109,7 +109,7 @@ cl_int Pipe::getPipeInfo(cl_image_info paramName,
} }
void Pipe::setPipeArg(void *memory, uint32_t patchSize) { void Pipe::setPipeArg(void *memory, uint32_t patchSize) {
patchWithRequiredSize(memory, patchSize, (uintptr_t)getCpuAddress()); patchWithRequiredSize(memory, patchSize, static_cast<uintptr_t>(getGraphicsAllocation()->getGpuAddressToPatch()));
} }
Pipe::~Pipe() = default; Pipe::~Pipe() = default;

View File

@ -93,3 +93,23 @@ TEST_F(PipeTest, givenPipeWhenEnqueueWriteForUnmapIsCalledThenReturnError) {
errCode = clEnqueueUnmapMemObject(&cmdQ, pipe.get(), nullptr, 0, nullptr, nullptr); errCode = clEnqueueUnmapMemObject(&cmdQ, pipe.get(), nullptr, 0, nullptr, nullptr);
EXPECT_EQ(CL_INVALID_MEM_OBJECT, errCode); EXPECT_EQ(CL_INVALID_MEM_OBJECT, errCode);
} }
TEST_F(PipeTest, givenPipeWithDifferentCpuAndGpuAddressesWhenSetArgPipeThenUseGpuAddress) {
int errCode = CL_SUCCESS;
auto pipe = Pipe::create(&context, CL_MEM_READ_ONLY, 1, 20, nullptr, errCode);
ASSERT_NE(nullptr, pipe);
EXPECT_EQ(CL_SUCCESS, errCode);
EXPECT_EQ(21u, *reinterpret_cast<unsigned int *>(pipe->getCpuAddress()));
uint64_t gpuAddress = 0x12345;
auto pipeAllocation = pipe->getGraphicsAllocation();
pipeAllocation->setCpuPtrAndGpuAddress(pipeAllocation->getUnderlyingBuffer(), gpuAddress);
EXPECT_NE(reinterpret_cast<uint64_t>(pipeAllocation->getUnderlyingBuffer()), pipeAllocation->getGpuAddress());
uint64_t valueToPatch;
pipe->setPipeArg(&valueToPatch, sizeof(valueToPatch));
EXPECT_EQ(valueToPatch, pipeAllocation->getGpuAddressToPatch());
delete pipe;
}