Mercurial > hg > graal-jvmci-8
comparison src/os_gpu/bsd_ptx/vm/gpu_bsd.cpp @ 11292:5040ec3ff3aa
Defer PTX on Mac probe to the CUDA driver initialization call
author | Morris Meyer <morris.meyer@oracle.com> |
---|---|
date | Mon, 12 Aug 2013 15:52:26 -0400 |
parents | d55f24eac4b1 |
children | 4f69a5189e77 |
comparison
equal
deleted
inserted
replaced
11291:4a6b03a16808 | 11292:5040ec3ff3aa |
---|---|
23 */ | 23 */ |
24 | 24 |
25 #include "runtime/gpu.hpp" | 25 #include "runtime/gpu.hpp" |
26 #include "utilities/ostream.hpp" | 26 #include "utilities/ostream.hpp" |
27 | 27 |
28 #ifdef __APPLE__ | |
29 #include <ApplicationServices/ApplicationServices.h> | |
30 #include <IOKit/IOKitLib.h> | |
31 #endif | |
32 | 28 |
33 void gpu::probe_gpu() { | 29 void gpu::probe_gpu() { |
34 #ifdef __APPLE__ | 30 #ifdef __APPLE__ |
35 set_available(gpu::Bsd::probe_gpu_apple()); | 31 /* |
32 * Let the CUDA driver initialization be the gate to GPU for now, pending | |
33 * a better detection solution for NVIDA PTX and AMD HSAIL. | |
34 */ | |
35 set_available(true); | |
36 if (TraceGPUInteraction) { | 36 if (TraceGPUInteraction) { |
37 tty->print_cr("gpu_bsd::probe_gpu(APPLE): %d", gpu::is_available()); | 37 tty->print_cr("gpu_bsd::probe_gpu(APPLE): %d", gpu::is_available()); |
38 } | 38 } |
39 #else | 39 #else |
40 if (TraceGPUInteraction) { | 40 if (TraceGPUInteraction) { |
42 } | 42 } |
43 set_available(false); | 43 set_available(false); |
44 #endif | 44 #endif |
45 } | 45 } |
46 | 46 |
47 #ifdef __APPLE__ | |
48 /* | |
49 * This is rudimentary at best, but until we decide on a CUDA Compiler Compatibility | |
50 * level, this will have to suffice. | |
51 */ | |
52 bool gpu::Bsd::probe_gpu_apple() { | |
53 CGError err = CGDisplayNoErr; | |
54 CGDisplayCount displayCount = 0; | |
55 CFDataRef vendorID, deviceID, model; | |
56 CGDirectDisplayID *displays; | |
57 IOOptionBits options = kIORegistryIterateRecursively | kIORegistryIterateParents; | |
58 io_registry_entry_t displayPort; | |
59 | |
60 err = CGGetActiveDisplayList(0, NULL, &displayCount); | |
61 displays = (CGDirectDisplayID *)calloc((size_t)displayCount, sizeof(CGDirectDisplayID)); | |
62 err = CGGetActiveDisplayList(displayCount, displays, &displayCount); | |
63 | |
64 for (CGDisplayCount i = 0; i < displayCount; i++) { | |
65 displayPort = CGDisplayIOServicePort(displays[i]); | |
66 vendorID = (CFDataRef)IORegistryEntrySearchCFProperty(displayPort, kIOServicePlane, CFSTR("vendor-id"), | |
67 kCFAllocatorDefault, options); | |
68 deviceID = (CFDataRef)IORegistryEntrySearchCFProperty(displayPort, kIOServicePlane, CFSTR("device-id"), | |
69 kCFAllocatorDefault, options); | |
70 model = (CFDataRef)IORegistryEntrySearchCFProperty(displayPort, kIOServicePlane, CFSTR("model"), | |
71 kCFAllocatorDefault, options); | |
72 if (TraceGPUInteraction) { | |
73 tty->print_cr("vendor: 0x%08X", *((UInt32*)CFDataGetBytePtr(vendorID))); | |
74 tty->print_cr("device: 0x%08X", *((UInt32*)CFDataGetBytePtr(deviceID))); | |
75 tty->print_cr("model: %s", CFDataGetBytePtr(model)); | |
76 } | |
77 UInt32 vendor = *((UInt32*)CFDataGetBytePtr(vendorID)); | |
78 if (vendor != 0x10DE) { | |
79 return false; | |
80 } else { | |
81 /* | |
82 * see https://developer.nvidia.com/cuda-gpus | |
83 * see http://en.wikipedia.org/wiki/CUDA#Supported_GPUs | |
84 * see http://www.pcidatabase.com/reports.php?type=csv | |
85 * | |
86 * Only supporting GK104, GK106, GK107 and GK110 GPUs for now, | |
87 * which is CUDA Computer Capability 3.0 and greater. | |
88 */ | |
89 switch (*((UInt32*)CFDataGetBytePtr(deviceID))) { | |
90 case 0x11C0: | |
91 return true; // NVIDIA GeForce GTX 660 | |
92 default: | |
93 return false; | |
94 } | |
95 } | |
96 } | |
97 return false; | |
98 } | |
99 #endif |