| 1 | | Note: err is just an int that will say whether the function executed properly, not part of translation at this time. |
| 2 | | |
| 3 | | This iteration of the transformation is rather basic, with functions broken down into bare essentials. They may be transformed into slightly more complicated functions as time goes on. For now, here is what their equivalents are, using example code: |
| 4 | | |
| 5 | | err = clGetDeviceIDs(NULL, gpu ? CL_DEVICE_TYPE_GPU : CL_DEVICE_TYPE_CPU, 1, &device_id, NULL); |
| 6 | | |
| 7 | | This function in openCL will query for devices then put their ID into the pointer &device_id. In the transformation it puts in arbitrary numbers for ID. |
| 8 | | |
| 9 | | This only takes up the 3rd and 4th parameter, the 3rd for the number of devices, but also uses the name of the pointer in the 4th place. Note that the part for picking a device actually comes from clCreateCommandQueue, and if multiple devices are not used then the device at index 0 is used |
| 10 | | {{{ |
| 11 | | int clGetDeviceIDs(int numEntries, cl_device_id * devices) |
| 12 | | { |
| 13 | | for (int i=0; i<numEntries; i++) { |
| 14 | | devices[i].id = i; |
| 15 | | // exactly equivalent to: (devices+i)->id = i |
| 16 | | } |
| 17 | | return CL_SUCCESS; |
| 18 | | } |
| 19 | | }}} |
| 20 | | |
| 21 | | kernel = clCreateKernel(program, "square", &err); |
| 22 | | |
| 23 | | Creates the kernel using data from the program, and the name of the function. In the transformation it chooses which function to use. |
| 24 | | |
| 25 | | {{{ |
| 26 | | cl_kernel clCreateKernel(args * argument) |
| 27 | | { |
| 28 | | cl_kernel kernel; |
| 29 | | kernel.arguments = argument; |
| 30 | | |
| 31 | | return kernel; |
| 32 | | } |
| 33 | | }}} |
| 34 | | |
| 35 | | args is a struct containing all of the variables that will be passed into a kernel, for example |
| | 1 | * 'args' : a struct containing all of the variables that will be passed into a kernel. Uses an array of void pointers. |