| 1 |
|
|---|
| 2 | #include "cl.cvl"
|
|---|
| 3 | #include <stdlib.h>
|
|---|
| 4 |
|
|---|
| 5 | $input int DEVICE_ID;
|
|---|
| 6 | $input int DEVICE_ID_BOUND;
|
|---|
| 7 |
|
|---|
| 8 | $assume 0 < DEVICE_ID && DEVICE_ID < DEVICE_ID_BOUND;
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 | int clGetDeviceIDs(cl_platform_id platform,
|
|---|
| 14 | cl_device_type device_type,
|
|---|
| 15 | cl_uint num_entries,
|
|---|
| 16 | cl_device_id *devices,
|
|---|
| 17 | cl_uint *num_devices)
|
|---|
| 18 | {
|
|---|
| 19 | //$assume device_type == CL_DEVICE_TYPE_DEFAULT;
|
|---|
| 20 | int i = 0;
|
|---|
| 21 | //cl_platform_id int value can be null
|
|---|
| 22 |
|
|---|
| 23 | //num_entries number of devices that can be added
|
|---|
| 24 | /*
|
|---|
| 25 | if(num_entries == 0 && devices != 0)
|
|---|
| 26 | {
|
|---|
| 27 | return CL_INVALID_VALUE;
|
|---|
| 28 | }
|
|---|
| 29 |
|
|---|
| 30 | if(num_entries == 0 && devices == 0)
|
|---|
| 31 | {
|
|---|
| 32 | return CL_INVALID_VALUE;
|
|---|
| 33 | }
|
|---|
| 34 | */
|
|---|
| 35 | //device_type type a bitfield that somehow gets type of OpenCL device
|
|---|
| 36 | //use the device types, look in openCLtypes and look for CL_DEVICE_TYPE_...
|
|---|
| 37 |
|
|---|
| 38 | /*
|
|---|
| 39 | if(device_type & (CL_DEVICE_TYPE_DEFAULT | CL_DEVICE_TYPE_CPU |
|
|---|
| 40 | CL_DEVICE_TYPE_GPU | CL_DEVICE_TYPE_ACCELERATOR |
|
|---|
| 41 | CL_DEVICE_TYPE_CUSTOM | CL_DEVICE_TYPE_ALL))
|
|---|
| 42 | {
|
|---|
| 43 | */
|
|---|
| 44 | while (i < num_entries)
|
|---|
| 45 | {
|
|---|
| 46 | if(devices)
|
|---|
| 47 | {
|
|---|
| 48 | devices[0] = (cl_device_id)(&DEVICE_ID);
|
|---|
| 49 | //how to say "use anything"?
|
|---|
| 50 | i++;
|
|---|
| 51 | }
|
|---|
| 52 | else
|
|---|
| 53 | {
|
|---|
| 54 | break;
|
|---|
| 55 | }
|
|---|
| 56 |
|
|---|
| 57 | }
|
|---|
| 58 | if (num_devices)
|
|---|
| 59 | {
|
|---|
| 60 | *num_devices = i;
|
|---|
| 61 | }
|
|---|
| 62 | //}
|
|---|
| 63 | /*
|
|---|
| 64 | else
|
|---|
| 65 | {
|
|---|
| 66 | return CL_DEVICE_NOT_FOUND;
|
|---|
| 67 | }
|
|---|
| 68 | */
|
|---|
| 69 | //*devices list of devices found, use
|
|---|
| 70 | //cl_device_id device_id;
|
|---|
| 71 | //&device_id
|
|---|
| 72 |
|
|---|
| 73 | return CL_SUCCESS;
|
|---|
| 74 |
|
|---|
| 75 | }
|
|---|
| 76 |
|
|---|
| 77 |
|
|---|
| 78 |
|
|---|
| 79 |
|
|---|
| 80 | cl_context clCreateContext(const cl_context_properties *properties,
|
|---|
| 81 | cl_uint num_devices,
|
|---|
| 82 | const cl_device_id * devices,
|
|---|
| 83 | void (CL_CALLBACK *pfn_notify)(const char *, const void *, size_t, void *),
|
|---|
| 84 | void * user_data,
|
|---|
| 85 | cl_int * errcode_ret)
|
|---|
| 86 | {
|
|---|
| 87 | cl_int default_errcode_ret;
|
|---|
| 88 |
|
|---|
| 89 | if(!errcode_ret)
|
|---|
| 90 | {
|
|---|
| 91 | errcode_ret = &default_errcode_ret;
|
|---|
| 92 | }
|
|---|
| 93 |
|
|---|
| 94 | if (!devices || !num_devices || (!pfn_notify && user_data))
|
|---|
| 95 | {
|
|---|
| 96 | *errcode_ret = CL_INVALID_VALUE;
|
|---|
| 97 | return 0;
|
|---|
| 98 | }
|
|---|
| 99 |
|
|---|
| 100 | *errcode_ret = CL_SUCCESS;
|
|---|
| 101 | cl_context ctx;
|
|---|
| 102 | ctx = (cl_context)malloc(sizeof(_cl_context));
|
|---|
| 103 |
|
|---|
| 104 |
|
|---|
| 105 | ctx->properties = properties;
|
|---|
| 106 | ctx->num_devices = num_devices;
|
|---|
| 107 | ctx->devices = devices;
|
|---|
| 108 | ctx->pfn_notify = pfn_notify;
|
|---|
| 109 | ctx->user_data = user_data;
|
|---|
| 110 | ctx->errcode_ret = errcode_ret;
|
|---|
| 111 |
|
|---|
| 112 |
|
|---|
| 113 | if(*errcode_ret != CL_SUCCESS)
|
|---|
| 114 | {
|
|---|
| 115 | //delete ctx;
|
|---|
| 116 | return 0;
|
|---|
| 117 | }
|
|---|
| 118 |
|
|---|
| 119 | return(cl_context) ctx;
|
|---|
| 120 |
|
|---|
| 121 | }
|
|---|
| 122 | /*
|
|---|
| 123 | cl_command_queue clCreateCommandQueue(cl_context context,
|
|---|
| 124 | cl_device_id device,
|
|---|
| 125 | cl_command_queue_properties properties,
|
|---|
| 126 | cl_int* errcode_ret)
|
|---|
| 127 | {
|
|---|
| 128 |
|
|---|
| 129 |
|
|---|
| 130 | }
|
|---|
| 131 | */
|
|---|
| 132 | cl_command_queue clCreateCommandQueue(cl_context context)
|
|---|
| 133 | {
|
|---|
| 134 | }
|
|---|
| 135 |
|
|---|
| 136 |
|
|---|