@@ -40,20 +40,13 @@ void createImmediateCommandList(ze_device_handle_t &device,
4040 SUCCESS_OR_TERMINATE (zeCommandListCreateImmediate (context, device, &cmdQueueDesc, &cmdList));
4141}
4242
43- void testCopyBetweenHostMemAndDeviceMem (ze_context_handle_t &context, ze_device_handle_t &device, bool syncMode, bool &validRet) {
43+ void testCopyBetweenHostMemAndDeviceMem (ze_context_handle_t &context, ze_device_handle_t &device, bool syncMode, int32_t copyQueueGroup, bool &validRet) {
4444 const size_t allocSize = 4096 + 7 ; // +7 to brake alignment and make it harder
4545 char *hostBuffer = nullptr ;
4646 void *deviceBuffer = nullptr ;
4747 char *stackBuffer = new char [allocSize];
4848 ze_command_list_handle_t cmdList;
4949
50- int32_t copyQueueGroup = getCopyOnlyCommandQueueOrdinal (device);
51- if (copyQueueGroup < 0 ) {
52- std::cout << " No Copy queue group found. Skipping test run\n " ;
53- validRet = true ;
54- return ;
55- }
56-
5750 createImmediateCommandList (device, context, copyQueueGroup, syncMode, cmdList);
5851
5952 ze_host_mem_alloc_desc_t hostDesc = {};
@@ -275,15 +268,68 @@ int main(int argc, char *argv[]) {
275268 std::cout << " \n Test case: Async mode compute queue with Kernel launch \n " ;
276269 executeGpuKernelAndValidate (context, device, false , outputValidationSuccessful);
277270 }
278- if (outputValidationSuccessful) {
279- // Sync mode with Copy queue
280- std::cout << " \n Test case: Sync mode copy queue for memory copy\n " ;
281- testCopyBetweenHostMemAndDeviceMem (context, device, true , outputValidationSuccessful);
271+
272+ // Find copy queue in root device, if not found, try subdevices
273+ int32_t copyQueueGroup = 0 ;
274+ bool copyQueueFound = false ;
275+ auto copyQueueDev = devices[0 ];
276+ for (auto &rd : devices) {
277+ copyQueueGroup = getCopyOnlyCommandQueueOrdinal (rd);
278+ if (copyQueueGroup >= 0 ) {
279+ copyQueueFound = true ;
280+ copyQueueDev = rd;
281+ if (verbose) {
282+ std::cout << " \n Copy queue group found in root device\n " ;
283+ }
284+ break ;
285+ }
282286 }
283- if (outputValidationSuccessful) {
284- // Async mode with Copy queue
285- std::cout << " \n Test case: Async mode copy queue for memory copy\n " ;
286- testCopyBetweenHostMemAndDeviceMem (context, device, false , outputValidationSuccessful);
287+
288+ if (!copyQueueFound) {
289+ if (verbose) {
290+ std::cout << " \n No Copy queue group found in root device. Checking subdevices now...\n " ;
291+ }
292+ copyQueueGroup = 0 ;
293+ for (auto &rd : devices) {
294+ int subDevCount = 0 ;
295+ auto subdevs = zelloGetSubDevices (rd, subDevCount);
296+
297+ if (!subDevCount) {
298+ continue ;
299+ }
300+
301+ // Find subdev that has a copy engine. If not skip tests
302+ for (auto &sd : subdevs) {
303+ copyQueueGroup = getCopyOnlyCommandQueueOrdinal (sd);
304+ if (copyQueueGroup >= 0 ) {
305+ copyQueueFound = true ;
306+ copyQueueDev = sd;
307+ break ;
308+ }
309+ }
310+
311+ if (copyQueueFound) {
312+ if (verbose) {
313+ std::cout << " \n Copy queue group found in sub device\n " ;
314+ }
315+ break ;
316+ }
317+ }
318+ }
319+
320+ if (!copyQueueFound) {
321+ std::cout << " No Copy queue group found. Skipping further test runs\n " ;
322+ } else {
323+ if (outputValidationSuccessful) {
324+ // Sync mode with Copy queue
325+ std::cout << " \n Test case: Sync mode copy queue for memory copy\n " ;
326+ testCopyBetweenHostMemAndDeviceMem (context, copyQueueDev, true , copyQueueGroup, outputValidationSuccessful);
327+ }
328+ if (outputValidationSuccessful) {
329+ // Async mode with Copy queue
330+ std::cout << " \n Test case: Async mode copy queue for memory copy\n " ;
331+ testCopyBetweenHostMemAndDeviceMem (context, copyQueueDev, false , copyQueueGroup, outputValidationSuccessful);
332+ }
287333 }
288334
289335 SUCCESS_OR_TERMINATE (zeContextDestroy (context));
0 commit comments