1 module dcompute.driver.cuda.platform; 2 3 import dcompute.driver.error; 4 import dcompute.driver.cuda; 5 import std.experimental.allocator.typed; 6 7 struct Platform 8 { 9 static void initialise(uint flags =0) 10 { 11 DerelictCUDADriver.load(); 12 status = cast(Status)cuInit(flags); 13 checkErrors(); 14 } 15 16 static Device[] getDevices(A)(A a) 17 { 18 int len; 19 TypedAllocator!(A) allocator; 20 status = cast(Status)cuDeviceGetCount(&len); 21 checkErrors(); 22 23 //TODO: 24 //Device[] ret = allocator.makeArray!(Device)(len); 25 Device[] ret = new Device[len]; 26 foreach(int i; 0 .. len) 27 { 28 status = cast(Status)cuDeviceGet(&ret[i].raw,i); 29 checkErrors(); 30 } 31 return ret; 32 } 33 34 }