SWDEV-435015 - Disable sysmem allocation in abstraction layer
Change-Id: Idefdabd2997d618b962c42545ae67768c628c5d6
This commit is contained in:
@@ -951,7 +951,7 @@ bool Buffer::create(bool alloc_local) {
|
||||
|
||||
return deviceMemory_ != nullptr;
|
||||
}
|
||||
assert(owner()->getHostMem() != nullptr);
|
||||
assert(owner()->getHostMem() != nullptr || (owner()->getContext().devices().size() == 1));
|
||||
|
||||
flags_ |= HostMemoryDirectAccess;
|
||||
|
||||
@@ -965,7 +965,15 @@ bool Buffer::create(bool alloc_local) {
|
||||
return deviceMemory_ != nullptr;
|
||||
}
|
||||
|
||||
if (owner()->getSvmPtr() != owner()->getHostMem()) {
|
||||
// Just one device and allocation must be done in the backend
|
||||
if ((memFlags & CL_MEM_ALLOC_HOST_PTR) && (owner()->getContext().devices().size() == 1)) {
|
||||
deviceMemory_ = dev().hostAlloc(size(), 1, Device::MemorySegment::kNoAtomics);
|
||||
// Copy original data to the allocated host memory
|
||||
if (memFlags & CL_MEM_COPY_HOST_PTR) {
|
||||
memcpy(deviceMemory_, owner()->getHostMem(), owner()->getSize());
|
||||
}
|
||||
owner()->setHostMem(deviceMemory_);
|
||||
} else if (owner()->getSvmPtr() != owner()->getHostMem()) {
|
||||
if (memFlags & (CL_MEM_USE_HOST_PTR | CL_MEM_ALLOC_HOST_PTR)) {
|
||||
hsa_amd_memory_pool_t pool = (memFlags & CL_MEM_SVM_ATOMICS) ?
|
||||
dev().SystemSegment() :
|
||||
|
||||
@@ -214,7 +214,14 @@ bool Memory::allocHostMemory(void* initFrom, bool allocHostMem, bool forceCopy)
|
||||
// This allocation is necessary to use coherency mechanism
|
||||
// for the initialization
|
||||
if (getMemFlags() & (CL_MEM_COPY_HOST_PTR | CL_MEM_ALLOC_HOST_PTR)) {
|
||||
allocHostMem = true;
|
||||
// Extra system memory allocation and copy can be very expensive.
|
||||
// Thus, avoid it if runtime doesn't perform deferred allocations
|
||||
if ((devices.size() == 1) || DISABLE_DEFERRED_ALLOC) {
|
||||
allocHostMem = false;
|
||||
setHostMem(initFrom);
|
||||
} else {
|
||||
allocHostMem = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Did application request to use host memory?
|
||||
|
||||
Reference in New Issue
Block a user