2013-02-17 107 views
0

當使用clSetKernelArg(memory_object)設置內核參數並使用clEnqueueNDKernelRangeKernel()多次調用內核時,您以前在內核的clSetKernelArg()中將參數設置爲的memory_object是從主機傳輸到GPU,每次調用內核?opencl中的多個內核調用

status = clSetKernelArg(kernel, 0, sizeof(cl_mem), &inbuf); 



    size_t num_total_wi = M * N; 
    size_t num_wg = num_elem/N + ((num_elem/N == 0) ? 0 : 1); 
    size_t num_iter = num_elem/(num_total_wi) + (((num_elem % (num_total_wi)) == 0) ?  0 : 1); 
    for(i = 0; i < num_iter; i++) { 
      size_t global_work_size[3] = {num_total_wi, 1, 1};  
      size_t local_ws[3] = {N, 1, 1}; 
      size_t global_offset[3] = {i * num_total_wi, 0, 0}; 

      clEnqueueNDRangeKernel(queue, kernel, 1, global_offset, global_work_size, local_ws, 0, NULL, NULL); 

    } 

回答

0

存儲器傳輸是通過調用開始clEnqueueWriteBufferclEnqueueWriteImage但當clEnqueueNDRangeKernel被稱爲最有可能啓動。一旦數據傳輸完畢,您可以隨意重複使用內存對象,如果您沒有再次明確說明,它將不會再次傳輸。