Add DisableZeroCopyForBuffers debug flag.

- This flag disables zero copy for all buffers.

Change-Id: I882f01942f99e399e33f5fe2750acbcc0476457c
This commit is contained in:
Mrozek, Michal
2018-06-06 16:59:27 +02:00
committed by sys_ocldev
parent dccee618be
commit f24ec6ec33
5 changed files with 44 additions and 4 deletions

View File

@@ -211,7 +211,8 @@ void Buffer::checkMemory(cl_mem_flags flags,
if (alignUp(hostPtr, MemoryConstants::cacheLineSize) != hostPtr ||
alignUp(size, MemoryConstants::cacheLineSize) != size ||
minAddress > reinterpret_cast<uintptr_t>(hostPtr) ||
DebugManager.flags.DisableZeroCopyForUseHostPtr.get()) {
DebugManager.flags.DisableZeroCopyForUseHostPtr.get() ||
DebugManager.flags.DisableZeroCopyForBuffers.get()) {
allocateMemory = true;
isZeroCopy = false;
copyMemoryFromHostPtr = true;
@@ -224,6 +225,9 @@ void Buffer::checkMemory(cl_mem_flags flags,
} else {
allocateMemory = true;
isZeroCopy = true;
if (DebugManager.flags.DisableZeroCopyForBuffers.get()) {
isZeroCopy = false;
}
}
if (flags & CL_MEM_COPY_HOST_PTR) {

View File

@@ -27,6 +27,7 @@
#include "runtime/helpers/mipmap.h"
#include "runtime/sharings/sharing.h"
#include "runtime/mem_obj/map_operations_handler.h"
#include "runtime/os_interface/debug_settings_manager.h"
#include <atomic>
#include <cstdint>
#include <vector>
@@ -119,7 +120,7 @@ class MemObj : public BaseObject<_cl_mem> {
void waitForCsrCompletion();
void destroyGraphicsAllocation(GraphicsAllocation *allocation, bool asyncDestroy);
bool checkIfMemoryTransferIsRequired(size_t offsetInMemObjest, size_t offsetInHostPtr, const void *ptr, cl_command_type cmdType);
bool mappingOnCpuAllowed() const { return !allowTiling() && !peekSharingHandler() && !isMipMapped(this); }
bool mappingOnCpuAllowed() const { return !allowTiling() && !peekSharingHandler() && !isMipMapped(this) && !DebugManager.flags.DisableZeroCopyForBuffers.get(); }
virtual size_t calculateOffsetForMapping(const MemObjOffsetArray &offset) const { return offset[0]; }
size_t calculateMappedPtrLength(const MemObjSizeArray &size) const { return calculateOffsetForMapping(size); }
cl_mem_object_type peekClMemObjType() const { return memObjectType; }