我寫了下面的C++代碼。在clSetKernelArg(kernel, 8, sizeof(cl_mem), (void *) &mob_whdis);
,它返回error code -49
,我不明白爲什麼。其他一切正常運行。誰能幫我?clSetKernelArg返回錯誤代碼-49
cl_mem mob_X = NULL;
cl_mem mob_Y = NULL;
cl_mem mob_Z = NULL;
cl_mem mob_WAT = NULL;
cl_mem mob_POL = NULL;
cl_mem mob_FSW = NULL;
cl_mem mob_nop = NULL;
cl_mem mob_nofsw = NULL;
cl_mem mob_whdis = NULL;
cl_mem mob_watwp = NULL;
cl_mem mob_watp = NULL;
cl_mem mob_distp = NULL;
cl_mem mob_watww = NULL;
cl_mem mob_watw = NULL;
cl_mem mob_distw = NULL;
cl_program program = NULL;
cl_kernel kernel = NULL;
cl_uint ret_num_devices;
cl_uint ret_num_platforms;
cl_int err;
float whdis=3.5;
mob_X = clCreateBuffer(context, CL_MEM_READ_WRITE, na * sizeof(float), NULL, &err);
mob_Y = clCreateBuffer(context, CL_MEM_READ_WRITE, na * sizeof(float), NULL, &err);
mob_Z = clCreateBuffer(context, CL_MEM_READ_WRITE, na * sizeof(float), NULL, &err);
mob_WAT = clCreateBuffer(context, CL_MEM_READ_WRITE, now * sizeof(int), NULL, &err);
mob_POL = clCreateBuffer(context, CL_MEM_READ_WRITE, nop * sizeof(int), NULL, &err);
mob_FSW = clCreateBuffer(context, CL_MEM_READ_WRITE, now * sizeof(int), NULL, &err);
mob_nop = clCreateBuffer(context, CL_MEM_READ_WRITE, sizeof(int), NULL, &err);
mob_nofsw = clCreateBuffer(context, CL_MEM_READ_WRITE, sizeof(int), NULL, &err);
mob_whdis = clCreateBuffer(context, CL_MEM_READ_WRITE, sizeof(float), NULL, &err);
mob_watwp = clCreateBuffer(context, CL_MEM_READ_WRITE, sizeof(int) * now * 40, NULL, &err);
mob_watp = clCreateBuffer(context, CL_MEM_READ_WRITE, sizeof(int) * now * 40, NULL, &err);
mob_distp = clCreateBuffer(context, CL_MEM_READ_WRITE, sizeof(float) * now * 40, NULL, &err);
mob_watww = clCreateBuffer(context, CL_MEM_READ_WRITE, sizeof(int) * now * 40, NULL, &err);
mob_watw = clCreateBuffer(context, CL_MEM_READ_WRITE, sizeof(int) * now * 40, NULL, &err);
mob_distw = clCreateBuffer(context, CL_MEM_READ_WRITE, sizeof(float) * now * 40, NULL, &err);
err = clEnqueueWriteBuffer(command_queue, mob_X, CL_TRUE, 0, na * sizeof(float), X, 0, NULL, NULL);
err = clEnqueueWriteBuffer(command_queue, mob_Y, CL_TRUE, 0, na * sizeof(float), Y, 0, NULL, NULL);
err = clEnqueueWriteBuffer(command_queue, mob_Z, CL_TRUE, 0, na * sizeof(float), Z, 0, NULL, NULL);
err = clEnqueueWriteBuffer(command_queue, mob_WAT, CL_TRUE, 0, now * sizeof(int), wat, 0, NULL, NULL);
err = clEnqueueWriteBuffer(command_queue, mob_POL, CL_TRUE, 0, nop * sizeof(int), pol, 0, NULL, NULL);
err = clEnqueueWriteBuffer(command_queue, mob_FSW, CL_TRUE, 0, now * sizeof(int), fsw, 0, NULL, NULL);
err = clEnqueueWriteBuffer(command_queue, mob_nop, CL_TRUE, 0, sizeof(int), &nop, 0, NULL, NULL);
err = clEnqueueWriteBuffer(command_queue, mob_nofsw, CL_TRUE, 0, sizeof(int), &nofsw, 0, NULL, NULL);
err = clEnqueueWriteBuffer(command_queue, mob_whdis, CL_TRUE, 0, sizeof(float), &whdis, 0, NULL, NULL);
err_check(err, "clSetKernelArg");
err = clSetKernelArg(kernel, 0, sizeof(cl_mem), (void *) &mob_X);
err = clSetKernelArg(kernel, 1, sizeof(cl_mem), (void *) &mob_Y);
err = clSetKernelArg(kernel, 2, sizeof(cl_mem), (void *) &mob_Z);
err = clSetKernelArg(kernel, 3, sizeof(cl_mem), (void *) &mob_WAT);
err = clSetKernelArg(kernel, 4, sizeof(cl_mem), (void *) &mob_POL);
err = clSetKernelArg(kernel, 5, sizeof(cl_mem), (void *) &mob_FSW);
err = clSetKernelArg(kernel, 6, sizeof(cl_mem), (void *) &mob_nop);
err = clSetKernelArg(kernel, 7, sizeof(cl_mem), (void *) &mob_nofsw);
err = clSetKernelArg(kernel, 8, sizeof(cl_mem), (void *) &mob_whdis);
// Step 11: Execute OpenCL kernel in data parallel
size_t worksize[] = { now, 1, 1 };
clEnqueueNDRangeKernel(command_queue, kernel, 1, NULL, worksize, 0, 0, 0, 0);
err_check(err, "clEnqueueNDRangeKernel");
// Step 12: Read (Transfer result) from the memory buffer
我冒昧地對您的問題進行了重新說明。我希望沒問題。 :) – weltraumpirat
一開始就是[搞清楚'-49'的實際含義](http://www.google.de/#gs_rn=19&gs_ri=psy-ab&cp=9&gs_id=57&xhr=t&q=opencl+error+codes&es_nrs=真PF = p&sclient = PSY-AB和OQ = OpenCL的+ ER&gs_l =&PBX = 1&BAV = on.2,or.r_qf。&BVM = bv.48705608,d.Yms&FP = 1becc00280c7e15&BIW = 1920&波黑= 1034)。 –