Mercurial > hg > truffle
changeset 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 | 4a6b03a16808 |
children | 085ffcd5159f bb70a309a7cf |
files | src/os_gpu/bsd_ptx/vm/gpu_bsd.cpp src/os_gpu/linux_ptx/vm/gpu_linux.cpp |
diffstat | 2 files changed, 10 insertions(+), 63 deletions(-) [+] |
line wrap: on
line diff
--- a/src/os_gpu/bsd_ptx/vm/gpu_bsd.cpp Mon Aug 12 13:12:14 2013 -0400 +++ b/src/os_gpu/bsd_ptx/vm/gpu_bsd.cpp Mon Aug 12 15:52:26 2013 -0400 @@ -25,14 +25,14 @@ #include "runtime/gpu.hpp" #include "utilities/ostream.hpp" -#ifdef __APPLE__ -#include <ApplicationServices/ApplicationServices.h> -#include <IOKit/IOKitLib.h> -#endif void gpu::probe_gpu() { #ifdef __APPLE__ - set_available(gpu::Bsd::probe_gpu_apple()); + /* + * Let the CUDA driver initialization be the gate to GPU for now, pending + * a better detection solution for NVIDA PTX and AMD HSAIL. + */ + set_available(true); if (TraceGPUInteraction) { tty->print_cr("gpu_bsd::probe_gpu(APPLE): %d", gpu::is_available()); } @@ -44,56 +44,3 @@ #endif } -#ifdef __APPLE__ -/* - * This is rudimentary at best, but until we decide on a CUDA Compiler Compatibility - * level, this will have to suffice. - */ -bool gpu::Bsd::probe_gpu_apple() { - CGError err = CGDisplayNoErr; - CGDisplayCount displayCount = 0; - CFDataRef vendorID, deviceID, model; - CGDirectDisplayID *displays; - IOOptionBits options = kIORegistryIterateRecursively | kIORegistryIterateParents; - io_registry_entry_t displayPort; - - err = CGGetActiveDisplayList(0, NULL, &displayCount); - displays = (CGDirectDisplayID *)calloc((size_t)displayCount, sizeof(CGDirectDisplayID)); - err = CGGetActiveDisplayList(displayCount, displays, &displayCount); - - for (CGDisplayCount i = 0; i < displayCount; i++) { - displayPort = CGDisplayIOServicePort(displays[i]); - vendorID = (CFDataRef)IORegistryEntrySearchCFProperty(displayPort, kIOServicePlane, CFSTR("vendor-id"), - kCFAllocatorDefault, options); - deviceID = (CFDataRef)IORegistryEntrySearchCFProperty(displayPort, kIOServicePlane, CFSTR("device-id"), - kCFAllocatorDefault, options); - model = (CFDataRef)IORegistryEntrySearchCFProperty(displayPort, kIOServicePlane, CFSTR("model"), - kCFAllocatorDefault, options); - if (TraceGPUInteraction) { - tty->print_cr("vendor: 0x%08X", *((UInt32*)CFDataGetBytePtr(vendorID))); - tty->print_cr("device: 0x%08X", *((UInt32*)CFDataGetBytePtr(deviceID))); - tty->print_cr("model: %s", CFDataGetBytePtr(model)); - } - UInt32 vendor = *((UInt32*)CFDataGetBytePtr(vendorID)); - if (vendor != 0x10DE) { - return false; - } else { - /* - * see https://developer.nvidia.com/cuda-gpus - * see http://en.wikipedia.org/wiki/CUDA#Supported_GPUs - * see http://www.pcidatabase.com/reports.php?type=csv - * - * Only supporting GK104, GK106, GK107 and GK110 GPUs for now, - * which is CUDA Computer Capability 3.0 and greater. - */ - switch (*((UInt32*)CFDataGetBytePtr(deviceID))) { - case 0x11C0: - return true; // NVIDIA GeForce GTX 660 - default: - return false; - } - } - } - return false; -} -#endif
--- a/src/os_gpu/linux_ptx/vm/gpu_linux.cpp Mon Aug 12 13:12:14 2013 -0400 +++ b/src/os_gpu/linux_ptx/vm/gpu_linux.cpp Mon Aug 12 15:52:26 2013 -0400 @@ -43,11 +43,11 @@ bool gpu::Linux::probe_gpu() { /* - Open /proc/bus/pci/devices to look for the first CUDA enabled - device. For now, finding the first CUDA device. Will need to - revisit this wo support execution on multiple CUDA devices if - they exist. - */ + * Open /proc/bus/pci/devices to look for the first CUDA enabled + * device. For now, finding the first CUDA device. Will need to + * revisit this to support execution on multiple CUDA devices if + * they exist. + */ FILE *pci_devices = fopen("/proc/bus/pci/devices", "r"); char contents[4096]; unsigned int bus_num_devfn_ign;