exponential on input value causes CL_BUILD_PROGRAM_FAILURE

Hi everyone,

I have a simple test kernel with input/output buffers declared as follows:

// OpenCL Kernel Function for Hodgkin Huxley integration step
kernel void Exponential(global const double* V_in,  global double* V_out)
{
   // get index into global data array
   int iGID = get_global_id(0);

   double value = (double) V_in[iGID];
   double exponential = (double) exp((double) value);
   V_out[iGID] = exponential;
}

My problem is that the code above raises a CL_BUILD_PROGRAM_FAILURE with no details.

If I hardcode the value in the kernel as follows I don’t get the error:

double value = (double) 10;
double exponential = (double) exp((double) value);

There is probably something very basic that I am missing, any help appreciated!

A build failure with no information in the log usually means you’ve found a compiler bug. The only thing wrong with your code is that it’s missing this line of code at the beginning:

#pragma OPENCL EXTENSION cl_khr_fp64 : enable

You must always use this pragma if your kernel is using double-precision floats.

Also, there are lots of unnecessary casts in the kernel. I don’t think they are the cause of the build failure but it’s worth trying this other version – it is identical semantically to the code you’ve posted:


#pragma OPENCL EXTENSION cl_khr_fp64 : enable

// OpenCL Kernel Function for Hodgkin Huxley integration step
kernel void Exponential(global const double* V_in,  global double* V_out)
{
   // get index into global data array
   size_t iGID = get_global_id(0);

   V_out[iGID] = exp(V_in[iGID]);
}

Thanks a lot for your prompt reply David,

in the meantime I found out that if I replace the doubles with floats it works like a charm (without any casts, I had the casts there because - even with hardcoded values - the compiler was complaining about multiple declarations of the exp signature).

I’ll now try to add the #pragma and report back soon!

Thanks again!

For some reason even with the #pragma I am still getting the same. I can live with the floats for now but I’d like to understand why this is happening.

Here is the full error (I am using jocl, it’s showing build logs on both CPU and GPU, both empty):

Exception in thread "main" com.jogamp.opencl.CLException$CLBuildProgramFailureException: 
CLDevice [id: 16914944 name: Radeon HD 4850 type: GPU profile: FULL_PROFILE] build log:
    <empty>
CLDevice [id: 16909312 name: Intel(R) Core(TM) i7 CPU         860  @ 2.80GHz type: CPU profile: FULL_PROFILE] build log:
    <empty> [error: CL_BUILD_PROGRAM_FAILURE]
	at com.jogamp.opencl.CLException.newException(CLException.java:78)
	at com.jogamp.opencl.CLProgram.build(CLProgram.java:366)
	at com.jogamp.opencl.CLProgram.build(CLProgram.java:205)
	at MyOpenCLTest.main(MyOpenCLTest.java:75)

I shouldn’t have taken this for granted. Does your GPU actually support doubles? Check that glGetDeviceInfo(CL_DEVICE_EXTENSIONS) to see whether cl_khr_fp64 is exposed.

Yep - it looks like my GPU [ATI HD 4850 http://goo.gl/jb7v2] does not support double-precision. Shoot!

Good thing I can do without for now -thanks for all the help!