diff --git a/level_zero/core/test/black_box_tests/common/zello_common.h b/level_zero/core/test/black_box_tests/common/zello_common.h index fedb409fba..77e2d740b8 100644 --- a/level_zero/core/test/black_box_tests/common/zello_common.h +++ b/level_zero/core/test/black_box_tests/common/zello_common.h @@ -194,6 +194,21 @@ void createEventPoolAndEvents(ze_context_handle_t &context, } } +std::vector zelloGetSubDevices(ze_device_handle_t &device, int &subDevCount) { + uint32_t deviceCount = 0; + std::vector subdevs(deviceCount, nullptr); + SUCCESS_OR_TERMINATE(zeDeviceGetSubDevices(device, &deviceCount, nullptr)); + if (deviceCount == 0) { + std::cout << "No sub device found!\n"; + subDevCount = 0; + return subdevs; + } + subDevCount = deviceCount; + subdevs.resize(deviceCount); + SUCCESS_OR_TERMINATE(zeDeviceGetSubDevices(device, &deviceCount, subdevs.data())); + return subdevs; +} + std::vector zelloInitContextAndGetDevices(ze_context_handle_t &context, ze_driver_handle_t &driverHandle) { SUCCESS_OR_TERMINATE(zeInit(ZE_INIT_FLAG_GPU_ONLY)); diff --git a/level_zero/core/test/black_box_tests/zello_immediate.cpp b/level_zero/core/test/black_box_tests/zello_immediate.cpp index a3652d19e1..4831eba0a5 100644 --- a/level_zero/core/test/black_box_tests/zello_immediate.cpp +++ b/level_zero/core/test/black_box_tests/zello_immediate.cpp @@ -40,20 +40,13 @@ void createImmediateCommandList(ze_device_handle_t &device, SUCCESS_OR_TERMINATE(zeCommandListCreateImmediate(context, device, &cmdQueueDesc, &cmdList)); } -void testCopyBetweenHostMemAndDeviceMem(ze_context_handle_t &context, ze_device_handle_t &device, bool syncMode, bool &validRet) { +void testCopyBetweenHostMemAndDeviceMem(ze_context_handle_t &context, ze_device_handle_t &device, bool syncMode, int32_t copyQueueGroup, bool &validRet) { const size_t allocSize = 4096 + 7; // +7 to brake alignment and make it harder char *hostBuffer = nullptr; void *deviceBuffer = nullptr; char *stackBuffer = new char[allocSize]; ze_command_list_handle_t cmdList; - int32_t copyQueueGroup = getCopyOnlyCommandQueueOrdinal(device); - if (copyQueueGroup < 0) { - std::cout << "No Copy queue group found. Skipping test run\n"; - validRet = true; - return; - } - createImmediateCommandList(device, context, copyQueueGroup, syncMode, cmdList); ze_host_mem_alloc_desc_t hostDesc = {}; @@ -275,15 +268,68 @@ int main(int argc, char *argv[]) { std::cout << "\nTest case: Async mode compute queue with Kernel launch \n"; executeGpuKernelAndValidate(context, device, false, outputValidationSuccessful); } - if (outputValidationSuccessful) { - //Sync mode with Copy queue - std::cout << "\nTest case: Sync mode copy queue for memory copy\n"; - testCopyBetweenHostMemAndDeviceMem(context, device, true, outputValidationSuccessful); + + // Find copy queue in root device, if not found, try subdevices + int32_t copyQueueGroup = 0; + bool copyQueueFound = false; + auto copyQueueDev = devices[0]; + for (auto &rd : devices) { + copyQueueGroup = getCopyOnlyCommandQueueOrdinal(rd); + if (copyQueueGroup >= 0) { + copyQueueFound = true; + copyQueueDev = rd; + if (verbose) { + std::cout << "\nCopy queue group found in root device\n"; + } + break; + } } - if (outputValidationSuccessful) { - //Async mode with Copy queue - std::cout << "\nTest case: Async mode copy queue for memory copy\n"; - testCopyBetweenHostMemAndDeviceMem(context, device, false, outputValidationSuccessful); + + if (!copyQueueFound) { + if (verbose) { + std::cout << "\nNo Copy queue group found in root device. Checking subdevices now...\n"; + } + copyQueueGroup = 0; + for (auto &rd : devices) { + int subDevCount = 0; + auto subdevs = zelloGetSubDevices(rd, subDevCount); + + if (!subDevCount) { + continue; + } + + // Find subdev that has a copy engine. If not skip tests + for (auto &sd : subdevs) { + copyQueueGroup = getCopyOnlyCommandQueueOrdinal(sd); + if (copyQueueGroup >= 0) { + copyQueueFound = true; + copyQueueDev = sd; + break; + } + } + + if (copyQueueFound) { + if (verbose) { + std::cout << "\nCopy queue group found in sub device\n"; + } + break; + } + } + } + + if (!copyQueueFound) { + std::cout << "No Copy queue group found. Skipping further test runs\n"; + } else { + if (outputValidationSuccessful) { + //Sync mode with Copy queue + std::cout << "\nTest case: Sync mode copy queue for memory copy\n"; + testCopyBetweenHostMemAndDeviceMem(context, copyQueueDev, true, copyQueueGroup, outputValidationSuccessful); + } + if (outputValidationSuccessful) { + //Async mode with Copy queue + std::cout << "\nTest case: Async mode copy queue for memory copy\n"; + testCopyBetweenHostMemAndDeviceMem(context, copyQueueDev, false, copyQueueGroup, outputValidationSuccessful); + } } SUCCESS_OR_TERMINATE(zeContextDestroy(context));