Create function to get proper CSR

Add function getCommandStreamReceiverByCommandType to get
GpgpuCommandStreamReceiver or BcsCommandStreamReceiver
according to given cmdType.

Related-To: NEO-4013
Change-Id: I16385ada79fe9048cdf9b14a6c5a18652fb788b1
Signed-off-by: Krzysztof Gibala <krzysztof.gibala@intel.com>
This commit is contained in:
Krzysztof Gibala
2020-04-21 12:04:47 +02:00
committed by sys_ocldev
parent 9a0764d422
commit d5e34d2d10
8 changed files with 39 additions and 11 deletions

View File

@@ -118,6 +118,15 @@ CommandStreamReceiver *CommandQueue::getBcsCommandStreamReceiver() const {
return nullptr;
}
CommandStreamReceiver &CommandQueue::getCommandStreamReceiverByCommandType(cl_command_type cmdType) const {
if (blitEnqueueAllowed(cmdType)) {
auto csr = getBcsCommandStreamReceiver();
UNRECOVERABLE_IF(!csr);
return *csr;
}
return getGpgpuCommandStreamReceiver();
}
Device &CommandQueue::getDevice() const noexcept {
return device->getDevice();
}

View File

@@ -222,6 +222,7 @@ class CommandQueue : public BaseObject<_cl_command_queue> {
MOCKABLE_VIRTUAL CommandStreamReceiver &getGpgpuCommandStreamReceiver() const;
CommandStreamReceiver *getBcsCommandStreamReceiver() const;
MOCKABLE_VIRTUAL CommandStreamReceiver &getCommandStreamReceiverByCommandType(cl_command_type cmdType) const;
Device &getDevice() const noexcept;
Context &getContext() const { return *context; }
Context *getContextPtr() const { return context; }

View File

@@ -96,7 +96,7 @@ cl_int CommandQueueHw<GfxFamily>::enqueueReadBuffer(
} else {
surfaces[1] = &hostPtrSurf;
if (size != 0) {
auto &csr = blitEnqueueAllowed(cmdType) ? *getBcsCommandStreamReceiver() : getGpgpuCommandStreamReceiver();
auto &csr = getCommandStreamReceiverByCommandType(cmdType);
bool status = csr.createAllocationForHostSurface(hostPtrSurf, true);
if (!status) {
return CL_OUT_OF_RESOURCES;

View File

@@ -66,7 +66,7 @@ cl_int CommandQueueHw<GfxFamily>::enqueueReadBufferRect(
if (region[0] != 0 &&
region[1] != 0 &&
region[2] != 0) {
auto &csr = blitEnqueueAllowed(cmdType) ? *getBcsCommandStreamReceiver() : getGpgpuCommandStreamReceiver();
auto &csr = getCommandStreamReceiverByCommandType(cmdType);
bool status = csr.createAllocationForHostSurface(hostPtrSurf, true);
if (!status) {
return CL_OUT_OF_RESOURCES;

View File

@@ -348,7 +348,7 @@ cl_int CommandQueueHw<GfxFamily>::enqueueSVMMemcpy(cl_bool blockingCopy,
HostPtrSurface dstHostPtrSurf(dstPtr, size);
cmdType = CL_COMMAND_READ_BUFFER;
if (size != 0) {
auto &csr = blitEnqueueAllowed(cmdType) ? *getBcsCommandStreamReceiver() : getGpgpuCommandStreamReceiver();
auto &csr = getCommandStreamReceiverByCommandType(cmdType);
bool status = csr.createAllocationForHostSurface(dstHostPtrSurf, true);
if (!status) {
return CL_OUT_OF_RESOURCES;
@@ -371,7 +371,7 @@ cl_int CommandQueueHw<GfxFamily>::enqueueSVMMemcpy(cl_bool blockingCopy,
GeneralSurface dstSvmSurf(dstSvmData->gpuAllocation);
cmdType = CL_COMMAND_WRITE_BUFFER;
if (size != 0) {
auto &csr = blitEnqueueAllowed(cmdType) ? *getBcsCommandStreamReceiver() : getGpgpuCommandStreamReceiver();
auto &csr = getCommandStreamReceiverByCommandType(cmdType);
bool status = csr.createAllocationForHostSurface(srcHostPtrSurf, false);
if (!status) {
return CL_OUT_OF_RESOURCES;
@@ -408,7 +408,7 @@ cl_int CommandQueueHw<GfxFamily>::enqueueSVMMemcpy(cl_bool blockingCopy,
HostPtrSurface dstHostPtrSurf(dstPtr, size);
cmdType = CL_COMMAND_WRITE_BUFFER;
if (size != 0) {
auto &csr = blitEnqueueAllowed(cmdType) ? *getBcsCommandStreamReceiver() : getGpgpuCommandStreamReceiver();
auto &csr = getCommandStreamReceiverByCommandType(cmdType);
bool status = csr.createAllocationForHostSurface(srcHostPtrSurf, false);
status &= csr.createAllocationForHostSurface(dstHostPtrSurf, true);
if (!status) {

View File

@@ -93,7 +93,7 @@ cl_int CommandQueueHw<GfxFamily>::enqueueWriteBuffer(
} else {
surfaces[1] = &hostPtrSurf;
if (size != 0) {
auto &csr = blitEnqueueAllowed(cmdType) ? *getBcsCommandStreamReceiver() : getGpgpuCommandStreamReceiver();
auto &csr = getCommandStreamReceiverByCommandType(cmdType);
bool status = csr.createAllocationForHostSurface(hostPtrSurf, false);
if (!status) {
return CL_OUT_OF_RESOURCES;

View File

@@ -65,7 +65,7 @@ cl_int CommandQueueHw<GfxFamily>::enqueueWriteBufferRect(
if (region[0] != 0 &&
region[1] != 0 &&
region[2] != 0) {
auto &csr = blitEnqueueAllowed(cmdType) ? *getBcsCommandStreamReceiver() : getGpgpuCommandStreamReceiver();
auto &csr = getCommandStreamReceiverByCommandType(cmdType);
bool status = csr.createAllocationForHostSurface(hostPtrSurf, false);
if (!status) {
return CL_OUT_OF_RESOURCES;