Mercurial > hg > graal-compiler
comparison src/os/linux/vm/gpu_linux.cpp @ 13828:5c8a3c09397b
Add additional device checks and compute capability checks for CUDA devices found on Linux.
author | S.Bharadwaj Yadavalli <bharadwaj.yadavalli@oracle.com> |
---|---|
date | Thu, 30 Jan 2014 17:49:56 -0500 |
parents | 49db2c1e3bee |
children | 51584f76462d |
comparison
equal
deleted
inserted
replaced
13827:8053c3ede984 | 13828:5c8a3c09397b |
---|---|
32 */ | 32 */ |
33 | 33 |
34 static unsigned int nvidia_vendor_id = 0x10de; | 34 static unsigned int nvidia_vendor_id = 0x10de; |
35 static unsigned int amd_vendor_id = 0x1002; | 35 static unsigned int amd_vendor_id = 0x1002; |
36 | 36 |
37 #define PCI_DRIVER_NAME_START_POS 255 | |
38 | |
37 jobject gpu::probe_gpus(JNIEnv* env) { | 39 jobject gpu::probe_gpus(JNIEnv* env) { |
38 bool hsail = false; | 40 bool hsail = false; |
39 bool ptx = false; | 41 bool ptx = false; |
40 | 42 |
41 if (UseHSAILSimulator && gpu::Hsail::register_natives(env)) { | 43 if (UseHSAILSimulator && gpu::Hsail::register_natives(env)) { |
50 FILE *pci_devices = fopen("/proc/bus/pci/devices", "r"); | 52 FILE *pci_devices = fopen("/proc/bus/pci/devices", "r"); |
51 char contents[4096]; | 53 char contents[4096]; |
52 unsigned int bus_num_devfn_ign; | 54 unsigned int bus_num_devfn_ign; |
53 unsigned int vendor; | 55 unsigned int vendor; |
54 unsigned int device; | 56 unsigned int device; |
57 const char *driver_name_string = "nvidia"; | |
58 const int driver_name_string_len = strlen(driver_name_string); | |
59 | |
55 if (pci_devices == NULL) { | 60 if (pci_devices == NULL) { |
56 tty->print_cr("*** Failed to open /proc/bus/pci/devices"); | 61 tty->print_cr("*** Failed to open /proc/bus/pci/devices"); |
57 return NULL; | 62 return NULL; |
58 } | 63 } |
59 | 64 |
60 while (fgets(contents, sizeof(contents)-1, pci_devices)) { | 65 while (fgets(contents, sizeof(contents)-1, pci_devices)) { |
61 sscanf(contents, "%04x%04x%04x", &bus_num_devfn_ign, &vendor, &device); | 66 sscanf(contents, "%04x%04x%04x", &bus_num_devfn_ign, &vendor, &device); |
62 /* Break after finding the first GPU device. */ | |
63 if (vendor == nvidia_vendor_id) { | 67 if (vendor == nvidia_vendor_id) { |
64 if (TraceGPUInteraction) { | 68 /* Check if this device is registered to be using nvidia driver */ |
65 tty->print_cr("Found supported nVidia GPU: vendor=0x%04x, device=0x%04x", vendor, device); | 69 if (strncmp(&contents[PCI_DRIVER_NAME_START_POS], |
66 } | 70 driver_name_string, driver_name_string_len) == 0) { |
67 if (!ptx && gpu::Ptx::register_natives(env)) { | 71 if (TraceGPUInteraction) { |
68 ptx = true; | 72 tty->print_cr("Found supported nVidia device [vendor=0x%04x, device=0x%04x]", vendor, device); |
73 } | |
74 if (!ptx && gpu::Ptx::register_natives(env)) { | |
75 ptx = true; | |
76 } | |
69 } | 77 } |
70 } | 78 } |
71 } | 79 } |
72 | 80 |
73 // Close file pointer. | 81 // Close file pointer. |