[v0.23] Sort PCI devices; this makes the devices list to match CUDA driver ordering, which fixes a bug when there was more than one NVIDIA GPU

This commit is contained in:
Dr-Noob
2022-01-22 13:25:22 +01:00
parent 23586a18e9
commit bd1158c139
11 changed files with 103 additions and 20 deletions

View File

@@ -98,7 +98,7 @@ int64_t get_peak_performance_tcu(cudaDeviceProp prop, struct gpu_info* gpu) {
else return 0;
}
struct gpu_info* get_gpu_info_cuda(int gpu_idx) {
struct gpu_info* get_gpu_info_cuda(struct pci_dev *devices, int gpu_idx) {
struct gpu_info* gpu = (struct gpu_info*) emalloc(sizeof(struct gpu_info));
gpu->pci = NULL;
gpu->idx = gpu_idx;
@@ -146,8 +146,7 @@ struct gpu_info* get_gpu_info_cuda(int gpu_idx) {
gpu->name = (char *) emalloc(sizeof(char) * (strlen(deviceProp.name) + 1));
strcpy(gpu->name, deviceProp.name);
struct pci_dev *devices = get_pci_devices_from_pciutils();
gpu->pci = get_pci_from_pciutils(devices, PCI_VENDOR_ID_NVIDIA);
gpu->pci = get_pci_from_pciutils(devices, PCI_VENDOR_ID_NVIDIA, gpu_idx);
gpu->arch = get_uarch_from_cuda(gpu);
gpu->cach = get_cache_info(deviceProp);
gpu->mem = get_memory_info(gpu, deviceProp);