Prefer CPU transfer for Local Memory 32 bit applications.

Change-Id: Icdb1333c0d0123be3d26329088d7ed44df37c84e
Signed-off-by: Michal Mrozek <michal.mrozek@intel.com>
This commit is contained in:
Michal Mrozek
2020-02-21 12:36:52 +01:00
committed by sys_ocldev
parent 4987ac71c4
commit 33d5f504c6
4 changed files with 27 additions and 4 deletions

2
Jenkinsfile vendored
View File

@ -1,5 +1,5 @@
#!groovy
dependenciesRevision='b67325e72bcd5baa03886d87cac9afe6aea8cebd-1371'
strategy='EQUAL'
allowedCD=222
allowedCD=223
allowedF=11

View File

@ -528,7 +528,8 @@ bool Buffer::isReadWriteOnCpuPreffered(void *ptr, size_t size) {
}
//if we are not in System Memory Pool, it is more beneficial to do the transfer on GPU
if (!MemoryPool::isSystemMemoryPool(graphicsAllocation->getMemoryPool())) {
//for 32 bit applications, utilize CPU transfers here.
if (!MemoryPool::isSystemMemoryPool(graphicsAllocation->getMemoryPool()) && is64bit) {
return false;
}

View File

@ -228,5 +228,25 @@ TEST(ReadWriteBufferOnCpu, givenNoHostPtrAndAlignedSizeWhenMemoryAllocationIsInN
reinterpret_cast<MemoryAllocation *>(buffer->getGraphicsAllocation())->overrideMemoryPool(MemoryPool::SystemCpuInaccessible);
//read write on CPU is allowed, but not preffered. We can access this memory via Lock.
EXPECT_TRUE(buffer->isReadWriteOnCpuAllowed());
EXPECT_FALSE(buffer->isReadWriteOnCpuPreffered(reinterpret_cast<void *>(0x1000), MemoryConstants::pageSize));
if (is32bit) {
EXPECT_TRUE(buffer->isReadWriteOnCpuPreffered(reinterpret_cast<void *>(0x1000), MemoryConstants::pageSize));
} else {
EXPECT_FALSE(buffer->isReadWriteOnCpuPreffered(reinterpret_cast<void *>(0x1000), MemoryConstants::pageSize));
}
}
TEST(ReadWriteBufferOnCpu, given32BitApplicationWhenLocalMemoryPoolAllocationIsAskedForPreferenceThenCpuIsChoosen) {
if (is64bit) {
GTEST_SKIP();
}
auto device = std::make_unique<MockClDevice>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(nullptr));
MockContext ctx(device.get());
cl_int retVal = 0;
std::unique_ptr<Buffer> buffer(Buffer::create(&ctx, CL_MEM_READ_WRITE, MemoryConstants::pageSize, nullptr, retVal));
ASSERT_NE(nullptr, buffer.get());
reinterpret_cast<MemoryAllocation *>(buffer->getGraphicsAllocation())->overrideMemoryPool(MemoryPool::LocalMemory);
EXPECT_TRUE(buffer->isReadWriteOnCpuAllowed());
EXPECT_TRUE(buffer->isReadWriteOnCpuPreffered(reinterpret_cast<void *>(0x1000), MemoryConstants::pageSize));
}

View File

@ -467,7 +467,9 @@ TEST(Buffer, givenClMemCopyHostPointerPassedToBufferCreateWhenAllocationIsNotInS
std::unique_ptr<Buffer> buffer(Buffer::create(&ctx, flags, sizeof(memory), memory, retVal));
ASSERT_NE(nullptr, buffer.get());
auto taskCountSent = device->getGpgpuCommandStreamReceiver().peekLatestFlushedTaskCount();
EXPECT_LT(taskCount, taskCountSent);
if (is64bit) {
EXPECT_LT(taskCount, taskCountSent);
}
}
struct RenderCompressedBuffersTests : public ::testing::Test {
void SetUp() override {