0
votes

Hi i have a problem with the log2 function used in an OpenCL kernel, i have a compiler crash:

CVMS_ERROR_SERVICE_FAILURE: CVMS compiler has crashed or hung managing the service

the code is this:

int offset = log2((double)m)

where m is an int, where is the problem? Thanks

1
What value is m? Note that the logarithm of m with a value <= 0 is undefined. What crashed - the compiler or the executable code? - Weather Vane
m value is 256, the compiler of the kernel, the log returned with clGetProgramBuildInfo is "CVMS_ERROR_SERVICE_FAILURE: CVMS compiler has crashed or hung managing the service" - pinotto
You asked the same more detailed question only recently. - Weather Vane
i hope that wrote in this way it should be more clear - pinotto

1 Answers

0
votes

I can't reproduce the error, so I assume it's a driver issue.

According to the OpenCL documentation, T log2 (T) is defined, so log2(double) returns a double which should only give you a compiler warning when implicitly casted to int. Try

int offset = (int)(log2((float)m)+0.5f);

to avoid any compiler warning and if this still does not work, use my evil fast log2 method

int offset = (as_uint((float)m)>>23)-127;

which uses the built-in OpenCL function as_uint(float).