|
10 | 10 | #include "shared/source/indirect_heap/indirect_heap.h" |
11 | 11 | #include "shared/source/memory_manager/internal_allocation_storage.h" |
12 | 12 | #include "shared/test/common/cmd_parse/gen_cmd_parse.h" |
| 13 | +#include "shared/test/common/helpers/debug_manager_state_restore.h" |
13 | 14 | #include "shared/test/common/helpers/relaxed_ordering_commands_helper.h" |
14 | 15 | #include "shared/test/common/helpers/unit_test_helper.h" |
15 | 16 | #include "shared/test/common/libult/ult_command_stream_receiver.h" |
@@ -1108,6 +1109,113 @@ HWTEST2_F(CommandListCreate, whenDispatchingThenPassNumCsrClients, IsAtLeastXeHp |
1108 | 1109 | EXPECT_EQ(ultCsr->latestFlushedBatchBuffer.numCsrClients, ultCsr->getNumClients()); |
1109 | 1110 | } |
1110 | 1111 |
|
| 1112 | +HWTEST_F(CommandListCreate, givenSignalEventWhenCallingSynchronizeThenUnregisterClient) { |
| 1113 | + ze_command_queue_desc_t desc = {}; |
| 1114 | + desc.mode = ZE_COMMAND_QUEUE_MODE_SYNCHRONOUS; |
| 1115 | + ze_result_t returnValue; |
| 1116 | + std::unique_ptr<L0::CommandList> commandList(CommandList::createImmediate(productFamily, device, &desc, false, NEO::EngineGroupType::RenderCompute, returnValue)); |
| 1117 | + ASSERT_NE(nullptr, commandList); |
| 1118 | + auto whiteBoxCmdList = static_cast<CommandList *>(commandList.get()); |
| 1119 | + |
| 1120 | + Mock<::L0::Kernel> kernel; |
| 1121 | + ze_group_count_t groupCount{1, 1, 1}; |
| 1122 | + CmdListKernelLaunchParams launchParams = {}; |
| 1123 | + |
| 1124 | + auto ultCsr = static_cast<NEO::UltCommandStreamReceiver<FamilyType> *>(whiteBoxCmdList->csr); |
| 1125 | + |
| 1126 | + ze_event_pool_desc_t eventPoolDesc = {}; |
| 1127 | + eventPoolDesc.count = 3; |
| 1128 | + |
| 1129 | + ze_event_desc_t eventDesc = {}; |
| 1130 | + |
| 1131 | + ze_event_handle_t event1 = nullptr; |
| 1132 | + ze_event_handle_t event2 = nullptr; |
| 1133 | + ze_event_handle_t event3 = nullptr; |
| 1134 | + |
| 1135 | + std::unique_ptr<L0::EventPool> eventPool(EventPool::create(driverHandle.get(), context, 0, nullptr, &eventPoolDesc, returnValue)); |
| 1136 | + |
| 1137 | + ASSERT_EQ(ZE_RESULT_SUCCESS, eventPool->createEvent(&eventDesc, &event1)); |
| 1138 | + ASSERT_EQ(ZE_RESULT_SUCCESS, eventPool->createEvent(&eventDesc, &event2)); |
| 1139 | + ASSERT_EQ(ZE_RESULT_SUCCESS, eventPool->createEvent(&eventDesc, &event3)); |
| 1140 | + |
| 1141 | + EXPECT_EQ(ultCsr->getNumClients(), 0u); |
| 1142 | + |
| 1143 | + { |
| 1144 | + commandList->appendLaunchKernel(kernel.toHandle(), &groupCount, event1, 0, nullptr, launchParams, false); |
| 1145 | + EXPECT_EQ(ultCsr->getNumClients(), 1u); |
| 1146 | + |
| 1147 | + Event::fromHandle(event1)->setIsCompleted(); |
| 1148 | + |
| 1149 | + zeEventHostSynchronize(event1, std::numeric_limits<uint64_t>::max()); |
| 1150 | + EXPECT_EQ(ultCsr->getNumClients(), 0u); |
| 1151 | + } |
| 1152 | + |
| 1153 | + { |
| 1154 | + commandList->appendLaunchKernel(kernel.toHandle(), &groupCount, event2, 0, nullptr, launchParams, false); |
| 1155 | + EXPECT_EQ(ultCsr->getNumClients(), 1u); |
| 1156 | + |
| 1157 | + *reinterpret_cast<uint32_t *>(Event::fromHandle(event2)->getHostAddress()) = static_cast<uint32_t>(Event::STATE_SIGNALED); |
| 1158 | + |
| 1159 | + zeEventHostSynchronize(event2, std::numeric_limits<uint64_t>::max()); |
| 1160 | + EXPECT_EQ(ultCsr->getNumClients(), 0u); |
| 1161 | + } |
| 1162 | + |
| 1163 | + { |
| 1164 | + commandList->appendLaunchKernel(kernel.toHandle(), &groupCount, event3, 0, nullptr, launchParams, false); |
| 1165 | + EXPECT_EQ(ultCsr->getNumClients(), 1u); |
| 1166 | + |
| 1167 | + zeEventHostReset(event3); |
| 1168 | + |
| 1169 | + zeEventHostSynchronize(event3, 1); |
| 1170 | + EXPECT_EQ(ultCsr->getNumClients(), 1u); |
| 1171 | + } |
| 1172 | + |
| 1173 | + zeEventDestroy(event1); |
| 1174 | + zeEventDestroy(event2); |
| 1175 | + zeEventDestroy(event3); |
| 1176 | +} |
| 1177 | + |
| 1178 | +HWTEST_F(CommandListCreate, givenDebugFlagSetWhenCallingSynchronizeThenDontUnregister) { |
| 1179 | + DebugManagerStateRestore restore; |
| 1180 | + DebugManager.flags.TrackNumCsrClientsOnSyncPoints.set(0); |
| 1181 | + |
| 1182 | + ze_command_queue_desc_t desc = {}; |
| 1183 | + desc.mode = ZE_COMMAND_QUEUE_MODE_SYNCHRONOUS; |
| 1184 | + ze_result_t returnValue; |
| 1185 | + std::unique_ptr<L0::CommandList> commandList(CommandList::createImmediate(productFamily, device, &desc, false, NEO::EngineGroupType::RenderCompute, returnValue)); |
| 1186 | + ASSERT_NE(nullptr, commandList); |
| 1187 | + auto whiteBoxCmdList = static_cast<CommandList *>(commandList.get()); |
| 1188 | + |
| 1189 | + Mock<::L0::Kernel> kernel; |
| 1190 | + ze_group_count_t groupCount{1, 1, 1}; |
| 1191 | + CmdListKernelLaunchParams launchParams = {}; |
| 1192 | + |
| 1193 | + auto ultCsr = static_cast<NEO::UltCommandStreamReceiver<FamilyType> *>(whiteBoxCmdList->csr); |
| 1194 | + |
| 1195 | + ze_event_pool_desc_t eventPoolDesc = {}; |
| 1196 | + eventPoolDesc.count = 1; |
| 1197 | + |
| 1198 | + ze_event_desc_t eventDesc = {}; |
| 1199 | + |
| 1200 | + ze_event_handle_t event = nullptr; |
| 1201 | + |
| 1202 | + std::unique_ptr<L0::EventPool> eventPool(EventPool::create(driverHandle.get(), context, 0, nullptr, &eventPoolDesc, returnValue)); |
| 1203 | + |
| 1204 | + ASSERT_EQ(ZE_RESULT_SUCCESS, eventPool->createEvent(&eventDesc, &event)); |
| 1205 | + |
| 1206 | + EXPECT_EQ(ultCsr->getNumClients(), 0u); |
| 1207 | + commandList->appendLaunchKernel(kernel.toHandle(), &groupCount, event, 0, nullptr, launchParams, false); |
| 1208 | + EXPECT_EQ(ultCsr->getNumClients(), 1u); |
| 1209 | + |
| 1210 | + Event::fromHandle(event)->setIsCompleted(); |
| 1211 | + |
| 1212 | + zeEventHostSynchronize(event, std::numeric_limits<uint64_t>::max()); |
| 1213 | + |
| 1214 | + EXPECT_EQ(ultCsr->getNumClients(), 1u); |
| 1215 | + |
| 1216 | + zeEventDestroy(event); |
| 1217 | +} |
| 1218 | + |
1111 | 1219 | HWTEST2_F(CommandListCreate, givenDirectSubmissionAndImmCmdListWhenDispatchingThenPassRelaxedOrderingDependenciesInfo, IsAtLeastXeHpcCore) { |
1112 | 1220 | DebugManagerStateRestore restore; |
1113 | 1221 | DebugManager.flags.DirectSubmissionRelaxedOrdering.set(1); |
|
0 commit comments