1 module dcompute.driver.cuda.device; 2 3 import dcompute.driver.cuda; 4 5 struct Device 6 { 7 int raw; 8 //struct CUdevprop 9 static struct Info 10 { 11 @(1) int maxThreadsPerBlock; 12 @(2) int maxThreadsDimX; 13 @(3) int maxThreadsDimY; 14 @(4) int maxThreadsDimZ; 15 @(5) int maxGridSizeX; 16 @(6) int maxGridSizeY; 17 @(7) int maxGridSizeZ; 18 @(8) int sharedMemPerBlock; 19 @(9) int totalConstantMemory; 20 @(10) int SIMDWidth; // warp size 21 @(11) int maxPitch; 22 @(12) int regsPerBlock; 23 @(13) int clockRate; 24 @(14) int textureAlign; 25 @(15) int GPUOverlap; 26 @(16) int multiprocessorCount; 27 @(17) int kernelExecTimeout; 28 @(18) int integrated; 29 @(19) int canMapHostMemeory; 30 @(20) int computeMode; 31 @(21) int maxTexture1DWidth; 32 @(22) int maxTexture2DWidth; 33 @(23) int maxTexture2DHeight; 34 @(24) int maxTexture3DWidth; 35 @(25) int maxTexture3DHeight; 36 @(26) int maxTexture3DDepth; 37 @(27) int maxTexture2DLayeredWidth; 38 @(28) int maxTexture2DLayeredHeight; 39 @(29) int maxTexture2DLayeredLayers; 40 @(27) int maxTexture2DArrayWidth; 41 @(28) int maxTexture2DArrayHeight; 42 @(29) int maxTexture2DArrayNumSlices; 43 @(30) int surfaceAlignment; 44 @(31) int concurrentKernels; 45 @(32) int eccEnabled; 46 @(33) int PCIBusID; 47 @(34) int PCIDeviceID; 48 @(35) int tccDriver; 49 @(36) int memoryClockRate; 50 @(37) int globalMemoryBusWidth; 51 @(38) int L2CacheSize; 52 @(39) int maxThreadPerMultiProcessor; 53 @(40) int asyncEngineCount; 54 @(41) int unifiedAddressing; 55 @(42) int maxTexture1DLayeredWidth; 56 @(43) int maxTexture1DLayeredLayers; 57 @(44) int canTex2DGather; 58 @(45) int maxTextrue2DGatherWidth; 59 @(46) int maxTextrue2DGatherHeight; 60 @(47) int maxTexture3DWidthAlternative; 61 @(48) int maxTexture3DHeightAlternative; 62 @(49) int maxTexture3DDepthAlternative; 63 @(50) int PICDomainID; 64 @(51) int texturePitchAlignment; 65 @(52) int textureCubemapWidth; 66 @(53) int textureCubemapLayeredWidths; 67 @(54) int textureCubemapLayeredLayers; 68 @(55) int maxSurface1DWidth; 69 @(56) int maxSurface2DWidth; 70 @(57) int maxSurface2DHeight; 71 @(58) int maxSurface3DWidth; 72 @(59) int maxSurface3DHeight; 73 @(60) int maxSurface3DDepth; 74 @(61) int maxSurface1DLayeredWidth; 75 @(62) int maxSurface1DLayeredLayers; 76 @(63) int maxSurface2DLayeredWidth; 77 @(64) int maxSurface2DLayeredHeight; 78 @(65) int maxSurface2DLayeredLayers; 79 @(66) int maxSurfaceCubemapWidth; 80 @(67) int maxSurfaceCubemapLayeredWidth; 81 @(68) int maxSurfaceCubemapLayeredLayers; 82 @(69) int maxTaxture1DLinearWidth; 83 @(70) int maxTaxture2DLinearWidth; 84 @(71) int maxTaxture2DLinearHeight; 85 @(72) int maxTaxture2DLinearPitch; 86 @(73) int maxTaxture2DMipmappedWidth; 87 @(74) int maxTaxture2DMipmappedHeight; 88 @(75) int computeCapabilityMajor; 89 @(76) int computeCapabilityMinor; 90 @(77) int maxTaxture1DMipmappedWidth; 91 @(78) int streamPrioritiesSupported; 92 @(79) int globalL1CacheSupported; 93 @(80) int localL1CacheSupported; 94 @(81) int maxSharedMemoryPerMultiprocessor; 95 @(82) int maxRegistorsPerMultiprocessor; 96 @(83) int managedMemory; 97 @(84) int multiGPUBoard; 98 @(85) int multiGPUBoardGroupID; 99 } 100 101 @property size_t totalMemory() 102 { 103 size_t ret; 104 status = cast(Status)cuDeviceTotalMem(&ret,raw); 105 checkErrors(); 106 return ret; 107 } 108 109 //char[] name : cuDeviceGetName 110 111 static foreach (mem; __traits(allMembers, Info)) { 112 mixin( 113 ` @property int `, 114 mem, 115 ` () { int result; `, 116 ` status = cast(Status)cuDeviceGetAttribute( `, 117 ` &result, `, 118 __traits(getAttributes, __traits(getMember, Info, mem))[0].stringof, 119 `, raw); `, 120 ` checkErrors(); `, 121 ` return result; `, 122 ` } `); 123 } 124 }