Enable blitter for platforms without timestamp packet writes

Change-Id: Ib37306ad44b19f57901416f6b2d11be93978b339
Signed-off-by: Maciej Dziuban <maciej.dziuban@intel.com>
Related-To: NEO-4233
This commit is contained in:
Maciej Dziuban 2020-05-21 16:35:20 +02:00 committed by sys_ocldev
parent 546c81af70
commit 9bafefe2bc
5 changed files with 58 additions and 6 deletions

View File

@ -66,11 +66,11 @@ CommandQueue::CommandQueue(Context *context, ClDevice *device, const cl_queue_pr
flushStamp.reset(new FlushStampTracker(true));
if (device) {
auto hwInfo = device->getHardwareInfo();
gpgpuEngine = &device->getDefaultEngine();
if (gpgpuEngine->commandStreamReceiver->peekTimestampPacketWriteEnabled()) {
if (hwInfo.capabilityTable.blitterOperationsSupported || gpgpuEngine->commandStreamReceiver->peekTimestampPacketWriteEnabled()) {
timestampPacketContainer = std::make_unique<TimestampPacketContainer>();
}
auto hwInfo = device->getHardwareInfo();
if (hwInfo.capabilityTable.blitterOperationsSupported) {
auto &selectorCopyEngine = device->getDeviceById(0)->getSelectorCopyEngine();
bcsEngine = &device->getDeviceById(0)->getEngine(EngineHelpers::getBcsEngineType(hwInfo, selectorCopyEngine), false);

View File

@ -202,7 +202,7 @@ void CommandQueueHw<GfxFamily>::enqueueHandler(Surface **surfacesForResidency,
bool enqueueWithBlitAuxTranslation = HwHelperHw<GfxFamily>::isBlitAuxTranslationRequired(device->getHardwareInfo(), multiDispatchInfo);
if (getGpgpuCommandStreamReceiver().peekTimestampPacketWriteEnabled()) {
if (blitEnqueue || getGpgpuCommandStreamReceiver().peekTimestampPacketWriteEnabled()) {
eventsRequest.fillCsrDependencies(csrDeps, getGpgpuCommandStreamReceiver(), CsrDependencies::DependenciesType::OnCsr);
auto allocator = getGpgpuCommandStreamReceiver().getTimestampPacketAllocator();

View File

@ -343,7 +343,7 @@ CompletionStamp &CommandWithoutKernel::submit(uint32_t taskLevel, bool terminate
false //usePerDssBackedBuffer
);
UNRECOVERABLE_IF(!commandStreamReceiver.peekTimestampPacketWriteEnabled());
UNRECOVERABLE_IF(!kernelOperation->blitEnqueue && !commandStreamReceiver.peekTimestampPacketWriteEnabled());
eventsRequest.fillCsrDependencies(dispatchFlags.csrDependencies, commandStreamReceiver, CsrDependencies::DependenciesType::OutOfCsr);
makeTimestampPacketsResident(commandStreamReceiver);

View File

@ -22,7 +22,8 @@
using namespace NEO;
struct BlitAuxTranslationTests : public ::testing::Test {
template <int timestampPacketEnabled>
struct BlitEnqueueTests : public ::testing::Test {
class BcsMockContext : public MockContext {
public:
BcsMockContext(ClDevice *device) : MockContext(device) {
@ -56,7 +57,7 @@ struct BlitAuxTranslationTests : public ::testing::Test {
if (is32bit || !hwHelper.requiresAuxResolves()) {
GTEST_SKIP();
}
DebugManager.flags.EnableTimestampPacket.set(1);
DebugManager.flags.EnableTimestampPacket.set(timestampPacketEnabled);
DebugManager.flags.EnableBlitterOperationsForReadWriteBuffers.set(1);
DebugManager.flags.ForceAuxTranslationMode.set(1);
DebugManager.flags.CsrDispatchMode.set(static_cast<int32_t>(DispatchMode::ImmediateDispatch));
@ -198,6 +199,8 @@ struct BlitAuxTranslationTests : public ::testing::Test {
cl_int retVal = CL_SUCCESS;
};
using BlitAuxTranslationTests = BlitEnqueueTests<1>;
HWTEST_TEMPLATED_F(BlitAuxTranslationTests, givenBlitAuxTranslationWhenConstructingCommandBufferThenEnsureCorrectOrder) {
using PIPE_CONTROL = typename FamilyType::PIPE_CONTROL;
using MI_SEMAPHORE_WAIT = typename FamilyType::MI_SEMAPHORE_WAIT;
@ -811,3 +814,37 @@ HWTEST_TEMPLATED_F(BlitAuxTranslationTests, givenBlitTranslationWhenEnqueueIsCal
EXPECT_EQ(1u, ultCsr->taskCount);
EXPECT_TRUE(ultCsr->recordedDispatchFlags.implicitFlush);
}
using BlitEnqueueWithNoTimestampPacketTests = BlitEnqueueTests<0>;
HWTEST_TEMPLATED_F(BlitEnqueueWithNoTimestampPacketTests, givenNoTimestampPacketsWritewhenEnqueueingBlitOperationThenEnginesAreSynchronized) {
using MI_SEMAPHORE_WAIT = typename FamilyType::MI_SEMAPHORE_WAIT;
using MI_FLUSH_DW = typename FamilyType::MI_FLUSH_DW;
using WALKER_TYPE = typename FamilyType::WALKER_TYPE;
const size_t bufferSize = 1u;
auto buffer = createBuffer(bufferSize, false);
auto ultCsr = static_cast<UltCommandStreamReceiver<FamilyType> *>(gpgpuCsr);
ASSERT_EQ(0u, ultCsr->taskCount);
setMockKernelArgs(std::array<Buffer *, 1>{{buffer.get()}});
commandQueue->enqueueKernel(mockKernel->mockKernel, 1, nullptr, gws, nullptr, 0, nullptr, nullptr);
char cpuBuffer[bufferSize]{};
commandQueue->enqueueReadBuffer(buffer.get(), CL_FALSE, 0, bufferSize, cpuBuffer, nullptr, 0, nullptr, nullptr);
commandQueue->finish();
auto bcsCommands = getCmdList<FamilyType>(bcsCsr->getCS(0));
auto ccsCommands = getCmdList<FamilyType>(commandQueue->getCS(0));
auto cmdFound = expectCommand<MI_SEMAPHORE_WAIT>(bcsCommands.begin(), bcsCommands.end());
cmdFound = expectMiFlush<MI_FLUSH_DW>(cmdFound++, bcsCommands.end());
auto miflushDwCmd = genCmdCast<MI_FLUSH_DW *>(*cmdFound);
const auto bcsSignalAddress = miflushDwCmd->getDestinationAddress();
cmdFound = expectCommand<WALKER_TYPE>(ccsCommands.begin(), ccsCommands.end());
cmdFound = expectCommand<MI_SEMAPHORE_WAIT>(cmdFound++, ccsCommands.end());
verifySemaphore<FamilyType>(cmdFound, bcsSignalAddress);
}

View File

@ -1117,3 +1117,18 @@ TEST(CommandQueue, GivenCommandQueueWhenEnqueueInitDispatchGlobalsCalledThenSucc
nullptr);
EXPECT_EQ(CL_SUCCESS, result);
}
TEST(CommandQueue, givenBlitterOperationsSupportedWhenCreatingQueueThenTimestampPacketIsCreated) {
DebugManagerStateRestore restore;
DebugManager.flags.EnableTimestampPacket.set(0);
MockContext context{};
HardwareInfo *hwInfo = context.getDevice(0)->getRootDeviceEnvironment().getMutableHardwareInfo();
if (!HwHelper::get(hwInfo->platform.eDisplayCoreFamily).obtainBlitterPreference(*hwInfo)) {
GTEST_SKIP();
}
hwInfo->capabilityTable.blitterOperationsSupported = true;
MockCommandQueue cmdQ(&context, context.getDevice(0), 0);
EXPECT_NE(nullptr, cmdQ.timestampPacketContainer);
}