mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-05 09:09:04 +08:00
Extend specialQueue in context to StackVec
Related-To: NEO-4589 Change-Id: I92db4cf8511e13a35307a4f48b51041a6fc7330f Signed-off-by: Krzysztof Gibala <krzysztof.gibala@intel.com>
This commit is contained in:
committed by
sys_ocldev
parent
430cca3f4c
commit
2c1551d40d
@@ -3678,7 +3678,7 @@ void *clSharedMemAllocINTEL(
|
||||
err.set(CL_INVALID_BUFFER_SIZE);
|
||||
return nullptr;
|
||||
}
|
||||
auto ptr = neoContext->getSVMAllocsManager()->createSharedUnifiedMemoryAllocation(neoDevice->getRootDeviceIndex(), size, unifiedMemoryProperties, neoContext->getSpecialQueue());
|
||||
auto ptr = neoContext->getSVMAllocsManager()->createSharedUnifiedMemoryAllocation(neoDevice->getRootDeviceIndex(), size, unifiedMemoryProperties, neoContext->getSpecialQueue(neoDevice->getRootDeviceIndex()));
|
||||
if (!ptr) {
|
||||
err.set(CL_OUT_OF_RESOURCES);
|
||||
}
|
||||
|
||||
@@ -49,8 +49,11 @@ Context::Context(
|
||||
|
||||
Context::~Context() {
|
||||
delete[] properties;
|
||||
if (specialQueue) {
|
||||
delete specialQueue;
|
||||
|
||||
for (auto rootDeviceIndex = 0u; rootDeviceIndex < specialQueues.size(); rootDeviceIndex++) {
|
||||
if (specialQueues[rootDeviceIndex]) {
|
||||
delete specialQueues[rootDeviceIndex];
|
||||
}
|
||||
}
|
||||
if (svmAllocsManager) {
|
||||
delete svmAllocsManager;
|
||||
@@ -100,15 +103,15 @@ void Context::setDefaultDeviceQueue(DeviceQueue *queue) {
|
||||
defaultDeviceQueue = queue;
|
||||
}
|
||||
|
||||
CommandQueue *Context::getSpecialQueue() {
|
||||
return specialQueue;
|
||||
CommandQueue *Context::getSpecialQueue(uint32_t rootDeviceIndex) {
|
||||
return specialQueues[rootDeviceIndex];
|
||||
}
|
||||
|
||||
void Context::setSpecialQueue(CommandQueue *commandQueue) {
|
||||
specialQueue = commandQueue;
|
||||
void Context::setSpecialQueue(CommandQueue *commandQueue, uint32_t rootDeviceIndex) {
|
||||
specialQueues[rootDeviceIndex] = commandQueue;
|
||||
}
|
||||
void Context::overrideSpecialQueueAndDecrementRefCount(CommandQueue *commandQueue) {
|
||||
setSpecialQueue(commandQueue);
|
||||
void Context::overrideSpecialQueueAndDecrementRefCount(CommandQueue *commandQueue, uint32_t rootDeviceIndex) {
|
||||
setSpecialQueue(commandQueue, rootDeviceIndex);
|
||||
commandQueue->setIsSpecialCommandQueue(true);
|
||||
//decrement ref count that special queue added
|
||||
this->decRefInternal();
|
||||
@@ -197,7 +200,7 @@ bool Context::createImpl(const cl_context_properties *properties,
|
||||
return false;
|
||||
}
|
||||
|
||||
this->devices = inputDevices;
|
||||
devices = inputDevices;
|
||||
for (auto &rootDeviceIndex : rootDeviceIndices) {
|
||||
DeviceBitfield deviceBitfield{};
|
||||
for (const auto &pDevice : devices) {
|
||||
@@ -210,6 +213,7 @@ bool Context::createImpl(const cl_context_properties *properties,
|
||||
|
||||
if (devices.size() > 0) {
|
||||
maxRootDeviceIndex = *std::max_element(rootDeviceIndices.begin(), rootDeviceIndices.end(), std::less<uint32_t const>());
|
||||
specialQueues.resize(maxRootDeviceIndex + 1u);
|
||||
auto device = this->getDevice(0);
|
||||
this->memoryManager = device->getMemoryManager();
|
||||
if (memoryManager->isAsyncDeleterEnabled()) {
|
||||
@@ -228,9 +232,13 @@ bool Context::createImpl(const cl_context_properties *properties,
|
||||
setupContextType();
|
||||
}
|
||||
|
||||
auto commandQueue = CommandQueue::create(this, devices[0], nullptr, true, errcodeRet);
|
||||
DEBUG_BREAK_IF(commandQueue == nullptr);
|
||||
overrideSpecialQueueAndDecrementRefCount(commandQueue);
|
||||
for (auto &device : devices) {
|
||||
if (!specialQueues[device->getRootDeviceIndex()]) {
|
||||
auto commandQueue = CommandQueue::create(this, device, nullptr, true, errcodeRet); // NOLINT
|
||||
DEBUG_BREAK_IF(commandQueue == nullptr);
|
||||
overrideSpecialQueueAndDecrementRefCount(commandQueue, device->getRootDeviceIndex());
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -98,9 +98,9 @@ class Context : public BaseObject<_cl_context> {
|
||||
DeviceQueue *getDefaultDeviceQueue();
|
||||
void setDefaultDeviceQueue(DeviceQueue *queue);
|
||||
|
||||
CommandQueue *getSpecialQueue();
|
||||
void setSpecialQueue(CommandQueue *commandQueue);
|
||||
void overrideSpecialQueueAndDecrementRefCount(CommandQueue *commandQueue);
|
||||
CommandQueue *getSpecialQueue(uint32_t rootDeviceIndex);
|
||||
void setSpecialQueue(CommandQueue *commandQueue, uint32_t rootDeviceIndex);
|
||||
void overrideSpecialQueueAndDecrementRefCount(CommandQueue *commandQueue, uint32_t rootDeviceIndex);
|
||||
|
||||
template <typename Sharing>
|
||||
Sharing *getSharing();
|
||||
@@ -194,7 +194,7 @@ class Context : public BaseObject<_cl_context> {
|
||||
void *userData = nullptr;
|
||||
MemoryManager *memoryManager = nullptr;
|
||||
SVMAllocsManager *svmAllocsManager = nullptr;
|
||||
CommandQueue *specialQueue = nullptr;
|
||||
StackVec<CommandQueue *, 1> specialQueues;
|
||||
DeviceQueue *defaultDeviceQueue = nullptr;
|
||||
DriverDiagnostics *driverDiagnostics = nullptr;
|
||||
|
||||
|
||||
@@ -383,7 +383,7 @@ Buffer *Buffer::create(Context *context,
|
||||
auto blitMemoryToAllocationResult = BlitHelperFunctions::blitMemoryToAllocation(pBuffer->getContext()->getDevice(rootDeviceIndex)->getDevice(), allocationInfo[rootDeviceIndex].memory, pBuffer->getOffset(), hostPtr, {size, 1, 1});
|
||||
|
||||
if (blitMemoryToAllocationResult != BlitOperationResult::Success) {
|
||||
auto cmdQ = context->getSpecialQueue();
|
||||
auto cmdQ = context->getSpecialQueue(rootDeviceIndex);
|
||||
if (CL_SUCCESS != cmdQ->enqueueWriteBuffer(pBuffer, CL_TRUE, 0, size, hostPtr, allocationInfo[rootDeviceIndex].mapAllocation, 0, nullptr, nullptr)) {
|
||||
errcodeRet = CL_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
@@ -402,10 +402,10 @@ Image *Image::create(Context *context,
|
||||
}
|
||||
|
||||
if (!imgInfo.linearStorage || !MemoryPool::isSystemMemoryPool(memory->getMemoryPool())) {
|
||||
auto cmdQ = context->getSpecialQueue();
|
||||
auto cmdQ = context->getSpecialQueue(rootDeviceIndex);
|
||||
|
||||
if (IsNV12Image(&image->getImageFormat())) {
|
||||
errcodeRet = image->writeNV12Planes(hostPtr, hostPtrRowPitch);
|
||||
errcodeRet = image->writeNV12Planes(hostPtr, hostPtrRowPitch, rootDeviceIndex);
|
||||
} else {
|
||||
errcodeRet = cmdQ->enqueueWriteImage(image, CL_TRUE, ©Origin[0], ©Region[0],
|
||||
hostPtrRowPitch, hostPtrSlicePitch,
|
||||
@@ -1022,8 +1022,8 @@ void Image::transferDataFromHostPtr(MemObjSizeArray ©Size, MemObjOffsetArray
|
||||
copySize, copyOffset);
|
||||
}
|
||||
|
||||
cl_int Image::writeNV12Planes(const void *hostPtr, size_t hostPtrRowPitch) {
|
||||
CommandQueue *cmdQ = context->getSpecialQueue();
|
||||
cl_int Image::writeNV12Planes(const void *hostPtr, size_t hostPtrRowPitch, uint32_t rootDeviceIndex) {
|
||||
CommandQueue *cmdQ = context->getSpecialQueue(rootDeviceIndex);
|
||||
size_t origin[3] = {0, 0, 0};
|
||||
size_t region[3] = {this->imageDesc.image_width, this->imageDesc.image_height, 1};
|
||||
|
||||
|
||||
@@ -183,7 +183,7 @@ class Image : public MemObj {
|
||||
static const ClSurfaceFormatInfo *getSurfaceFormatFromTable(cl_mem_flags flags, const cl_image_format *imageFormat, bool supportsOcl20Features);
|
||||
static cl_int validateRegionAndOrigin(const size_t *origin, const size_t *region, const cl_image_desc &imgDesc);
|
||||
|
||||
cl_int writeNV12Planes(const void *hostPtr, size_t hostPtrRowPitch);
|
||||
cl_int writeNV12Planes(const void *hostPtr, size_t hostPtrRowPitch, uint32_t rootDeviceIndex);
|
||||
void setMcsSurfaceInfo(const McsSurfaceInfo &info) { mcsSurfaceInfo = info; }
|
||||
const McsSurfaceInfo &getMcsSurfaceInfo() { return mcsSurfaceInfo; }
|
||||
size_t calculateOffsetForMapping(const MemObjOffsetArray &origin) const override;
|
||||
|
||||
Reference in New Issue
Block a user