Skip to content

Commit 2b12e9b

Browse files
kgibalaCompute-Runtime-Automation
authored andcommitted
Program MI_SEMAPHORE_WAIT only on multi device setup
Fill and program CsrDependenciesForForTaskCountContainer only on multi device environment Related-To: NEO-5508 Signed-off-by: Krzysztof Gibala <[email protected]>
1 parent 33f05a2 commit 2b12e9b

File tree

3 files changed

+58
-6
lines changed

3 files changed

+58
-6
lines changed

opencl/source/command_queue/enqueue_common.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,9 @@ void CommandQueueHw<GfxFamily>::enqueueHandler(Surface **surfacesForResidency,
197197
CsrDependencies csrDeps;
198198
BlitPropertiesContainer blitPropertiesContainer;
199199

200-
eventsRequest.fillCsrDependenciesForTaskCountContainer(csrDeps, getGpgpuCommandStreamReceiver());
200+
if (this->context->getRootDeviceIndices().size() > 1) {
201+
eventsRequest.fillCsrDependenciesForTaskCountContainer(csrDeps, getGpgpuCommandStreamReceiver());
202+
}
201203

202204
bool enqueueWithBlitAuxTranslation = isBlitAuxTranslationRequired(multiDispatchInfo);
203205

@@ -227,7 +229,9 @@ void CommandQueueHw<GfxFamily>::enqueueHandler(Surface **surfacesForResidency,
227229
blockedCommandsData, surfacesForResidency, numSurfaceForResidency);
228230
auto commandStreamStart = commandStream.getUsed();
229231

230-
TimestampPacketHelper::programCsrDependenciesForForTaskCountContainer<GfxFamily>(commandStream, csrDeps);
232+
if (this->context->getRootDeviceIndices().size() > 1) {
233+
TimestampPacketHelper::programCsrDependenciesForForTaskCountContainer<GfxFamily>(commandStream, csrDeps);
234+
}
231235

232236
if (enqueueWithBlitAuxTranslation) {
233237
processDispatchForBlitAuxTranslation(multiDispatchInfo, blitPropertiesContainer, timestampPacketDependencies,

opencl/test/unit_test/command_stream/command_stream_receiver_flush_task_3_tests.cpp

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1946,6 +1946,54 @@ HWTEST_F(CommandStreamReceiverFlushTaskTests, GivenGpuIsIdleWhenCsrIsEnabledToFl
19461946
*commandStreamReceiver.getTagAddress() = 2u;
19471947
}
19481948

1949+
using SingleRootDeviceCommandStreamReceiverTests = CommandStreamReceiverFlushTaskTests;
1950+
1951+
HWTEST_F(SingleRootDeviceCommandStreamReceiverTests, givenMultipleEventInSingleRootDeviceEnvironmentWhenTheyArePassedToEnqueueWithoutSubmissionThenSemaphoreWaitCommandIsNotProgrammed) {
1952+
using MI_SEMAPHORE_WAIT = typename FamilyType::MI_SEMAPHORE_WAIT;
1953+
1954+
auto deviceFactory = std::make_unique<UltClDeviceFactory>(1, 0);
1955+
auto device0 = deviceFactory->rootDevices[0];
1956+
1957+
auto mockCsr0 = new MockCommandStreamReceiver(*device0->executionEnvironment, device0->getRootDeviceIndex(), device0->getDeviceBitfield());
1958+
1959+
device0->resetCommandStreamReceiver(mockCsr0);
1960+
1961+
cl_device_id devices[] = {device0};
1962+
1963+
auto context = std::make_unique<MockContext>(ClDeviceVector(devices, 1), false);
1964+
1965+
auto pCmdQ0 = context.get()->getSpecialQueue(0u);
1966+
1967+
Event event1(pCmdQ0, CL_COMMAND_NDRANGE_KERNEL, 5, 15);
1968+
Event event2(nullptr, CL_COMMAND_NDRANGE_KERNEL, 6, 16);
1969+
Event event3(pCmdQ0, CL_COMMAND_NDRANGE_KERNEL, 4, 20);
1970+
UserEvent userEvent1(&pCmdQ0->getContext());
1971+
1972+
userEvent1.setStatus(CL_COMPLETE);
1973+
1974+
cl_event eventWaitList[] =
1975+
{
1976+
&event1,
1977+
&event2,
1978+
&event3,
1979+
&userEvent1,
1980+
};
1981+
cl_uint numEventsInWaitList = sizeof(eventWaitList) / sizeof(eventWaitList[0]);
1982+
1983+
{
1984+
pCmdQ0->enqueueMarkerWithWaitList(
1985+
numEventsInWaitList,
1986+
eventWaitList,
1987+
nullptr);
1988+
1989+
HardwareParse csHwParser;
1990+
csHwParser.parseCommands<FamilyType>(pCmdQ0->getCS(0));
1991+
auto semaphores = findAll<MI_SEMAPHORE_WAIT *>(csHwParser.cmdList.begin(), csHwParser.cmdList.end());
1992+
1993+
EXPECT_EQ(0u, semaphores.size());
1994+
}
1995+
}
1996+
19491997
using MultiRootDeviceCommandStreamReceiverTests = CommandStreamReceiverFlushTaskTests;
19501998

19511999
HWTEST_F(MultiRootDeviceCommandStreamReceiverTests, givenMultipleEventInMultiRootDeviceEnvironmentWhenTheyArePassedToEnqueueWithoutSubmissionThenCsIsWaitingForEventsFromPreviousDevices) {

opencl/test/unit_test/helpers/timestamp_packet_tests.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1769,12 +1769,12 @@ HWTEST_F(TimestampPacketTests, givenWaitlistAndOutputEventWhenEnqueueingMarkerWi
17691769
verifySemaphore(genCmdCast<MI_SEMAPHORE_WAIT *>(*(csrSemaphores[0])), node2.getNode(0), 0);
17701770

17711771
auto queueSemaphores = findAll<MI_SEMAPHORE_WAIT *>(hwParserCmdQ.cmdList.begin(), hwParserCmdQ.cmdList.end());
1772-
auto expectedQueueSemaphoresCount = 2u;
1772+
auto expectedQueueSemaphoresCount = 1u;
17731773
if (UnitTestHelper<FamilyType>::isAdditionalMiSemaphoreWaitRequired(device->getHardwareInfo())) {
17741774
expectedQueueSemaphoresCount += 2;
17751775
}
17761776
EXPECT_EQ(expectedQueueSemaphoresCount, queueSemaphores.size());
1777-
verifySemaphore(genCmdCast<MI_SEMAPHORE_WAIT *>(*(queueSemaphores[1])), node1.getNode(0), 0);
1777+
verifySemaphore(genCmdCast<MI_SEMAPHORE_WAIT *>(*(queueSemaphores[0])), node1.getNode(0), 0);
17781778
}
17791779

17801780
HWTEST_F(TimestampPacketTests, givenWaitlistAndOutputEventWhenEnqueueingBarrierWithoutKernelThenInheritTimestampPacketsAndProgramSemaphores) {
@@ -1812,12 +1812,12 @@ HWTEST_F(TimestampPacketTests, givenWaitlistAndOutputEventWhenEnqueueingBarrierW
18121812
verifySemaphore(genCmdCast<MI_SEMAPHORE_WAIT *>(*(csrSemaphores[0])), node2.getNode(0), 0);
18131813

18141814
auto queueSemaphores = findAll<MI_SEMAPHORE_WAIT *>(hwParserCmdQ.cmdList.begin(), hwParserCmdQ.cmdList.end());
1815-
auto expectedQueueSemaphoresCount = 2u;
1815+
auto expectedQueueSemaphoresCount = 1u;
18161816
if (UnitTestHelper<FamilyType>::isAdditionalMiSemaphoreWaitRequired(device->getHardwareInfo())) {
18171817
expectedQueueSemaphoresCount += 2;
18181818
}
18191819
EXPECT_EQ(expectedQueueSemaphoresCount, queueSemaphores.size());
1820-
verifySemaphore(genCmdCast<MI_SEMAPHORE_WAIT *>(*(queueSemaphores[1])), node1.getNode(0), 0);
1820+
verifySemaphore(genCmdCast<MI_SEMAPHORE_WAIT *>(*(queueSemaphores[0])), node1.getNode(0), 0);
18211821
}
18221822

18231823
HWTEST_F(TimestampPacketTests, givenEmptyWaitlistAndNoOutputEventWhenEnqueueingMarkerThenDoNothing) {

0 commit comments

Comments
 (0)