mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-28 16:48:45 +08:00
Find copy engines correctly before using in test cases
Signed-off-by: Aravind Gopalakrishnan <aravind.gopalakrishnan@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
8453287f5b
commit
5d90e2ab1d
@@ -194,6 +194,21 @@ void createEventPoolAndEvents(ze_context_handle_t &context,
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<ze_device_handle_t> zelloGetSubDevices(ze_device_handle_t &device, int &subDevCount) {
|
||||
uint32_t deviceCount = 0;
|
||||
std::vector<ze_device_handle_t> 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<ze_device_handle_t> zelloInitContextAndGetDevices(ze_context_handle_t &context, ze_driver_handle_t &driverHandle) {
|
||||
SUCCESS_OR_TERMINATE(zeInit(ZE_INIT_FLAG_GPU_ONLY));
|
||||
|
||||
|
||||
@@ -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));
|
||||
|
||||
Reference in New Issue
Block a user