1 module dcompute.driver.ocl.kernel; 2 3 import dcompute.driver.ocl; 4 5 struct Kernel(F) if (is(F == function) || is(F==void)) 6 { 7 cl_kernel raw; 8 9 static struct Info 10 { 11 @(0x1190) immutable char* _name; 12 StringzAccessor!(_name) name; 13 @(0x1191) uint numArgs; 14 @(0x1192) uint referenceCount; 15 @(0x1193) Context context; 16 @(0x1194) Program program; 17 @(0x1195) immutable char* _attributes; 18 StringzAccessor!(_attributes) attributes; 19 } 20 //mixin(generateGetInfo!(Info,clGetKernelInfo)); 21 void retain() 22 { 23 status = cast(Status)clRetainKernel(raw); 24 checkErrors(); 25 } 26 27 void release() 28 { 29 status = cast(Status)clReleaseKernel(raw); 30 checkErrors(); 31 } 32 33 void setArg(T)(uint index,T val) 34 { 35 status = cast(Status)clSetKernelArg(this.raw,index,T.sizeof,&val); 36 checkErrors(); 37 } 38 } 39 40 struct Arg 41 { 42 Kernel!void kernel; 43 uint argIndex; 44 enum AddressQualifier 45 { 46 global = 0x119B, 47 local = 0x119C, 48 constant = 0x119D, 49 private_ = 0x119E, 50 } 51 52 enum AccessQualifier 53 { 54 readOnly = 0x11A0, 55 writeOnly = 0x11A1, 56 readWrite = 0x11A2, 57 none = 0x11A3, 58 } 59 60 enum TypeQualifier 61 { 62 none = 0, 63 const_ = 1 << 0, 64 restrict = 1 << 1, 65 volatile = 1 << 2, 66 } 67 68 static struct Info 69 { 70 @(0x1196) AddressQualifier addressQualifier; 71 @(0x1197) AccessQualifier accessQualifier; 72 @(0x1198) immutable char* _typeName; 73 StringzAccessor!(_typeName) typeName; 74 @(0x1199) TypeQualifier typeQualifier; 75 @(0x119A) immutable char* _name; 76 StringzAccessor!(_name) name; 77 } 78 79 //mixin(generateGetInfo!(Info,clGetKernelArgInfo,"kernel.raw,argIndex")); 80 } 81 82 struct WorkGroup 83 { 84 Kernel!void kernel; 85 Device device; 86 static struct Info 87 { 88 @(0x11B0) size_t workGroupSize; 89 @(0x11B1) size_t[3] requiredWorkGroupSize; 90 @(0x11B2) ulong localMemorySize; 91 @(0x11B3) size_t preferredWorkGroupSizeMultiple; 92 @(0x11B4) ulong privateMemSize; 93 @(0x11B5) size_t[3] globalWorkSize; 94 } 95 96 //mixin(generateGetInfo!(Info,clGetKernelWorkGroupInfo,"kernel.raw,device.raw")); 97 }