mirror of
https://github.com/intel/compute-runtime.git
synced 2025-09-15 13:01:45 +08:00
Choose cpu copy for 32 bit application using local memory.
Change-Id: I74aed9475185b09d4569fafb3427052fff73fd89 Signed-off-by: Michal Mrozek <michal.mrozek@intel.com>
This commit is contained in:

committed by
sys_ocldev

parent
5751b5eb27
commit
0e85ccf084
@ -518,19 +518,22 @@ bool Buffer::isReadWriteOnCpuAllowed() {
|
||||
}
|
||||
|
||||
bool Buffer::isReadWriteOnCpuPreffered(void *ptr, size_t size) {
|
||||
//if buffer is not zero copy and pointer is aligned it will be more beneficial to do the transfer on GPU
|
||||
if (!isMemObjZeroCopy() && (reinterpret_cast<uintptr_t>(ptr) & (MemoryConstants::cacheLineSize - 1)) == 0) {
|
||||
return false;
|
||||
}
|
||||
if (MemoryPool::isSystemMemoryPool(graphicsAllocation->getMemoryPool())) {
|
||||
//if buffer is not zero copy and pointer is aligned it will be more beneficial to do the transfer on GPU
|
||||
if (!isMemObjZeroCopy() && (reinterpret_cast<uintptr_t>(ptr) & (MemoryConstants::cacheLineSize - 1)) == 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
//on low power devices larger transfers are better on the GPU
|
||||
if (context->getDevice(0)->getDeviceInfo().platformLP && size > maxBufferSizeForReadWriteOnCpu) {
|
||||
return false;
|
||||
//on low power devices larger transfers are better on the GPU
|
||||
if (context->getDevice(0)->getDeviceInfo().platformLP && size > maxBufferSizeForReadWriteOnCpu) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
//if we are not in System Memory Pool, it is more beneficial to do the transfer on GPU
|
||||
//for 32 bit applications, utilize CPU transfers here.
|
||||
if (!MemoryPool::isSystemMemoryPool(graphicsAllocation->getMemoryPool()) && is64bit) {
|
||||
if (is64bit) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -7,6 +7,7 @@
|
||||
|
||||
#include "shared/source/gmm_helper/gmm.h"
|
||||
#include "shared/source/helpers/basic_math.h"
|
||||
#include "shared/test/unit_test/helpers/debug_manager_state_restore.h"
|
||||
|
||||
#include "opencl/test/unit_test/command_queue/enqueue_read_buffer_fixture.h"
|
||||
#include "opencl/test/unit_test/mocks/mock_command_queue.h"
|
||||
@ -251,3 +252,20 @@ TEST(ReadWriteBufferOnCpu, given32BitApplicationWhenLocalMemoryPoolAllocationIsA
|
||||
EXPECT_TRUE(buffer->isReadWriteOnCpuAllowed());
|
||||
EXPECT_TRUE(buffer->isReadWriteOnCpuPreffered(reinterpret_cast<void *>(0x1000), MemoryConstants::pageSize));
|
||||
}
|
||||
|
||||
TEST(ReadWriteBufferOnCpu, given32BitAppAndLocalMemoryBufferWhenAskedForCpuTransferPreferenceThenTrueIsReturned) {
|
||||
if (is64bit) {
|
||||
GTEST_SKIP();
|
||||
}
|
||||
DebugManagerStateRestore restorer;
|
||||
DebugManager.flags.EnableLocalMemory.set(true);
|
||||
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());
|
||||
|
||||
EXPECT_TRUE(buffer->isReadWriteOnCpuAllowed());
|
||||
EXPECT_TRUE(buffer->isReadWriteOnCpuPreffered(reinterpret_cast<void *>(0x1000), MemoryConstants::pageSize));
|
||||
}
|
Reference in New Issue
Block a user