Add multiStorageResource flag to AllocationProperties

Related-To: NEO-3242

Change-Id: If31adaead389acd3bef6af1931b91396c43b305e
Signed-off-by: Jobczyk, Lukasz <lukasz.jobczyk@intel.com>
This commit is contained in:
Jobczyk, Lukasz
2019-06-13 10:08:53 +02:00
committed by sys_ocldev
parent 04e893d31f
commit 329d940285
27 changed files with 106 additions and 86 deletions

View File

@@ -368,7 +368,7 @@ AllocationsList &CommandStreamReceiver::getAllocationsForReuse() { return intern
bool CommandStreamReceiver::createAllocationForHostSurface(HostPtrSurface &surface, bool requiresL3Flush) {
auto memoryManager = getMemoryManager();
AllocationProperties properties{false, surface.getSurfaceSize(), GraphicsAllocation::AllocationType::EXTERNAL_HOST_PTR};
AllocationProperties properties{false, surface.getSurfaceSize(), GraphicsAllocation::AllocationType::EXTERNAL_HOST_PTR, false};
properties.flags.flushL3RequiredForRead = properties.flags.flushL3RequiredForWrite = requiresL3Flush;
auto allocation = memoryManager->allocateGraphicsMemoryWithProperties(properties, surface.getMemoryPointer());
if (allocation == nullptr && surface.peekIsPtrCopyAllowed()) {

View File

@@ -90,6 +90,10 @@ void Context::overrideSpecialQueueAndDecrementRefCount(CommandQueue *commandQueu
this->decRefInternal();
};
bool Context::areMultiStorageAllocationsPreffered() {
return this->contextType != ContextType::CONTEXT_TYPE_SPECIALIZED;
}
bool Context::createImpl(const cl_context_properties *properties,
const DeviceVector &inputDevices,
void(CL_CALLBACK *funcNotify)(const char *, const void *, size_t, void *),

View File

@@ -122,6 +122,7 @@ class Context : public BaseObject<_cl_context> {
bool getInteropUserSyncEnabled() { return interopUserSync; }
void setInteropUserSyncEnabled(bool enabled) { interopUserSync = enabled; }
bool areMultiStorageAllocationsPreffered();
ContextType peekContextType() { return this->contextType; }

View File

@@ -162,7 +162,7 @@ bool Device::createDeviceImpl() {
}
AllocationProperties Device::getAllocationPropertiesForPreemption() const {
AllocationProperties properties{true, getHardwareInfo().capabilityTable.requiredPreemptionSurfaceSize, GraphicsAllocation::AllocationType::PREEMPTION};
AllocationProperties properties{true, getHardwareInfo().capabilityTable.requiredPreemptionSurfaceSize, GraphicsAllocation::AllocationType::PREEMPTION, false};
properties.flags.uncacheable = getWaTable()->waCSRUncachable;
properties.alignment = 256 * MemoryConstants::kiloByte;
return properties;

View File

@@ -214,7 +214,7 @@ Buffer *Buffer::create(Context *context,
}
if (!memory) {
AllocationProperties allocProperties = MemObjHelper::getAllocationProperties(properties, allocateMemory, size, allocationType);
AllocationProperties allocProperties = MemObjHelper::getAllocationProperties(properties, allocateMemory, size, allocationType, context->areMultiStorageAllocationsPreffered());
memory = memoryManager->allocateGraphicsMemoryWithProperties(allocProperties, hostPtr);
}
@@ -227,7 +227,7 @@ Buffer *Buffer::create(Context *context,
allocationType = GraphicsAllocation::AllocationType::BUFFER_HOST_MEMORY;
zeroCopyAllowed = false;
copyMemoryFromHostPtr = true;
AllocationProperties allocProperties = MemObjHelper::getAllocationProperties(properties, true, size, allocationType);
AllocationProperties allocProperties = MemObjHelper::getAllocationProperties(properties, true, size, allocationType, context->areMultiStorageAllocationsPreffered());
memory = memoryManager->allocateGraphicsMemoryWithProperties(allocProperties);
}

View File

@@ -264,12 +264,12 @@ Image *Image::create(Context *context,
}
} else {
gmm = new Gmm(imgInfo, StorageInfo{});
memory = memoryManager->allocateGraphicsMemoryWithProperties({false, imgInfo.size, GraphicsAllocation::AllocationType::SHARED_CONTEXT_IMAGE}, hostPtr);
memory = memoryManager->allocateGraphicsMemoryWithProperties({false, imgInfo.size, GraphicsAllocation::AllocationType::SHARED_CONTEXT_IMAGE, false}, hostPtr);
memory->setDefaultGmm(gmm);
zeroCopy = true;
}
if (memory) {
AllocationProperties properties{false, hostPtrMinSize, GraphicsAllocation::AllocationType::EXTERNAL_HOST_PTR};
AllocationProperties properties{false, hostPtrMinSize, GraphicsAllocation::AllocationType::EXTERNAL_HOST_PTR, false};
properties.flags.flushL3RequiredForRead = properties.flags.flushL3RequiredForWrite = true;
mapAllocation = memoryManager->allocateGraphicsMemoryWithProperties(properties, hostPtr);
}

View File

@@ -329,7 +329,7 @@ void *MemObj::getBasePtrForMap() {
} else {
auto memory = memoryManager->allocateSystemMemory(getSize(), MemoryConstants::pageSize);
setAllocatedMapPtr(memory);
AllocationProperties properties{false, getSize(), GraphicsAllocation::AllocationType::EXTERNAL_HOST_PTR};
AllocationProperties properties{false, getSize(), GraphicsAllocation::AllocationType::EXTERNAL_HOST_PTR, false};
auto allocation = memoryManager->allocateGraphicsMemoryWithProperties(properties, memory);
setMapAllocation(allocation);
return getAllocatedMapPtr();

View File

@@ -89,8 +89,8 @@ class MemObjHelper {
}
static AllocationProperties getAllocationProperties(MemoryProperties memoryProperties, bool allocateMemory,
size_t size, GraphicsAllocation::AllocationType type) {
AllocationProperties allocationProperties(allocateMemory, size, type);
size_t size, GraphicsAllocation::AllocationType type, bool multiStorageResource) {
AllocationProperties allocationProperties(allocateMemory, size, type, multiStorageResource);
fillPoliciesInProperties(allocationProperties, memoryProperties);
return allocationProperties;
}

View File

@@ -52,7 +52,7 @@ Pipe *Pipe::create(Context *context,
while (true) {
auto size = static_cast<size_t>(packetSize * (maxPackets + 1) + intelPipeHeaderReservedSpace);
AllocationProperties allocProperties =
MemObjHelper::getAllocationProperties(memoryProperties, true, size, GraphicsAllocation::AllocationType::PIPE);
MemObjHelper::getAllocationProperties(memoryProperties, true, size, GraphicsAllocation::AllocationType::PIPE, false);
GraphicsAllocation *memory = memoryManager->allocateGraphicsMemoryWithProperties(allocProperties);
if (!memory) {
errcodeRet = CL_OUT_OF_HOST_MEMORY;

View File

@@ -30,22 +30,26 @@ struct AllocationProperties {
GraphicsAllocation::AllocationType allocationType = GraphicsAllocation::AllocationType::UNKNOWN;
ImageInfo *imgInfo = nullptr;
uint32_t deviceIndex = AllocationProperties::noDeviceSpecified;
bool multiStorageResource = false;
AllocationProperties(size_t size,
GraphicsAllocation::AllocationType allocationType)
: AllocationProperties(true, size, allocationType) {}
: AllocationProperties(true, size, allocationType, false) {}
AllocationProperties(bool allocateMemory,
ImageInfo &imgInfo,
GraphicsAllocation::AllocationType allocationType)
: AllocationProperties(allocateMemory, 0u, allocationType) {
: AllocationProperties(allocateMemory, 0u, allocationType, false) {
this->imgInfo = &imgInfo;
}
AllocationProperties(bool allocateMemory,
size_t size,
GraphicsAllocation::AllocationType allocationType)
: AllocationProperties(allocateMemory, size, allocationType, false, AllocationProperties::noDeviceSpecified) {}
GraphicsAllocation::AllocationType allocationType,
bool isMultiStorageAllocation)
: AllocationProperties(allocateMemory, size, allocationType, false, AllocationProperties::noDeviceSpecified) {
this->multiStorageResource = isMultiStorageAllocation;
}
AllocationProperties(bool allocateMemory,
size_t size,

View File

@@ -94,7 +94,7 @@ void *SVMAllocsManager::createSVMAlloc(size_t size, const SvmAllocationPropertie
void *SVMAllocsManager::createUnifiedMemoryAllocation(size_t size, const UnifiedMemoryProperties svmProperties) {
size_t alignedSize = alignUp<size_t>(size, MemoryConstants::pageSize64k);
AllocationProperties unifiedMemoryProperties{true, alignedSize, GraphicsAllocation::AllocationType::BUFFER};
AllocationProperties unifiedMemoryProperties{true, alignedSize, GraphicsAllocation::AllocationType::BUFFER, false};
GraphicsAllocation *unifiedMemoryAllocation = memoryManager->allocateGraphicsMemoryWithProperties(unifiedMemoryProperties);
SvmAllocationData allocData;
@@ -126,7 +126,7 @@ void SVMAllocsManager::freeSVMAlloc(void *ptr) {
}
void *SVMAllocsManager::createZeroCopySvmAllocation(size_t size, const SvmAllocationProperties &svmProperties) {
AllocationProperties properties{true, size, GraphicsAllocation::AllocationType::SVM_ZERO_COPY};
AllocationProperties properties{true, size, GraphicsAllocation::AllocationType::SVM_ZERO_COPY, false};
MemObjHelper::fillCachePolicyInProperties(properties, false, svmProperties.readOnly, false);
GraphicsAllocation *allocation = memoryManager->allocateGraphicsMemoryWithProperties(properties);
if (!allocation) {
@@ -145,7 +145,7 @@ void *SVMAllocsManager::createZeroCopySvmAllocation(size_t size, const SvmAlloca
void *SVMAllocsManager::createSvmAllocationWithDeviceStorage(size_t size, const SvmAllocationProperties &svmProperties) {
size_t alignedSize = alignUp<size_t>(size, 2 * MemoryConstants::megaByte);
AllocationProperties cpuProperties{true, alignedSize, GraphicsAllocation::AllocationType::SVM_CPU};
AllocationProperties cpuProperties{true, alignedSize, GraphicsAllocation::AllocationType::SVM_CPU, false};
cpuProperties.alignment = 2 * MemoryConstants::megaByte;
MemObjHelper::fillCachePolicyInProperties(cpuProperties, false, svmProperties.readOnly, false);
GraphicsAllocation *allocationCpu = memoryManager->allocateGraphicsMemoryWithProperties(cpuProperties);
@@ -156,7 +156,7 @@ void *SVMAllocsManager::createSvmAllocationWithDeviceStorage(size_t size, const
allocationCpu->setCoherent(svmProperties.coherent);
void *svmPtr = allocationCpu->getUnderlyingBuffer();
AllocationProperties gpuProperties{false, alignedSize, GraphicsAllocation::AllocationType::SVM_GPU};
AllocationProperties gpuProperties{false, alignedSize, GraphicsAllocation::AllocationType::SVM_GPU, false};
gpuProperties.alignment = 2 * MemoryConstants::megaByte;
MemObjHelper::fillCachePolicyInProperties(gpuProperties, false, svmProperties.readOnly, false);
GraphicsAllocation *allocationGpu = memoryManager->allocateGraphicsMemoryWithProperties(gpuProperties, svmPtr);

View File

@@ -38,7 +38,7 @@ class D3DBuffer : public D3DSharing<D3D> {
}
sharingFcns->getSharedHandle(bufferStaging, &sharedHandle);
AllocationProperties properties = {false, 0, GraphicsAllocation::AllocationType::SHARED_BUFFER};
AllocationProperties properties = {false, 0, GraphicsAllocation::AllocationType::SHARED_BUFFER, false};
auto alloc = context->getMemoryManager()->createGraphicsAllocationFromSharedHandle((osHandle)((UINT_PTR)sharedHandle), properties, true);
auto d3dBufferObj = new D3DBuffer<D3D>(context, d3dBuffer, bufferStaging, sharedResource);

View File

@@ -79,7 +79,7 @@ Image *D3DSurface::create(Context *context, cl_dx9_surface_info_khr *surfaceInfo
GraphicsAllocation *alloc = nullptr;
if (surfaceInfo->shared_handle) {
isSharedResource = true;
AllocationProperties allocProperties(false, 0u, GraphicsAllocation::AllocationType::SHARED_IMAGE);
AllocationProperties allocProperties(false, 0u, GraphicsAllocation::AllocationType::SHARED_IMAGE, false);
alloc = context->getMemoryManager()->createGraphicsAllocationFromSharedHandle((osHandle)((UINT_PTR)surfaceInfo->shared_handle), allocProperties,
false);
updateImgInfo(alloc->getDefaultGmm(), imgInfo, imgDesc, oclPlane, 0u);

View File

@@ -68,7 +68,7 @@ Image *D3DTexture<D3D>::create2d(Context *context, D3DTexture2d *d3dTexture, cl_
alloc = context->getMemoryManager()->createGraphicsAllocationFromNTHandle(sharedHandle);
} else {
sharingFcns->getSharedHandle(textureStaging, &sharedHandle);
AllocationProperties allocProperties(nullptr, false, GraphicsAllocation::AllocationType::SHARED_IMAGE);
AllocationProperties allocProperties(nullptr, false, GraphicsAllocation::AllocationType::SHARED_IMAGE, false);
alloc = context->getMemoryManager()->createGraphicsAllocationFromSharedHandle((osHandle)((UINT_PTR)sharedHandle), allocProperties, false);
}
DEBUG_BREAK_IF(!alloc);
@@ -126,7 +126,7 @@ Image *D3DTexture<D3D>::create3d(Context *context, D3DTexture3d *d3dTexture, cl_
alloc = context->getMemoryManager()->createGraphicsAllocationFromNTHandle(sharedHandle);
} else {
sharingFcns->getSharedHandle(textureStaging, &sharedHandle);
AllocationProperties allocProperties(nullptr, false, GraphicsAllocation::AllocationType::SHARED_IMAGE);
AllocationProperties allocProperties(nullptr, false, GraphicsAllocation::AllocationType::SHARED_IMAGE, false);
alloc = context->getMemoryManager()->createGraphicsAllocationFromSharedHandle((osHandle)((UINT_PTR)sharedHandle), allocProperties, false);
}
DEBUG_BREAK_IF(!alloc);

View File

@@ -128,7 +128,7 @@ GraphicsAllocation *GlBuffer::createGraphicsAllocation(Context *context, unsigne
}
if (!graphicsAllocation) {
AllocationProperties properties = {false, 0, GraphicsAllocation::AllocationType::SHARED_BUFFER};
AllocationProperties properties = {false, 0, GraphicsAllocation::AllocationType::SHARED_BUFFER, false};
// couldn't find allocation for reuse - create new
graphicsAllocation =
context->getMemoryManager()->createGraphicsAllocationFromSharedHandle(bufferInfo.globalShareHandle, properties, true);

View File

@@ -45,7 +45,7 @@ Image *GlTexture::createSharedGlTexture(Context *context, cl_mem_flags flags, cl
errorCode.set(CL_SUCCESS);
AllocationProperties allocProperties(false, 0u, GraphicsAllocation::AllocationType::SHARED_IMAGE);
AllocationProperties allocProperties(false, 0u, GraphicsAllocation::AllocationType::SHARED_IMAGE, false);
auto alloc = memoryManager->createGraphicsAllocationFromSharedHandle(texInfo.globalShareHandle, allocProperties, false);
if (alloc == nullptr) {