Skip to content

Commit 5d2c6a2

Browse files
Return error code if BCS engine is not available
Signed-off-by: Bartosz Dunajski <bartosz.dunajski@intel.com>
1 parent 470c49b commit 5d2c6a2

File tree

2 files changed

+30
-5
lines changed

2 files changed

+30
-5
lines changed

opencl/test/unit_test/memory_manager/memory_manager_tests.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2767,6 +2767,27 @@ TEST(MemoryTransferHelperTest, WhenBlitterIsSelectedButBlitCopyFailsThenFallback
27672767
EXPECT_EQ(0, memcmp(destData, srcData, dataSize));
27682768
}
27692769

2770+
TEST(MemoryTransferHelperTest, givenBlitOperationSupportedWhenBcsEngineNotAvailableThenReturnUnsupported) {
2771+
constexpr uint32_t dataSize = 16;
2772+
uint8_t destData[dataSize] = {};
2773+
uint8_t srcData[dataSize] = {};
2774+
2775+
MockGraphicsAllocation graphicsAllocation{destData, sizeof(destData)};
2776+
graphicsAllocation.storageInfo.memoryBanks = 1;
2777+
graphicsAllocation.setAllocationType(GraphicsAllocation::AllocationType::BUFFER);
2778+
2779+
auto hwInfo = *defaultHwInfo;
2780+
hwInfo.capabilityTable.blitterOperationsSupported = true;
2781+
hwInfo.featureTable.ftrBcsInfo = 0;
2782+
2783+
auto device = std::unique_ptr<MockDevice>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(&hwInfo));
2784+
2785+
auto bcsEngine = device->tryGetEngine(aub_stream::EngineType::ENGINE_BCS, EngineUsage::Regular);
2786+
EXPECT_EQ(nullptr, bcsEngine);
2787+
2788+
EXPECT_EQ(BlitOperationResult::Unsupported, BlitHelperFunctions::blitMemoryToAllocation(*device, &graphicsAllocation, 0, srcData, {dataSize, 1, 1}));
2789+
}
2790+
27702791
TEST(MemoryManagerTest, givenMemoryManagerWithLocalMemoryWhenCreatingMultiGraphicsAllocationInSystemMemoryThenForceSystemMemoryPlacement) {
27712792
MockExecutionEnvironment executionEnvironment(defaultHwInfo.get());
27722793
executionEnvironment.initGmm();

shared/source/helpers/blit_commands_helper.cpp

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -192,17 +192,21 @@ BlitOperationResult BlitHelper::blitMemoryToAllocationBanks(const Device &device
192192
auto pDeviceForBlit = pRootDevice->getDeviceById(tileId);
193193

194194
auto &selectorCopyEngine = pDeviceForBlit->getSelectorCopyEngine();
195-
auto &bcsEngine = pDeviceForBlit->getEngine(EngineHelpers::getBcsEngineType(hwInfo, selectorCopyEngine), EngineUsage::Regular);
196-
bcsEngine.osContext->ensureContextInitialized();
197-
bcsEngine.commandStreamReceiver->initDirectSubmission(*pDeviceForBlit, *bcsEngine.osContext);
195+
auto bcsEngine = pDeviceForBlit->tryGetEngine(EngineHelpers::getBcsEngineType(hwInfo, selectorCopyEngine), EngineUsage::Regular);
196+
if (!bcsEngine) {
197+
return BlitOperationResult::Unsupported;
198+
}
199+
200+
bcsEngine->osContext->ensureContextInitialized();
201+
bcsEngine->commandStreamReceiver->initDirectSubmission(*pDeviceForBlit, *bcsEngine->osContext);
198202
BlitPropertiesContainer blitPropertiesContainer;
199203
blitPropertiesContainer.push_back(
200204
BlitProperties::constructPropertiesForReadWrite(BlitterConstants::BlitDirection::HostPtrToBuffer,
201-
*bcsEngine.commandStreamReceiver, memory, nullptr,
205+
*bcsEngine->commandStreamReceiver, memory, nullptr,
202206
hostPtr,
203207
(memory->getGpuAddress() + offset),
204208
0, 0, 0, size, 0, 0, 0, 0));
205-
bcsEngine.commandStreamReceiver->blitBuffer(blitPropertiesContainer, true, false, *pDeviceForBlit);
209+
bcsEngine->commandStreamReceiver->blitBuffer(blitPropertiesContainer, true, false, *pDeviceForBlit);
206210
}
207211

208212
return BlitOperationResult::Success;

0 commit comments

Comments
 (0)