Uni Ibkからのあなたですか?関数はcl_utils.hから取得しました。しかし、ここにコードがあります。
cl_device_id cluInitDevice(size_t num, cl_context *out_context, cl_command_queue *out_queue) {
// get platform ids
cl_uint ret_num_platforms;
CLU_ERRCHECK(clGetPlatformIDs(0, NULL, &ret_num_platforms), "Failed to query number of ocl platforms");
cl_platform_id *ret_platforms = (cl_platform_id*)alloca(sizeof(cl_platform_id)*ret_num_platforms);
CLU_ERRCHECK(clGetPlatformIDs(ret_num_platforms, ret_platforms, NULL), "Failed to retrieve ocl platforms");
// get device id of desired device
cl_device_id device_id = NULL;
for(cl_uint i=0; i<ret_num_platforms; ++i) {
cl_uint ret_num_devices;
CLU_ERRCHECK(clGetDeviceIDs(ret_platforms[i], CL_DEVICE_TYPE_ALL, 0, NULL, &ret_num_devices), "Failed to query number of ocl devices");
if(num < ret_num_devices) {
// desired device is on this platform, select
cl_device_id *ret_devices = (cl_device_id*)alloca(sizeof(cl_device_id)*ret_num_devices);
CLU_ERRCHECK(clGetDeviceIDs(ret_platforms[i], CL_DEVICE_TYPE_ALL, ret_num_devices, ret_devices, NULL), "Failed to retrieve ocl devices");
device_id = ret_devices[num];
}
num -= ret_num_devices;
}
// create opencl context if requested
if(out_context != NULL) {
cl_int err;
*out_context = clCreateContext(NULL, 1, &device_id, NULL, NULL, &err);
CLU_ERRCHECK(err, "Failed to create ocl context");
// create command queue if requested
if(out_queue != NULL) {
*out_queue = clCreateCommandQueue(*out_context, device_id, 0, &err);
CLU_ERRCHECK(err, "Failed to create ocl command queue");
}
}
return device_id;
}
'cl_device_id DEVICE_ID = cluInitDevice(CL_DEVICE、&コンテキスト、&command_queue);'、標準APIコールではないカスタム・コールです。そのコードは何をしていますか?制約は何ですか?どうか明らかにしてください。 – DarkZeros