| [e01b89d] | 1 |
|
|---|
| [9c7b25c] | 2 | #include "cl.cvl"
|
|---|
| [0744ab0] | 3 | #include <stdlib.h>
|
|---|
| [e01b89d] | 4 |
|
|---|
| 5 | $input int DEVICE_ID;
|
|---|
| 6 | $input int DEVICE_ID_BOUND;
|
|---|
| 7 |
|
|---|
| 8 | $assume 0 < DEVICE_ID && DEVICE_ID < DEVICE_ID_BOUND;
|
|---|
| [6267964] | 9 |
|
|---|
| 10 |
|
|---|
| [9c7b25c] | 11 |
|
|---|
| [e01b89d] | 12 |
|
|---|
| [9c7b25c] | 13 | int clGetDeviceIDs(cl_platform_id platform,
|
|---|
| 14 | cl_device_type device_type,
|
|---|
| 15 | cl_uint num_entries,
|
|---|
| 16 | cl_device_id *devices,
|
|---|
| [e01b89d] | 17 | cl_uint *num_devices)
|
|---|
| 18 | {
|
|---|
| [9c7b25c] | 19 | //$assume device_type == CL_DEVICE_TYPE_DEFAULT;
|
|---|
| [e01b89d] | 20 | int i = 0;
|
|---|
| 21 | //cl_platform_id int value can be null
|
|---|
| 22 |
|
|---|
| 23 | //num_entries number of devices that can be added
|
|---|
| [9c7b25c] | 24 | /*
|
|---|
| [e01b89d] | 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 | }
|
|---|
| [9c7b25c] | 34 | */
|
|---|
| [e01b89d] | 35 | //device_type type a bitfield that somehow gets type of OpenCL device
|
|---|
| [9c7b25c] | 36 | //use the device types, look in openCLtypes and look for CL_DEVICE_TYPE_...
|
|---|
| 37 |
|
|---|
| [6777880] | 38 | /*
|
|---|
| [e01b89d] | 39 | if(device_type & (CL_DEVICE_TYPE_DEFAULT | CL_DEVICE_TYPE_CPU |
|
|---|
| 40 | CL_DEVICE_TYPE_GPU | CL_DEVICE_TYPE_ACCELERATOR |
|
|---|
| [9c7b25c] | 41 | CL_DEVICE_TYPE_CUSTOM | CL_DEVICE_TYPE_ALL))
|
|---|
| [e01b89d] | 42 | {
|
|---|
| [6777880] | 43 | */
|
|---|
| [e01b89d] | 44 | while (i < num_entries)
|
|---|
| 45 | {
|
|---|
| 46 | if(devices)
|
|---|
| 47 | {
|
|---|
| [9c7b25c] | 48 | devices[0] = (cl_device_id)(&DEVICE_ID);
|
|---|
| [e01b89d] | 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 | }
|
|---|
| [6777880] | 62 | //}
|
|---|
| [9c7b25c] | 63 | /*
|
|---|
| [e01b89d] | 64 | else
|
|---|
| 65 | {
|
|---|
| 66 | return CL_DEVICE_NOT_FOUND;
|
|---|
| 67 | }
|
|---|
| [9c7b25c] | 68 | */
|
|---|
| [e01b89d] | 69 | //*devices list of devices found, use
|
|---|
| 70 | //cl_device_id device_id;
|
|---|
| 71 | //&device_id
|
|---|
| 72 |
|
|---|
| 73 | return CL_SUCCESS;
|
|---|
| 74 |
|
|---|
| 75 | }
|
|---|
| [9c7b25c] | 76 |
|
|---|
| 77 |
|
|---|
| [6267964] | 78 |
|
|---|
| 79 |
|
|---|
| [9c7b25c] | 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;
|
|---|
| [6267964] | 88 |
|
|---|
| [9c7b25c] | 89 | if(!errcode_ret)
|
|---|
| [6267964] | 90 | {
|
|---|
| [9c7b25c] | 91 | errcode_ret = &default_errcode_ret;
|
|---|
| [6267964] | 92 | }
|
|---|
| [0744ab0] | 93 |
|
|---|
| 94 | if (!devices || !num_devices || (!pfn_notify && user_data))
|
|---|
| [6267964] | 95 | {
|
|---|
| 96 | *errcode_ret = CL_INVALID_VALUE;
|
|---|
| 97 | return 0;
|
|---|
| 98 | }
|
|---|
| [0744ab0] | 99 |
|
|---|
| [6267964] | 100 | *errcode_ret = CL_SUCCESS;
|
|---|
| [0744ab0] | 101 | cl_context ctx;
|
|---|
| 102 | ctx = (cl_context)malloc(sizeof(_cl_context));
|
|---|
| [6267964] | 103 |
|
|---|
| [0744ab0] | 104 |
|
|---|
| [6267964] | 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;
|
|---|
| [0744ab0] | 110 | ctx->errcode_ret = errcode_ret;
|
|---|
| 111 |
|
|---|
| 112 |
|
|---|
| [6267964] | 113 | if(*errcode_ret != CL_SUCCESS)
|
|---|
| 114 | {
|
|---|
| [0744ab0] | 115 | //delete ctx;
|
|---|
| [6267964] | 116 | return 0;
|
|---|
| 117 | }
|
|---|
| [0744ab0] | 118 |
|
|---|
| 119 | return(cl_context) ctx;
|
|---|
| [6267964] | 120 |
|
|---|
| [9c7b25c] | 121 | }
|
|---|
| [0744ab0] | 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 | }
|
|---|
| [9c7b25c] | 135 |
|
|---|
| 136 |
|
|---|