mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-08 05:56:36 +08:00
Allocate non USE_HOST_PTR and non-buffer images in preferred pool.
Change-Id: Ia486c7b32932202162d6587d06dc61023e38fff6
This commit is contained in:
committed by
sys_ocldev
parent
883822ccee
commit
a31c446d9f
@@ -10,6 +10,7 @@
|
||||
#include "runtime/event/event.h"
|
||||
#include "runtime/event/hw_timestamps.h"
|
||||
#include "runtime/event/perf_counter.h"
|
||||
#include "runtime/gmm_helper/gmm.h"
|
||||
#include "runtime/helpers/aligned_memory.h"
|
||||
#include "runtime/helpers/basic_math.h"
|
||||
#include "runtime/helpers/kernel_commands.h"
|
||||
@@ -273,6 +274,7 @@ bool MemoryManager::getAllocationData(AllocationData &allocationData, const Allo
|
||||
allocationData.type = properties.allocationType;
|
||||
allocationData.devicesBitfield = devicesBitfield;
|
||||
allocationData.alignment = properties.alignment ? properties.alignment : MemoryConstants::preferredAlignment;
|
||||
allocationData.imgInfo = properties.imgInfo;
|
||||
|
||||
if (allocationData.flags.allocateMemory) {
|
||||
allocationData.hostPtr = nullptr;
|
||||
@@ -285,7 +287,7 @@ GraphicsAllocation *MemoryManager::allocateGraphicsMemoryInPreferredPool(Allocat
|
||||
AllocationStatus status = AllocationStatus::Error;
|
||||
|
||||
getAllocationData(allocationData, properties, devicesBitfield, hostPtr);
|
||||
UNRECOVERABLE_IF(allocationData.type == GraphicsAllocation::AllocationType::IMAGE || allocationData.type == GraphicsAllocation::AllocationType::SHARED_RESOURCE);
|
||||
UNRECOVERABLE_IF(allocationData.type == GraphicsAllocation::AllocationType::SHARED_RESOURCE);
|
||||
GraphicsAllocation *allocation = nullptr;
|
||||
|
||||
allocation = allocateGraphicsMemoryInDevicePool(allocationData, status);
|
||||
@@ -295,10 +297,16 @@ GraphicsAllocation *MemoryManager::allocateGraphicsMemoryInPreferredPool(Allocat
|
||||
if (allocation) {
|
||||
allocation->setAllocationType(properties.allocationType);
|
||||
}
|
||||
|
||||
return allocation;
|
||||
}
|
||||
|
||||
GraphicsAllocation *MemoryManager::allocateGraphicsMemory(const AllocationData &allocationData) {
|
||||
if (allocationData.type == GraphicsAllocation::AllocationType::IMAGE) {
|
||||
UNRECOVERABLE_IF(allocationData.imgInfo == nullptr);
|
||||
return allocateGraphicsMemoryForImage(*allocationData.imgInfo, allocationData.hostPtr);
|
||||
}
|
||||
|
||||
if (force32bitAllocations && allocationData.flags.allow32Bit && is64bit) {
|
||||
return allocate32BitGraphicsMemory(allocationData.size, allocationData.hostPtr, AllocationOrigin::EXTERNAL_ALLOCATION);
|
||||
}
|
||||
|
||||
@@ -17,12 +17,15 @@
|
||||
#include <vector>
|
||||
|
||||
namespace OCLRT {
|
||||
class CommandStreamReceiver;
|
||||
class DeferredDeleter;
|
||||
class ExecutionEnvironment;
|
||||
class Gmm;
|
||||
class GraphicsAllocation;
|
||||
class HostPtrManager;
|
||||
class CommandStreamReceiver;
|
||||
class OsContext;
|
||||
struct ImageInfo;
|
||||
|
||||
enum class PreemptionMode : uint32_t;
|
||||
|
||||
using CsrContainer = std::vector<std::array<std::unique_ptr<CommandStreamReceiver>, EngineInstanceConstants::numGpgpuEngineInstances>>;
|
||||
@@ -54,6 +57,7 @@ struct AllocationProperties {
|
||||
size_t size = 0;
|
||||
size_t alignment = 0;
|
||||
GraphicsAllocation::AllocationType allocationType = GraphicsAllocation::AllocationType::UNKNOWN;
|
||||
ImageInfo *imgInfo = nullptr;
|
||||
|
||||
AllocationProperties(size_t size, GraphicsAllocation::AllocationType allocationType) : AllocationProperties(true, size, allocationType) {}
|
||||
AllocationProperties(bool allocateMemory, size_t size, GraphicsAllocation::AllocationType allocationType) : size(size), allocationType(allocationType) {
|
||||
@@ -62,6 +66,13 @@ struct AllocationProperties {
|
||||
flags.flushL3RequiredForWrite = 1;
|
||||
flags.allocateMemory = allocateMemory;
|
||||
}
|
||||
AllocationProperties(ImageInfo *imgInfo) : allocationType(GraphicsAllocation::AllocationType::IMAGE) {
|
||||
allFlags = 0;
|
||||
flags.flushL3RequiredForRead = 1;
|
||||
flags.flushL3RequiredForWrite = 1;
|
||||
flags.allocateMemory = 1;
|
||||
this->imgInfo = imgInfo;
|
||||
}
|
||||
};
|
||||
|
||||
struct AlignedMallocRestrictions {
|
||||
@@ -70,9 +81,6 @@ struct AlignedMallocRestrictions {
|
||||
|
||||
constexpr size_t paddingBufferSize = 2 * MemoryConstants::megaByte;
|
||||
|
||||
class Gmm;
|
||||
struct ImageInfo;
|
||||
|
||||
class MemoryManager {
|
||||
public:
|
||||
enum AllocationStatus {
|
||||
@@ -114,8 +122,6 @@ class MemoryManager {
|
||||
|
||||
virtual GraphicsAllocation *allocateGraphicsMemoryForImage(ImageInfo &imgInfo, const void *hostPtr) = 0;
|
||||
|
||||
GraphicsAllocation *allocateGraphicsMemoryForImageFromHostPtr(ImageInfo &imgInfo, const void *hostPtr);
|
||||
|
||||
GraphicsAllocation *allocateGraphicsMemoryInPreferredPool(AllocationProperties properties, DevicesBitfield devicesBitfield, const void *hostPtr);
|
||||
|
||||
virtual GraphicsAllocation *createGraphicsAllocationFromSharedHandle(osHandle handle, bool requireSpecificBitness) = 0;
|
||||
@@ -213,6 +219,7 @@ class MemoryManager {
|
||||
size_t size = 0;
|
||||
size_t alignment = 0;
|
||||
DevicesBitfield devicesBitfield = 0;
|
||||
ImageInfo *imgInfo = nullptr;
|
||||
};
|
||||
|
||||
static bool getAllocationData(AllocationData &allocationData, const AllocationProperties &properties, const DevicesBitfield devicesBitfield,
|
||||
@@ -237,6 +244,7 @@ class MemoryManager {
|
||||
status = AllocationStatus::RetryInNonDevicePool;
|
||||
return nullptr;
|
||||
}
|
||||
GraphicsAllocation *allocateGraphicsMemoryForImageFromHostPtr(ImageInfo &imgInfo, const void *hostPtr);
|
||||
|
||||
bool force32bitAllocations = false;
|
||||
bool virtualPaddingAvailable = false;
|
||||
|
||||
Reference in New Issue
Block a user