0

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

pinotto
  • 45
  • 7
  • 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 Feb 05 '20 at 21:53
  • 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 Feb 05 '20 at 22:50
  • You asked the same [more detailed question](https://stackoverflow.com/questions/60082588/opencl-cvms-error-service-failure-cvms-compiler-has-crashed-or-hung-managing-th) only recently. – Weather Vane Feb 05 '20 at 22:53
  • i hope that wrote in this way it should be more clear – pinotto Feb 05 '20 at 23:10
  • Does this answer your question? [OpenCL CVMS\_ERROR\_SERVICE\_FAILURE: CVMS compiler has crashed or hung managing the service?](https://stackoverflow.com/questions/60082588/opencl-cvms-error-service-failure-cvms-compiler-has-crashed-or-hung-managing-th) – isopach Feb 06 '20 at 03:58
  • Does your OpenCL implementation support the `cl_khr_fp64` extension for double-precision arithmetic, and have you enabled it in your kernel? – pmdj Feb 06 '20 at 13:43

1 Answers1

0

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).

ProjectPhysX
  • 4,535
  • 2
  • 14
  • 34