mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-03 14:55:24 +08:00
Add additional create buffer arguments
Allow to: disable performance hints, make allocation lockable Used in BufferPoolAllocator Related-To: NEO-7332 Signed-off-by: Dominik Dabek <dominik.dabek@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
50df7f430e
commit
67bfebb25e
@@ -170,9 +170,20 @@ Buffer *Buffer::create(Context *context,
|
||||
cl_mem_flags flags,
|
||||
size_t size,
|
||||
void *hostPtr,
|
||||
AdditionalBufferCreateArgs &bufferCreateArgs,
|
||||
cl_int &errcodeRet) {
|
||||
return create(context, ClMemoryPropertiesHelper::createMemoryProperties(flags, 0, 0, &context->getDevice(0)->getDevice()),
|
||||
flags, 0, size, hostPtr, errcodeRet);
|
||||
flags, 0, size, hostPtr, bufferCreateArgs, errcodeRet);
|
||||
}
|
||||
|
||||
Buffer *Buffer::create(Context *context,
|
||||
cl_mem_flags flags,
|
||||
size_t size,
|
||||
void *hostPtr,
|
||||
cl_int &errcodeRet) {
|
||||
AdditionalBufferCreateArgs bufferCreateArgs{};
|
||||
return create(context, ClMemoryPropertiesHelper::createMemoryProperties(flags, 0, 0, &context->getDevice(0)->getDevice()),
|
||||
flags, 0, size, hostPtr, bufferCreateArgs, errcodeRet);
|
||||
}
|
||||
|
||||
bool inline copyHostPointer(Buffer *buffer,
|
||||
@@ -233,6 +244,18 @@ Buffer *Buffer::create(Context *context,
|
||||
size_t size,
|
||||
void *hostPtr,
|
||||
cl_int &errcodeRet) {
|
||||
AdditionalBufferCreateArgs bufferCreateArgs{};
|
||||
return create(context, memoryProperties, flags, flagsIntel, size, hostPtr, bufferCreateArgs, errcodeRet);
|
||||
}
|
||||
|
||||
Buffer *Buffer::create(Context *context,
|
||||
const MemoryProperties &memoryProperties,
|
||||
cl_mem_flags flags,
|
||||
cl_mem_flags_intel flagsIntel,
|
||||
size_t size,
|
||||
void *hostPtr,
|
||||
AdditionalBufferCreateArgs &bufferCreateArgs,
|
||||
cl_int &errcodeRet) {
|
||||
|
||||
errcodeRet = CL_SUCCESS;
|
||||
Context::BufferPoolAllocator &bufferPoolAllocator = context->getBufferPoolAllocator();
|
||||
@@ -355,7 +378,7 @@ Buffer *Buffer::create(Context *context,
|
||||
allocationInfo.allocateMemory = false;
|
||||
}
|
||||
|
||||
if (hostPtr && context->isProvidingPerformanceHints()) {
|
||||
if (!bufferCreateArgs.doNotProvidePerformanceHints && hostPtr && context->isProvidingPerformanceHints()) {
|
||||
if (allocationInfo.zeroCopyAllowed) {
|
||||
context->providePerformanceHint(CL_CONTEXT_DIAGNOSTICS_LEVEL_GOOD_INTEL, CL_BUFFER_MEETS_ALIGNMENT_RESTRICTIONS, hostPtr, size);
|
||||
} else {
|
||||
@@ -367,7 +390,7 @@ Buffer *Buffer::create(Context *context,
|
||||
allocationInfo.zeroCopyAllowed = false;
|
||||
}
|
||||
|
||||
if (allocationInfo.allocateMemory && context->isProvidingPerformanceHints()) {
|
||||
if (!bufferCreateArgs.doNotProvidePerformanceHints && allocationInfo.allocateMemory && context->isProvidingPerformanceHints()) {
|
||||
context->providePerformanceHint(CL_CONTEXT_DIAGNOSTICS_LEVEL_GOOD_INTEL, CL_BUFFER_NEEDS_ALLOCATE_MEMORY);
|
||||
}
|
||||
|
||||
@@ -381,6 +404,7 @@ Buffer *Buffer::create(Context *context,
|
||||
*hwInfo, context->getDeviceBitfieldForAllocation(rootDeviceIndex), context->isSingleDeviceContext());
|
||||
allocProperties.flags.crossRootDeviceAccess = context->getRootDeviceIndices().size() > 1;
|
||||
allocProperties.flags.preferCompressed = compressionEnabled;
|
||||
allocProperties.makeDeviceBufferLockable = bufferCreateArgs.makeAllocationLockable;
|
||||
|
||||
if (allocationCpuPtr) {
|
||||
allocationInfo.memory = memoryManager->createGraphicsAllocationFromExistingStorage(allocProperties, allocationCpuPtr, multiGraphicsAllocation);
|
||||
|
||||
@@ -57,6 +57,10 @@ extern ValidateInputAndCreateBufferFunc validateInputAndCreateBuffer;
|
||||
|
||||
class Buffer : public MemObj {
|
||||
public:
|
||||
struct AdditionalBufferCreateArgs {
|
||||
bool doNotProvidePerformanceHints;
|
||||
bool makeAllocationLockable;
|
||||
};
|
||||
constexpr static size_t maxBufferSizeForReadWriteOnCpu = 10 * MB;
|
||||
constexpr static size_t maxBufferSizeForCopyOnCpu = 64 * KB;
|
||||
constexpr static cl_ulong maskMagic = 0xFFFFFFFFFFFFFFFFLL;
|
||||
@@ -80,6 +84,13 @@ class Buffer : public MemObj {
|
||||
void *hostPtr,
|
||||
cl_int &errcodeRet);
|
||||
|
||||
static Buffer *create(Context *context,
|
||||
cl_mem_flags flags,
|
||||
size_t size,
|
||||
void *hostPtr,
|
||||
AdditionalBufferCreateArgs &bufferCreateArgs,
|
||||
cl_int &errcodeRet);
|
||||
|
||||
static Buffer *create(Context *context,
|
||||
const MemoryProperties &properties,
|
||||
cl_mem_flags flags,
|
||||
@@ -88,6 +99,15 @@ class Buffer : public MemObj {
|
||||
void *hostPtr,
|
||||
cl_int &errcodeRet);
|
||||
|
||||
static Buffer *create(Context *context,
|
||||
const MemoryProperties &properties,
|
||||
cl_mem_flags flags,
|
||||
cl_mem_flags_intel flagsIntel,
|
||||
size_t size,
|
||||
void *hostPtr,
|
||||
AdditionalBufferCreateArgs &bufferCreateArgs,
|
||||
cl_int &errcodeRet);
|
||||
|
||||
static Buffer *createSharedBuffer(Context *context,
|
||||
cl_mem_flags flags,
|
||||
SharingHandler *sharingHandler,
|
||||
|
||||
Reference in New Issue
Block a user