mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-03 14:55:24 +08:00
Return "OUT_OF_MEMORY" when gfx alloc on device fails during cmdqueue create
Signed-off-by: Vinod Tipparaju <vinod.tipparaju@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
4c5ff75371
commit
f553e1e514
@@ -101,11 +101,10 @@ CommandList *CommandList::createImmediate(uint32_t productFamily, Device *device
|
||||
|
||||
UNRECOVERABLE_IF(nullptr == csr);
|
||||
|
||||
auto commandQueue = CommandQueue::create(productFamily, device, csr, desc, NEO::EngineGroupType::Copy == engineGroupType);
|
||||
auto commandQueue = CommandQueue::create(productFamily, device, csr, desc, NEO::EngineGroupType::Copy == engineGroupType, returnValue);
|
||||
if (!commandQueue) {
|
||||
commandList->destroy();
|
||||
commandList = nullptr;
|
||||
returnValue = ZE_RESULT_ERROR_UNINITIALIZED;
|
||||
return commandList;
|
||||
}
|
||||
|
||||
|
||||
@@ -28,14 +28,20 @@ ze_result_t CommandQueueImp::destroy() {
|
||||
return ZE_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
void CommandQueueImp::initialize(bool copyOnly) {
|
||||
buffers.initialize(device, totalCmdBufferSize);
|
||||
NEO::GraphicsAllocation *bufferAllocation = buffers.getCurrentBufferAllocation();
|
||||
commandStream = new NEO::LinearStream(bufferAllocation->getUnderlyingBuffer(),
|
||||
defaultQueueCmdBufferSize);
|
||||
UNRECOVERABLE_IF(commandStream == nullptr);
|
||||
commandStream->replaceGraphicsAllocation(bufferAllocation);
|
||||
isCopyOnlyCommandQueue = copyOnly;
|
||||
ze_result_t CommandQueueImp::initialize(bool copyOnly) {
|
||||
ze_result_t returnValue;
|
||||
returnValue = buffers.initialize(device, totalCmdBufferSize);
|
||||
if (returnValue == ZE_RESULT_SUCCESS) {
|
||||
NEO::GraphicsAllocation *bufferAllocation = buffers.getCurrentBufferAllocation();
|
||||
commandStream = new NEO::LinearStream(bufferAllocation->getUnderlyingBuffer(),
|
||||
defaultQueueCmdBufferSize);
|
||||
if (!commandStream) {
|
||||
return ZE_RESULT_ERROR_OUT_OF_DEVICE_MEMORY;
|
||||
}
|
||||
commandStream->replaceGraphicsAllocation(bufferAllocation);
|
||||
isCopyOnlyCommandQueue = copyOnly;
|
||||
}
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
void CommandQueueImp::reserveLinearStreamSize(size_t size) {
|
||||
@@ -99,17 +105,22 @@ void CommandQueueImp::printFunctionsPrintfOutput() {
|
||||
}
|
||||
|
||||
CommandQueue *CommandQueue::create(uint32_t productFamily, Device *device, NEO::CommandStreamReceiver *csr,
|
||||
const ze_command_queue_desc_t *desc, bool isCopyOnly) {
|
||||
const ze_command_queue_desc_t *desc, bool isCopyOnly, ze_result_t &returnValue) {
|
||||
CommandQueueAllocatorFn allocator = nullptr;
|
||||
if (productFamily < IGFX_MAX_PRODUCT) {
|
||||
allocator = commandQueueFactory[productFamily];
|
||||
}
|
||||
|
||||
CommandQueueImp *commandQueue = nullptr;
|
||||
returnValue = ZE_RESULT_ERROR_UNINITIALIZED;
|
||||
|
||||
if (allocator) {
|
||||
commandQueue = static_cast<CommandQueueImp *>((*allocator)(device, csr, desc));
|
||||
|
||||
commandQueue->initialize(isCopyOnly);
|
||||
returnValue = commandQueue->initialize(isCopyOnly);
|
||||
if (returnValue != ZE_RESULT_SUCCESS) {
|
||||
commandQueue->destroy();
|
||||
commandQueue = nullptr;
|
||||
}
|
||||
}
|
||||
return commandQueue;
|
||||
}
|
||||
@@ -118,7 +129,7 @@ ze_command_queue_mode_t CommandQueueImp::getSynchronousMode() {
|
||||
return desc.mode;
|
||||
}
|
||||
|
||||
void CommandQueueImp::CommandBufferManager::initialize(Device *device, size_t sizeRequested) {
|
||||
ze_result_t CommandQueueImp::CommandBufferManager::initialize(Device *device, size_t sizeRequested) {
|
||||
size_t alignedSize = alignUp<size_t>(sizeRequested, MemoryConstants::pageSize64k);
|
||||
NEO::AllocationProperties properties{device->getRootDeviceIndex(), true, alignedSize,
|
||||
NEO::GraphicsAllocation::AllocationType::COMMAND_BUFFER,
|
||||
@@ -127,21 +138,28 @@ void CommandQueueImp::CommandBufferManager::initialize(Device *device, size_t si
|
||||
CommonConstants::allDevicesBitfield};
|
||||
|
||||
buffers[BUFFER_ALLOCATION::FIRST] = device->getNEODevice()->getMemoryManager()->allocateGraphicsMemoryWithProperties(properties);
|
||||
|
||||
UNRECOVERABLE_IF(nullptr == buffers[BUFFER_ALLOCATION::FIRST]);
|
||||
memset(buffers[BUFFER_ALLOCATION::FIRST]->getUnderlyingBuffer(), 0, buffers[BUFFER_ALLOCATION::FIRST]->getUnderlyingBufferSize());
|
||||
|
||||
buffers[BUFFER_ALLOCATION::SECOND] = device->getNEODevice()->getMemoryManager()->allocateGraphicsMemoryWithProperties(properties);
|
||||
|
||||
UNRECOVERABLE_IF(nullptr == buffers[BUFFER_ALLOCATION::SECOND]);
|
||||
if (!buffers[BUFFER_ALLOCATION::FIRST] || !buffers[BUFFER_ALLOCATION::SECOND]) {
|
||||
return ZE_RESULT_ERROR_OUT_OF_DEVICE_MEMORY;
|
||||
}
|
||||
|
||||
memset(buffers[BUFFER_ALLOCATION::FIRST]->getUnderlyingBuffer(), 0, buffers[BUFFER_ALLOCATION::FIRST]->getUnderlyingBufferSize());
|
||||
memset(buffers[BUFFER_ALLOCATION::SECOND]->getUnderlyingBuffer(), 0, buffers[BUFFER_ALLOCATION::SECOND]->getUnderlyingBufferSize());
|
||||
flushId[BUFFER_ALLOCATION::FIRST] = 0u;
|
||||
flushId[BUFFER_ALLOCATION::SECOND] = 0u;
|
||||
return ZE_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
void CommandQueueImp::CommandBufferManager::destroy(NEO::MemoryManager *memoryManager) {
|
||||
memoryManager->freeGraphicsMemory(buffers[BUFFER_ALLOCATION::FIRST]);
|
||||
memoryManager->freeGraphicsMemory(buffers[BUFFER_ALLOCATION::SECOND]);
|
||||
if (buffers[BUFFER_ALLOCATION::FIRST]) {
|
||||
memoryManager->freeGraphicsMemory(buffers[BUFFER_ALLOCATION::FIRST]);
|
||||
buffers[BUFFER_ALLOCATION::FIRST] = nullptr;
|
||||
}
|
||||
if (buffers[BUFFER_ALLOCATION::SECOND]) {
|
||||
memoryManager->freeGraphicsMemory(buffers[BUFFER_ALLOCATION::SECOND]);
|
||||
buffers[BUFFER_ALLOCATION::SECOND] = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void CommandQueueImp::CommandBufferManager::switchBuffers(NEO::CommandStreamReceiver *csr) {
|
||||
|
||||
@@ -41,7 +41,7 @@ struct CommandQueue : _ze_command_queue_handle_t {
|
||||
virtual ze_result_t synchronize(uint64_t timeout) = 0;
|
||||
|
||||
static CommandQueue *create(uint32_t productFamily, Device *device, NEO::CommandStreamReceiver *csr,
|
||||
const ze_command_queue_desc_t *desc, bool isCopyOnly);
|
||||
const ze_command_queue_desc_t *desc, bool isCopyOnly, ze_result_t &resultValue);
|
||||
|
||||
static CommandQueue *fromHandle(ze_command_queue_handle_t handle) {
|
||||
return static_cast<CommandQueue *>(handle);
|
||||
|
||||
@@ -49,7 +49,10 @@ ze_result_t CommandQueueHw<gfxCoreFamily>::createFence(const ze_fence_desc_t *de
|
||||
template <GFXCORE_FAMILY gfxCoreFamily>
|
||||
ze_result_t CommandQueueHw<gfxCoreFamily>::destroy() {
|
||||
this->printFunctionsPrintfOutput();
|
||||
delete commandStream;
|
||||
if (commandStream) {
|
||||
delete commandStream;
|
||||
commandStream = nullptr;
|
||||
}
|
||||
buffers.destroy(this->getDevice()->getNEODevice()->getMemoryManager());
|
||||
delete this;
|
||||
return ZE_RESULT_SUCCESS;
|
||||
|
||||
@@ -35,7 +35,7 @@ struct CommandQueueImp : public CommandQueue {
|
||||
COUNT
|
||||
};
|
||||
|
||||
void initialize(Device *device, size_t sizeRequested);
|
||||
ze_result_t initialize(Device *device, size_t sizeRequested);
|
||||
void destroy(NEO::MemoryManager *memoryManager);
|
||||
void switchBuffers(NEO::CommandStreamReceiver *csr);
|
||||
|
||||
@@ -69,7 +69,7 @@ struct CommandQueueImp : public CommandQueue {
|
||||
|
||||
ze_result_t synchronize(uint64_t timeout) override;
|
||||
|
||||
void initialize(bool copyOnly);
|
||||
ze_result_t initialize(bool copyOnly);
|
||||
|
||||
Device *getDevice() { return device; }
|
||||
|
||||
|
||||
@@ -116,9 +116,10 @@ ze_result_t DeviceImp::createCommandQueue(const ze_command_queue_desc_t *desc,
|
||||
|
||||
UNRECOVERABLE_IF(csr == nullptr);
|
||||
|
||||
*commandQueue = CommandQueue::create(productFamily, this, csr, desc, NEO::EngineGroupType::Copy == static_cast<NEO::EngineGroupType>(engineGroupIndex));
|
||||
ze_result_t returnValue = ZE_RESULT_SUCCESS;
|
||||
*commandQueue = CommandQueue::create(productFamily, this, csr, desc, NEO::EngineGroupType::Copy == static_cast<NEO::EngineGroupType>(engineGroupIndex), returnValue);
|
||||
|
||||
return ZE_RESULT_SUCCESS;
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
ze_result_t DeviceImp::getCommandQueueGroupProperties(uint32_t *pCount,
|
||||
|
||||
Reference in New Issue
Block a user