Assign BCS at first blit enqueue

Signed-off-by: Lukasz Jobczyk <lukasz.jobczyk@intel.com>
This commit is contained in:
Lukasz Jobczyk
2022-04-25 11:06:41 +00:00
committed by Compute-Runtime-Automation
parent 03185f7111
commit 5f5a1a6f81
8 changed files with 87 additions and 22 deletions

View File

@@ -77,19 +77,22 @@ CommandQueue::CommandQueue(Context *context, ClDevice *device, const cl_queue_pr
UNRECOVERABLE_IF(gpgpuEngine->getEngineType() >= aub_stream::EngineType::NUM_ENGINES);
bool bcsAllowed = hwInfoConfig->isBlitterFullySupported(hwInfo) &&
hwHelper.isSubDeviceEngineSupported(hwInfo, device->getDeviceBitfield(), aub_stream::EngineType::ENGINE_BCS);
bcsAllowed = hwInfoConfig->isBlitterFullySupported(hwInfo) &&
hwHelper.isSubDeviceEngineSupported(hwInfo, device->getDeviceBitfield(), aub_stream::EngineType::ENGINE_BCS);
if (bcsAllowed || gpgpuEngine->commandStreamReceiver->peekTimestampPacketWriteEnabled()) {
timestampPacketContainer = std::make_unique<TimestampPacketContainer>();
deferredTimestampPackets = std::make_unique<TimestampPacketContainer>();
}
if (bcsAllowed) {
auto &neoDevice = device->getNearestGenericSubDevice(0)->getDevice();
auto &selectorCopyEngine = neoDevice.getSelectorCopyEngine();
auto bcsEngineType = EngineHelpers::getBcsEngineType(hwInfo, device->getDeviceBitfield(), selectorCopyEngine, internalUsage);
bcsEngines[EngineHelpers::getBcsIndex(bcsEngineType)] = neoDevice.tryGetEngine(bcsEngineType, EngineUsage::Regular);
bcsEngineTypes.push_back(bcsEngineType);
auto deferCmdQBcsInitialization = true;
if (DebugManager.flags.DeferCmdQBcsInitialization.get() != -1) {
deferCmdQBcsInitialization = DebugManager.flags.DeferCmdQBcsInitialization.get();
}
if (!deferCmdQBcsInitialization) {
this->initializeBcsEngine(internalUsage);
}
}
@@ -134,7 +137,8 @@ CommandStreamReceiver &CommandQueue::getGpgpuCommandStreamReceiver() const {
return *gpgpuEngine->commandStreamReceiver;
}
CommandStreamReceiver *CommandQueue::getBcsCommandStreamReceiver(aub_stream::EngineType bcsEngineType) const {
CommandStreamReceiver *CommandQueue::getBcsCommandStreamReceiver(aub_stream::EngineType bcsEngineType) {
initializeBcsEngine(isSpecial());
const EngineControl *engine = this->bcsEngines[EngineHelpers::getBcsIndex(bcsEngineType)];
if (engine == nullptr) {
return nullptr;
@@ -143,7 +147,8 @@ CommandStreamReceiver *CommandQueue::getBcsCommandStreamReceiver(aub_stream::Eng
}
}
CommandStreamReceiver *CommandQueue::getBcsForAuxTranslation() const {
CommandStreamReceiver *CommandQueue::getBcsForAuxTranslation() {
initializeBcsEngine(isSpecial());
for (const EngineControl *engine : this->bcsEngines) {
if (engine != nullptr) {
return engine->commandStreamReceiver;
@@ -152,7 +157,8 @@ CommandStreamReceiver *CommandQueue::getBcsForAuxTranslation() const {
return nullptr;
}
CommandStreamReceiver &CommandQueue::selectCsrForBuiltinOperation(const CsrSelectionArgs &args) const {
CommandStreamReceiver &CommandQueue::selectCsrForBuiltinOperation(const CsrSelectionArgs &args) {
initializeBcsEngine(isSpecial());
if (isCopyOnly) {
return *getBcsCommandStreamReceiver(bcsEngineTypes[0]);
}
@@ -220,6 +226,17 @@ CommandStreamReceiver &CommandQueue::selectCsrForBuiltinOperation(const CsrSelec
return *selectedCsr;
}
void CommandQueue::initializeBcsEngine(bool internalUsage) {
if (bcsAllowed && !bcsInitialized) {
auto &neoDevice = device->getNearestGenericSubDevice(0)->getDevice();
auto &selectorCopyEngine = neoDevice.getSelectorCopyEngine();
auto bcsEngineType = EngineHelpers::getBcsEngineType(device->getHardwareInfo(), device->getDeviceBitfield(), selectorCopyEngine, internalUsage);
bcsEngines[EngineHelpers::getBcsIndex(bcsEngineType)] = neoDevice.tryGetEngine(bcsEngineType, EngineUsage::Regular);
bcsEngineTypes.push_back(bcsEngineType);
bcsInitialized = true;
}
}
Device &CommandQueue::getDevice() const noexcept {
return device->getDevice();
}
@@ -233,7 +250,7 @@ volatile uint32_t *CommandQueue::getHwTagAddress() const {
return getGpgpuCommandStreamReceiver().getTagAddress();
}
bool CommandQueue::isCompleted(uint32_t gpgpuTaskCount, CopyEngineState bcsState) const {
bool CommandQueue::isCompleted(uint32_t gpgpuTaskCount, CopyEngineState bcsState) {
DEBUG_BREAK_IF(getHwTag() == CompletionStamp::notReady);
if (getGpgpuCommandStreamReceiver().testTaskCountReady(getHwTagAddress(), gpgpuTaskCount)) {
@@ -981,6 +998,7 @@ void CommandQueue::overrideEngine(aub_stream::EngineType engineType, EngineUsage
timestampPacketContainer = std::make_unique<TimestampPacketContainer>();
deferredTimestampPackets = std::make_unique<TimestampPacketContainer>();
isCopyOnly = true;
bcsInitialized = true;
} else {
gpgpuEngine = &device->getEngine(engineType, engineUsage);
}

View File

@@ -202,7 +202,7 @@ class CommandQueue : public BaseObject<_cl_command_queue> {
volatile uint32_t *getHwTagAddress() const;
bool isCompleted(uint32_t gpgpuTaskCount, CopyEngineState bcsState) const;
bool isCompleted(uint32_t gpgpuTaskCount, CopyEngineState bcsState);
bool isWaitForTimestampsEnabled() const;
virtual bool waitForTimestamps(Range<CopyEngineState> copyEnginesToWait, uint32_t taskCount) = 0;
@@ -223,9 +223,10 @@ class CommandQueue : public BaseObject<_cl_command_queue> {
const cl_event *eventWaitList);
MOCKABLE_VIRTUAL CommandStreamReceiver &getGpgpuCommandStreamReceiver() const;
MOCKABLE_VIRTUAL CommandStreamReceiver *getBcsCommandStreamReceiver(aub_stream::EngineType bcsEngineType) const;
CommandStreamReceiver *getBcsForAuxTranslation() const;
MOCKABLE_VIRTUAL CommandStreamReceiver &selectCsrForBuiltinOperation(const CsrSelectionArgs &args) const;
MOCKABLE_VIRTUAL CommandStreamReceiver *getBcsCommandStreamReceiver(aub_stream::EngineType bcsEngineType);
CommandStreamReceiver *getBcsForAuxTranslation();
MOCKABLE_VIRTUAL CommandStreamReceiver &selectCsrForBuiltinOperation(const CsrSelectionArgs &args);
void initializeBcsEngine(bool internalUsage);
Device &getDevice() const noexcept;
ClDevice &getClDevice() const { return *device; }
Context &getContext() const { return *context; }
@@ -408,6 +409,8 @@ class CommandQueue : public BaseObject<_cl_command_queue> {
bool perfCountersEnabled = false;
bool isCopyOnly = false;
bool bcsAllowed = false;
bool bcsInitialized = false;
LinearStream *commandStream = nullptr;

View File

@@ -1067,7 +1067,7 @@ struct WaitUntilCompletionTests : public ::testing::Test {
MyCmdQueue(Context *context, ClDevice *device) : CommandQueueHw<Family>(context, device, nullptr, false){};
CommandStreamReceiver *getBcsCommandStreamReceiver(aub_stream::EngineType bcsEngineType) const override {
CommandStreamReceiver *getBcsCommandStreamReceiver(aub_stream::EngineType bcsEngineType) override {
return bcsCsrToReturn;
}

View File

@@ -84,6 +84,46 @@ HWTEST2_F(CommandQueuePvcAndLaterTests, givenAdditionalBcsWhenCreatingCommandQue
EXPECT_EQ(1u, queue->countBcsEngines());
}
HWTEST2_F(CommandQueuePvcAndLaterTests, givenDeferCmdQBcsInitializationEnabledWhenCreateCommandQueueThenBcsCountIsZero, IsAtLeastXeHpcCore) {
DebugManagerStateRestore restorer;
DebugManager.flags.DeferCmdQBcsInitialization.set(1u);
HardwareInfo hwInfo = *defaultHwInfo;
hwInfo.featureTable.ftrBcsInfo = maxNBitValue(9);
hwInfo.capabilityTable.blitterOperationsSupported = true;
MockDevice *device = MockDevice::createWithNewExecutionEnvironment<MockDevice>(&hwInfo, 0);
MockClDevice clDevice{device};
cl_device_id clDeviceId = static_cast<cl_device_id>(&clDevice);
ClDeviceVector clDevices{&clDeviceId, 1u};
cl_int retVal{};
auto context = std::unique_ptr<Context>{Context::create<Context>(nullptr, clDevices, nullptr, nullptr, retVal)};
EXPECT_EQ(CL_SUCCESS, retVal);
auto queue = std::make_unique<MockCommandQueue>(*context);
EXPECT_EQ(0u, queue->countBcsEngines());
}
HWTEST2_F(CommandQueuePvcAndLaterTests, givenDeferCmdQBcsInitializationDisabledWhenCreateCommandQueueThenBcsIsInitialized, IsAtLeastXeHpcCore) {
DebugManagerStateRestore restorer;
DebugManager.flags.DeferCmdQBcsInitialization.set(0u);
HardwareInfo hwInfo = *defaultHwInfo;
hwInfo.featureTable.ftrBcsInfo = maxNBitValue(9);
hwInfo.capabilityTable.blitterOperationsSupported = true;
MockDevice *device = MockDevice::createWithNewExecutionEnvironment<MockDevice>(&hwInfo, 0);
MockClDevice clDevice{device};
cl_device_id clDeviceId = static_cast<cl_device_id>(&clDevice);
ClDeviceVector clDevices{&clDeviceId, 1u};
cl_int retVal{};
auto context = std::unique_ptr<Context>{Context::create<Context>(nullptr, clDevices, nullptr, nullptr, retVal)};
EXPECT_EQ(CL_SUCCESS, retVal);
auto queue = std::make_unique<MockCommandQueue>(*context);
EXPECT_NE(0u, queue->countBcsEngines());
}
HWTEST2_F(CommandQueuePvcAndLaterTests, givenQueueWithMainBcsIsReleasedWhenNewQueueIsCreatedThenMainBcsCanBeUsedAgain, IsAtLeastXeHpcCore) {
HardwareInfo hwInfo = *defaultHwInfo;
hwInfo.featureTable.ftrBcsInfo = maxNBitValue(9);
@@ -102,9 +142,9 @@ HWTEST2_F(CommandQueuePvcAndLaterTests, givenQueueWithMainBcsIsReleasedWhenNewQu
auto queue4 = std::make_unique<MockCommandQueue>(*context);
EXPECT_EQ(aub_stream::EngineType::ENGINE_BCS, queue1->getBcsCommandStreamReceiver(aub_stream::ENGINE_BCS)->getOsContext().getEngineType());
EXPECT_EQ(aub_stream::EngineType::ENGINE_BCS1, queue2->getBcsCommandStreamReceiver(aub_stream::ENGINE_BCS1)->getOsContext().getEngineType());
EXPECT_EQ(aub_stream::EngineType::ENGINE_BCS2, queue3->getBcsCommandStreamReceiver(aub_stream::ENGINE_BCS2)->getOsContext().getEngineType());
EXPECT_EQ(aub_stream::EngineType::ENGINE_BCS1, queue4->getBcsCommandStreamReceiver(aub_stream::ENGINE_BCS1)->getOsContext().getEngineType());
EXPECT_EQ(aub_stream::EngineType::ENGINE_BCS2, queue2->getBcsCommandStreamReceiver(aub_stream::ENGINE_BCS2)->getOsContext().getEngineType());
EXPECT_EQ(aub_stream::EngineType::ENGINE_BCS1, queue3->getBcsCommandStreamReceiver(aub_stream::ENGINE_BCS1)->getOsContext().getEngineType());
EXPECT_EQ(aub_stream::EngineType::ENGINE_BCS2, queue4->getBcsCommandStreamReceiver(aub_stream::ENGINE_BCS2)->getOsContext().getEngineType());
// Releasing main BCS. Next creation should be able to grab it
queue1.reset();
@@ -114,7 +154,7 @@ HWTEST2_F(CommandQueuePvcAndLaterTests, givenQueueWithMainBcsIsReleasedWhenNewQu
// Releasing link BCS. Shouldn't change anything
queue2.reset();
queue2 = std::make_unique<MockCommandQueue>(*context);
EXPECT_EQ(aub_stream::EngineType::ENGINE_BCS2, queue2->getBcsCommandStreamReceiver(aub_stream::ENGINE_BCS2)->getOsContext().getEngineType());
EXPECT_EQ(aub_stream::EngineType::ENGINE_BCS1, queue2->getBcsCommandStreamReceiver(aub_stream::ENGINE_BCS1)->getOsContext().getEngineType());
}
HWTEST2_F(CommandQueuePvcAndLaterTests, givenCooperativeEngineUsageHintAndCcsWhenCreatingCommandQueueThenCreateQueueWithCooperativeEngine, IsAtLeastXeHpcCore) {
@@ -455,10 +495,10 @@ HWTEST2_F(BcsCsrSelectionCommandQueueTests, givenMultipleEnginesInQueueWhenSelec
aub_stream::ENGINE_BCS7,
aub_stream::ENGINE_BCS8,
});
EXPECT_EQ(queue->getBcsCommandStreamReceiver(aub_stream::ENGINE_BCS1), &queue->selectCsrForBuiltinOperation(args));
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));
EXPECT_EQ(queue->getBcsCommandStreamReceiver(aub_stream::ENGINE_BCS1), &queue->selectCsrForBuiltinOperation(args));
}
}

View File

@@ -144,6 +144,7 @@ TEST(Event, givenBcsCsrSetInEventWhenPeekingBcsTaskCountThenReturnCorrectTaskCou
new MockClDevice{MockDevice::createWithNewExecutionEnvironment<MockAlignedMallocManagerDevice>(&hwInfo)}};
MockContext context{device.get()};
MockCommandQueue queue{context};
queue.initializeBcsEngine(false);
queue.updateBcsTaskCount(queue.bcsEngines[0]->getEngineType(), 19);
Event event{&queue, CL_COMMAND_READ_BUFFER, 0, 0};

View File

@@ -257,6 +257,7 @@ class MockCommandQueueHw : public CommandQueueHw<GfxFamily> {
MockCommandQueueHw(Context *context,
ClDevice *device,
cl_queue_properties *properties) : BaseClass(context, device, properties, false) {
this->initializeBcsEngine(false);
}
void clearBcsEngines() {

View File

@@ -382,6 +382,7 @@ ForceExtendedKernelIsaSize = -1
MakeIndirectAllocationsResidentAsPack = -1
MakeEachAllocationResident = -1
AssignBCSAtEnqueue = -1
DeferCmdQBcsInitialization = -1
ReuseKernelBinaries = -1
EnableChipsetUniqueUUID = -1
ForceSimdMessageSizeInWalker = -1