2016-10-18 4 views
0

私はOpenCLプログラムを持っており、データ転送とカーネル実行時間の測定を行いたいと思います。OpenCLカーネルタイミング

私はを "有効プロファイリングとキューの作成" が、

command_queue = clCreateCommandQueue(context, CL_DEVICE, CL_QUEUE_PROFILING_ENABLE, &err);

行の後にいくつかを作る

cl_device_id device_id = cluInitDevice(CL_DEVICE, &context, &command_queue);

行があるでこれを実行しようとしましたコンテキスト制約のために問題が発生します。

この制約はどのように処理できますか?

ありがとうございました。

+1

'cl_device_id DEVICE_ID = cluInitDevice(CL_DEVICE、&コンテキスト、&command_queue);'、標準APIコールではないカスタム・コールです。そのコードは何をしていますか?制約は何ですか?どうか明らかにしてください。 – DarkZeros

答えて

0

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; 

}