I was looking to rearrange some bits of code so that I follow some order and while both versions compile and run, the second version has a runtime error. Essentially I switch lines 2 and 3 and I get a runtime error. The reason I want to switch them is that I wanted to organize the code based on the type (global, constant, texture, etc). Why is there an error?
Version 1:
[codebox]
// Copy image data from host to device
error = clEnqueueWriteBuffer(command_queue, c_dev_matrix, CL_FALSE, 0, matrix_size, &kargs->matrix, 0, NULL, &device_event_1);
error |= clEnqueueWriteBuffer(command_queue, dev_img, CL_FALSE, 0, img_size, cbi->img, 0, NULL, &device_event_2);
oclCheckError(error, CL_SUCCESS);
clFinish(command_queue);
[/codebox]
Version 2:
[codebox]
// Copy image data from host to device
error = clEnqueueWriteBuffer(command_queue, dev_img, CL_FALSE, 0, img_size, cbi->img, 0, NULL, &device_event_2);
error |= clEnqueueWriteBuffer(command_queue, c_dev_matrix, CL_FALSE, 0, matrix_size, &kargs->matrix, 0, NULL, &device_event_1);
oclCheckError(error, CL_SUCCESS);
clFinish(command_queue);
[/codebox]
Setting of the arguments:
[codebox]
error |= clSetKernelArg(fdk_kernel, 0, sizeof(cl_mem), (void *) &g_dev_vol);
error |= clSetKernelArg(fdk_kernel, 1, sizeof(cl_mem), (void *) &c_img_dim);
error |= clSetKernelArg(fdk_kernel, 2, sizeof(cl_mem), (void *) &c_ic);
error |= clSetKernelArg(fdk_kernel, 3, sizeof(cl_mem), (void *) &c_nrm);
error |= clSetKernelArg(fdk_kernel, 4, sizeof(cl_mem), (void *) &c_sad);
error |= clSetKernelArg(fdk_kernel, 5, sizeof(cl_mem), (void *) &c_scale);
error |= clSetKernelArg(fdk_kernel, 6, sizeof(cl_mem), (void *) &c_vol_offset);
error |= clSetKernelArg(fdk_kernel, 7, sizeof(cl_mem), (void *) &c_vol_dim);
error |= clSetKernelArg(fdk_kernel, 8, sizeof(cl_mem), (void *) &c_vol_pix_spacing);
error |= clSetKernelArg(fdk_kernel, 9, sizeof(cl_mem), (void *) &c_dev_matrix);
error |= clSetKernelArg(fdk_kernel, 10, sizeof(cl_mem), (void *) &t_dev_img);
oclCheckError(error, CL_SUCCESS);
[/codebox]
Relevant kernel code:
[codebox]
__kernel void kernel_fdk(
__global float *dev_vol,
__constant int2 *img_dim,
__constant float2 *ic,
__constant float4 *nrm,
__constant float *sad,
__constant float *scale,
__constant float4 *vol_offset,
__constant int4 *vol_dim,
__constant float4 *vol_pix_spacing,
__constant float *dev_matrix,
__global float *dev_img
)
[/codebox]
Error:
[codebox]
007B7A58 (0x00000000 0x00000000 0x00000000 0x00000000), cuSurfRefGetFormat()+744
24 bytes(s)
[/codebox]
Thanks for the help!!!