#include "cl.cvl" $input int DEVICE_ID; $input int DEVICE_ID_BOUND; $assume 0 < DEVICE_ID && DEVICE_ID < DEVICE_ID_BOUND; int clGetDeviceIDs(cl_platform_id platform, cl_device_type device_type, cl_uint num_entries, cl_device_id *devices, cl_uint *num_devices) { //$assume device_type == CL_DEVICE_TYPE_DEFAULT; int i = 0; //cl_platform_id int value can be null //num_entries number of devices that can be added /* if(num_entries == 0 && devices != 0) { return CL_INVALID_VALUE; } if(num_entries == 0 && devices == 0) { return CL_INVALID_VALUE; } */ //device_type type a bitfield that somehow gets type of OpenCL device //use the device types, look in openCLtypes and look for CL_DEVICE_TYPE_... /* if(device_type & (CL_DEVICE_TYPE_DEFAULT | CL_DEVICE_TYPE_CPU | CL_DEVICE_TYPE_GPU | CL_DEVICE_TYPE_ACCELERATOR | CL_DEVICE_TYPE_CUSTOM | CL_DEVICE_TYPE_ALL)) { */ while (i < num_entries) { if(devices) { devices[0] = (cl_device_id)(&DEVICE_ID); //how to say "use anything"? i++; } else { break; } } if (num_devices) { *num_devices = i; } //} /* else { return CL_DEVICE_NOT_FOUND; } */ //*devices list of devices found, use //cl_device_id device_id; //&device_id return CL_SUCCESS; } cl_context clCreateContext(const cl_context_properties *properties, cl_uint num_devices, const cl_device_id * devices, void (CL_CALLBACK *pfn_notify)(const char *, const void *, size_t, void *), void * user_data, cl_int * errcode_ret) { cl_int default_errcode_ret; if(!errcode_ret) { errcode_ret = &default_errcode_ret; } /* if (!devices || !num_devices || !pfn_notify && user_data}} { *errcode_ret = CL_INVALID_VALUE; return 0; } */ *errcode_ret = CL_SUCCESS; cl_context *ctx; ctx->properties = properties; ctx->num_devices = num_devices; ctx->devices = devices; ctx->pfn_notify = pfn_notify; ctx->user_data = user_data; ctx->errcode_ret = errorcode_ret; /* if(*errcode_ret != CL_SUCCESS) { delete ctx; return 0; } */ return(_cl_context*) ctx; }