1
votes

So I have a project that I created on Mac Pro using double data type and it works perfect. Now I moved my project to MacBook Air and it started giving me

Exception
ERROR: clBuildProgram(-11)

error. Now the reason for this is that my MacBook Air does not support the double precision type with OpenCL. But on the contrary, I found this: OpenCL kernel error on Mac OSx. I applied the method in the answer like this:

cl_device_fp_config cfg;
clGetDeviceInfo(devicesIds[0], CL_DEVICE_DOUBLE_FP_CONFIG, sizeof(cfg), &cfg, NULL); // 0 is for the device number I guess?
printf("Double FP config = %llu\n", cfg);

And he explained that if the result is 0, then it means that double precision is not supported. But I get this result:

Double FP config = 63

I also tried this method:

if (!cfg) {
    printf("Double precision not supported \n\n");
} else {
  printf("Following double precision features supported:\n");

  if(cfg & CL_FP_INF_NAN)
      printf("  INF and NaN values\n");

  if(cfg & CL_FP_DENORM)
      printf("  Denormalized numbers\n");

  if(cfg & CL_FP_ROUND_TO_NEAREST)
      printf("  Round To Nearest Even mode\n");

  if(cfg & CL_FP_ROUND_TO_INF)
      printf("  Round To Infinity mode\n");

  if(cfg & CL_FP_ROUND_TO_ZERO)
      printf("  Round To Zero mode\n");

  if(cfg & CL_FP_FMA)
      printf("  Floating-point multiply-and-add operation\n\n");
}

And I got the following results:

Double FP config = 63
Following double precision features supported:
  INF and NaN values
  Denormalized numbers
  Round To Nearest Even mode
  Round To Infinity mode
  Round To Zero mode
  Floating-point multiply-and-add operation

What is going on here? Does my system support double precision with OpenCL or not? If yes, how do I enable and use it? If not, what are my alternatives? Now I am very confused. First of all, I don't know if my MacBook Air supports double precision or not? Apparently it doesn't. But with the output, it seems like it does.

If it doesn't support double precision, then what should I do? Should I change everything in my project to float values? OR if it does, then how do I enable it? Because I followed a lot of tutorials and examples and none of them work. e.g. https://streamcomputing.eu/blog/2013-10-17/writing-opencl-code-single-double-precision/ but none of them seem to work.

EDIT:

1
How do you know that the reason for the -11 in other words CL_BUILD_PROGRAM_FAILURE is that the device doesn't support doubles? Please post your CL build log. You can fetch it with clGetProgramBuildInfo.maZZZu
Because when I used a very minimal kernel without doubles, It worked perfect. But as soon as I introduced a double into the kernel, it gave me this error. Don't worry my research of why doubles are not working is based on solid observations. I have been stuck here in this problem for weeks now.Mohammad Sohaib
Without knowing what device 0 is on your system, it's hard to know if this is a bug in the drivers or not. Also, please provide the build log - you can use the function ` clGetProgramBuildInfo`. If you could post the code of your minimal kernel, that would also help.chippies

1 Answers

3
votes

Unfortunately double support is "optional" in OpenCL, some devices support it and some don't...
If a device supports double then the device extensions (CL_DEVICE_EXTENSIONS) will contain cl_khr_fp64 or cl_khr_fp64.

There is some example kernel code here to use floats when doubles aren't available.