Floating point exception on simple kernel

Hello everyone. I’m in my first steps with OpenCL and I have the following problem which I cannot understand at all why is happening.

I have a simple kernel:

#pragma OPENCL EXTENSION cl_khr_fp64 : enable
typedef struct
  double speeds[9];
} t_speed;

__kernel void george(__global const t_speed* cells,
                   __global double*  result,
                     const unsigned int n)
  int j, i = get_global_id(0);
  if(i >= n) return;
  result[i] = 0;
  for(j=0; j<9; j++)
    result[i] += cells[i].speeds[j];

which when I execute I get a “Floating point exception”. Can anyone explain to me please why should I get such an error?

Problem solved. It had nothing to do with the kernel after all.

Hi gkaran,
Can you tell what was the problem and solution with the floating point exception you had (if it was related to OpenCL)?
Thank you.

Yeah, the problem was with the clEnqueueNDRangeKernel call. The global work size was not divisible by the local work size.

I’m having a similar problem,


__kernel void masking_image( __read_only image2d_t srcImg, __write_only image2d_t dstImg,__global const float *mask, int width, int height)

Kernel is empty at this moment.

size_t LWS_IMAGE[2] = {1,1};
size_t GWS_IMAGE[2] = {16,16};

printf("LWS : %ldx%ld, GWS : %ldx%ld

void exec_opencl_image(int width, int height, unsigned char* input, unsigned char* output, float *mask)
  cl_int ret=0;
  size_t Offset[2] = {1,1};
  clSetKernelArg(ckKernel[1], 0, sizeof(cl_mem), (void *)&cmDevImageInput); CheckFN(ret);
  clSetKernelArg(ckKernel[1], 1, sizeof(cl_mem), (void *)&cmDevImageOutput); CheckFN(ret);
  clSetKernelArg(ckKernel[1], 2, sizeof(cl_mem), (void *)&cmDevMask); CheckFN(ret);
  clSetKernelArg(ckKernel[1], 3, sizeof(int), (void *)&width); CheckFN(ret);
  clSetKernelArg(ckKernel[1], 4, sizeof(int), (void *)&height); CheckFN(ret);

  //Just to make sure it's divisible
  size_t LWS_IMAGE[2] = {1,1};
  size_t GWS_IMAGE[2] = {16,16};

  //Where I'm having "Floating-point exception"
  ret = clEnqueueNDRangeKernel(cqCommandQueueGPU, ckKernel[1], 2, Offset, GWS_IMAGE,LWS_IMAGE, 0, NULL,NULL); CheckFN(ret);
  const size_t image_origin[3] = {0,0,0};
  //const size_t host_origin[3] = {0,0,0};
  const size_t region[3] = {width,height,1};
  //ret = clEnqueueReadImage(cqCommandQueueGPU, cmDevImageOutput, CL_TRUE, image_origin,region,0,0,output, NULL, 0,NULL); CheckFN(ret);

Any headups? I’m stuck in here for two days, and no luck with digging forums and googling~ Original image i’m using is 1920x1080x3.

Thanks in advance.

my LWS_IMAGE and RWS_IMAGE were NULL… somehow…my bad