| [cc87898] | 1 |
|
|---|
| 2 | //clCreateProgram for each individual one, because the struct args is defined here
|
|---|
| 3 | cl_program clCreateProgram(args * argument)
|
|---|
| 4 | {
|
|---|
| 5 | cl_program program;
|
|---|
| 6 | program.arguments = argument;
|
|---|
| 7 |
|
|---|
| 8 | return program;
|
|---|
| 9 | }
|
|---|
| 10 |
|
|---|
| 11 | /*
|
|---|
| 12 | int clSetKernelArg(cl_kernel kernel, int index, size_t size, void * value)
|
|---|
| 13 | {
|
|---|
| 14 | if (index == 0)
|
|---|
| 15 | {
|
|---|
| 16 | kernel.program.arguments.input = (int *)malloc(size);
|
|---|
| 17 | }
|
|---|
| 18 |
|
|---|
| 19 | return CL_SUCCESS;
|
|---|
| 20 | }
|
|---|
| 21 | */
|
|---|
| 22 |
|
|---|
| 23 | /*
|
|---|
| 24 | Inserts devices based on the number of entries, and unlike the openCL version, is the exact number not the maximum
|
|---|
| 25 | int numEntries - Number of devices to be inputted
|
|---|
| 26 | cl_device_id * devices- pointer to devices
|
|---|
| 27 | */
|
|---|
| 28 | int clGetDeviceIDs(int numEntries, cl_device_id * devices)
|
|---|
| 29 | {
|
|---|
| 30 | for (int i=0; i<numEntries; i++) {
|
|---|
| 31 | devices[i].id = i;
|
|---|
| 32 | // exactly equivalent to: (devices+i)->id = i
|
|---|
| 33 | }
|
|---|
| 34 | return CL_SUCCESS;
|
|---|
| 35 | }
|
|---|
| 36 |
|
|---|
| 37 | /*
|
|---|
| 38 | Creates a command queue based off of the device inputted, must be called as many times as needed
|
|---|
| 39 | cl_device_id devices - the device to be put into the queue
|
|---|
| 40 | */
|
|---|
| 41 | cl_command_queue clCreateCommandQueue(cl_device_id devices)
|
|---|
| 42 | {
|
|---|
| 43 | cl_command_queue queue;
|
|---|
| 44 |
|
|---|
| 45 | queue.device = devices;
|
|---|
| 46 |
|
|---|
| 47 | return queue;
|
|---|
| 48 | }
|
|---|
| 49 | //would pick the kernel by name, but not currently in place
|
|---|
| 50 |
|
|---|
| 51 | //example usage of the methods above
|
|---|
| 52 | int err = clGetDeviceIDs(1, &device_id);
|
|---|
| 53 |
|
|---|
| 54 | //ignore clCreateContext for now, until we get an example that uses multiple ones
|
|---|
| 55 |
|
|---|
| 56 | //clCreateCommandQueue, could use context later
|
|---|
| 57 | commands = clCreateCommandQueue(device_id); |
|---|