fix: add bcs engine type only if engine exist

- check bcs availability before insert to bcsEnginesTypes

Resolves: NEO-7886
Signed-off-by: Cencelewska, Katarzyna <katarzyna.cencelewska@intel.com>
This commit is contained in:
Cencelewska, Katarzyna 2023-04-20 00:18:51 +00:00 committed by Compute-Runtime-Automation
parent bf88e4ef08
commit ac8ac62c92
6 changed files with 22 additions and 16 deletions

View File

@ -254,7 +254,7 @@ CommandStreamReceiver *CommandQueue::getBcsForAuxTranslation() {
CommandStreamReceiver &CommandQueue::selectCsrForBuiltinOperation(const CsrSelectionArgs &args) {
initializeBcsEngine(isSpecial());
if (isCopyOnly) {
return *getBcsCommandStreamReceiver(bcsEngineTypes[0]);
return *getBcsCommandStreamReceiver(*bcsQueueEngineType);
}
if (!blitEnqueueAllowed(args)) {
@ -308,8 +308,8 @@ CommandStreamReceiver &CommandQueue::selectCsrForBuiltinOperation(const CsrSelec
selectedCsr = getBcsCommandStreamReceiver(preferredBcsEngineType);
}
if (selectedCsr == nullptr && !bcsEngineTypes.empty()) {
selectedCsr = getBcsCommandStreamReceiver(bcsEngineTypes[0]);
if (selectedCsr == nullptr && bcsQueueEngineType.has_value()) {
selectedCsr = getBcsCommandStreamReceiver(*bcsQueueEngineType);
}
}
if (selectedCsr == nullptr) {
@ -335,12 +335,12 @@ void CommandQueue::constructBcsEngine(bool internalUsage) {
bcsEngines[bcsIndex] = neoDevice.tryGetEngine(bcsEngineType, engineUsage);
}
bcsEngineTypes.push_back(bcsEngineType);
bcsInitialized = true;
if (bcsEngines[bcsIndex]) {
bcsQueueEngineType = bcsEngineType;
bcsEngines[bcsIndex]->osContext->ensureContextInitialized();
bcsEngines[bcsIndex]->commandStreamReceiver->initDirectSubmission();
}
bcsInitialized = true;
}
}
@ -362,8 +362,9 @@ void CommandQueue::constructBcsEnginesForSplit() {
auto &neoDevice = device->getNearestGenericSubDevice(0)->getDevice();
auto engineType = EngineHelpers::mapBcsIndexToEngineType(i, true);
bcsEngines[i] = neoDevice.tryGetEngine(engineType, EngineUsage::Regular);
bcsEngineTypes.push_back(engineType);
if (bcsEngines[i]) {
bcsQueueEngineType = engineType;
bcsEngines[i]->commandStreamReceiver->initializeResources();
bcsEngines[i]->commandStreamReceiver->initDirectSubmission();
}
@ -1177,7 +1178,9 @@ void CommandQueue::overrideEngine(aub_stream::EngineType engineType, EngineUsage
} else {
bcsEngines[engineIndex] = &device->getEngine(engineType, EngineUsage::Regular);
}
bcsEngineTypes = {engineType};
if (bcsEngines[engineIndex]) {
bcsQueueEngineType = engineType;
}
timestampPacketContainer = std::make_unique<TimestampPacketContainer>();
deferredTimestampPackets = std::make_unique<TimestampPacketContainer>();
isCopyOnly = true;

View File

@ -24,6 +24,7 @@
#include "opencl/source/helpers/properties_helper.h"
#include <cstdint>
#include <optional>
enum InternalMemoryType : uint32_t;
@ -412,7 +413,7 @@ class CommandQueue : public BaseObject<_cl_command_queue> {
ClDevice *device = nullptr;
mutable EngineControl *gpgpuEngine = nullptr;
std::array<EngineControl *, bcsInfoMaskSize> bcsEngines = {};
std::vector<aub_stream::EngineType> bcsEngineTypes = {};
std::optional<aub_stream::EngineType> bcsQueueEngineType{};
cl_command_queue_properties commandQueueProperties = 0;
std::vector<uint64_t> propertiesVector;

View File

@ -397,8 +397,8 @@ cl_int CommandQueueHw<GfxFamily>::enqueueHandler(Surface **surfacesForResidency,
}
// check if we have BCS associated, if so we need to make sure it is completed as well
if (eventBuilder.getEvent() && this->bcsEngineTypes.size() > 0u) {
eventBuilder.getEvent()->setupBcs(this->getBcsCommandStreamReceiver(this->bcsEngineTypes[0u])->getOsContext().getEngineType());
if (eventBuilder.getEvent() && this->bcsQueueEngineType.has_value()) {
eventBuilder.getEvent()->setupBcs(this->getBcsCommandStreamReceiver(*bcsQueueEngineType)->getOsContext().getEngineType());
}
}
if (eventBuilder.getEvent()) {

View File

@ -1987,7 +1987,7 @@ TEST_F(CsrSelectionCommandQueueWithBlitterTests, givenBlitterAndAssignBCSAtEnque
auto &csr = queue->selectCsrForBuiltinOperation(args);
EXPECT_EQ(&csr, queue->getBcsCommandStreamReceiver(queue->bcsEngineTypes[0]));
EXPECT_EQ(&csr, queue->getBcsCommandStreamReceiver(*queue->bcsQueueEngineType));
}
TEST_F(CsrSelectionCommandQueueWithQueueFamiliesBlitterTests, givenBlitterSelectedWithQueueFamiliesWhenSelectingBlitterThenSelectBlitter) {

View File

@ -759,6 +759,7 @@ HWTEST2_F(BcsCsrSelectionCommandQueueTests, givenMultipleEnginesInQueueWhenSelec
aub_stream::ENGINE_BCS7,
aub_stream::ENGINE_BCS8,
});
queue->bcsInitialized = false;
EXPECT_EQ(queue->getBcsCommandStreamReceiver(aub_stream::ENGINE_BCS2), &queue->selectCsrForBuiltinOperation(args));
EXPECT_EQ(queue->getBcsCommandStreamReceiver(aub_stream::ENGINE_BCS1), &queue->selectCsrForBuiltinOperation(args));
EXPECT_EQ(queue->getBcsCommandStreamReceiver(aub_stream::ENGINE_BCS2), &queue->selectCsrForBuiltinOperation(args));

View File

@ -23,8 +23,8 @@ namespace NEO {
class MockCommandQueue : public CommandQueue {
public:
using CommandQueue::bcsEngines;
using CommandQueue::bcsEngineTypes;
using CommandQueue::bcsInitialized;
using CommandQueue::bcsQueueEngineType;
using CommandQueue::bcsStates;
using CommandQueue::bcsTimestampPacketContainers;
using CommandQueue::blitEnqueueAllowed;
@ -47,14 +47,15 @@ class MockCommandQueue : public CommandQueue {
void clearBcsEngines() {
std::fill(bcsEngines.begin(), bcsEngines.end(), nullptr);
bcsEngineTypes.clear();
bcsQueueEngineType = std::nullopt;
}
void insertBcsEngine(aub_stream::EngineType bcsEngineType) {
const auto index = NEO::EngineHelpers::getBcsIndex(bcsEngineType);
const auto engine = &getDevice().getEngine(bcsEngineType, EngineUsage::Regular);
bcsEngines[index] = engine;
bcsEngineTypes.push_back(bcsEngineType);
bcsQueueEngineType = bcsEngineType;
bcsInitialized = true;
}
size_t countBcsEngines() const {
@ -241,7 +242,7 @@ class MockCommandQueueHw : public CommandQueueHw<GfxFamily> {
public:
using BaseClass::bcsEngines;
using BaseClass::bcsEngineTypes;
using BaseClass::bcsQueueEngineType;
using BaseClass::bcsStates;
using BaseClass::blitEnqueueAllowed;
using BaseClass::commandQueueProperties;
@ -270,7 +271,7 @@ class MockCommandQueueHw : public CommandQueueHw<GfxFamily> {
const auto index = NEO::EngineHelpers::getBcsIndex(bcsEngineType);
const auto engine = &getDevice().getEngine(bcsEngineType, EngineUsage::Regular);
bcsEngines[index] = engine;
bcsEngineTypes.push_back(bcsEngineType);
bcsQueueEngineType = bcsEngineType;
}
MockCommandQueueHw(Context *context,