2

I keep getting an internal error despite successful builds of the below openCL code. The error message is not very helpful as it does not point out the line or column. Can any body spot this. The kernel code (for the openCL program) was able to independently compile under OpenCL(TM) Code Builder (64-bit)

CLRuntimeError: clBuildProgram() failed with error CL_BUILD_PROGRAM_FAILURE   (-11)

Logs are:

fcl build 1 succeeded.
fcl build 2 succeeded.
Error: internal error.

Source was:

    #pragma OPENCL_EXTENSION cl_khr_fp64 : enable

    typedef struct tag_sinterest{
       float *high;
       float *low;
       }sinterest;

    typedef struct tag_sfutures{
      int time;
      float put;
      sinterest *interest;
      }sfutures;


       __kernel  void Float(float *_high_index,
                    float *_high,
                    float *_low_index,
                    float *_low,
                    float _put,
                    float _call,
                    float _call_float)
        {
                int k = get_global_id(0);
                float _float = (float)(pow(_high[k]-_high_index[k],2.0f)+pow(_low[k]-_low_index[k],2.0f));
                _call += _float*_put;
                _call_float += _float;
        }

        __kernel void Interest(sinterest *_interest_index,
                    sinterest *_interest,
                    float _put,
                    float _call,
                    float _call_float)
        {
                int j = get_global_id(0);
                if(j >= 0)
                {
                    Float(_interest_index[j].high,_interest[j].high,_interest_index[j].low,_interest[j].low,_put,_call,_call_float);

                }
        }


    __kernel void Futures(sfutures *_futures,
                      int _index,
                      int _stop,
                      float _call)
    {
       float _call_float = 0.0f;
       int _start = _stop - (42 * 30 * 1440 *60);
       if(_index > 1)
         {
             _call = 0.0f;

             int i = get_global_id(0);

             if(_futures[i].time < _stop && _futures[i].time >= _start)
               {
                   Interest(_futures[_index-1].interest,_futures[i].interest,_futures[i].put,_call,_call_float);
               }

         }

       if(_call_float > 0.0f)
        {
             _call /= _call_float;
        }
    }    

EDIT I am using windows 10 64-bit and my video card is intel HD 4000. My openCL is 1.2, python 2.7, and I am using the module opencl4py

ssn
  • 439
  • 5
  • 14

1 Answers1

1

On my 64-bit opencl 1.2 capable platform and 64-bit project and w10 and discrete gpu:

Error:

#pragma OPENCL_EXTENSION cl_khr_fp64 : enable

should be without '_' like this:

#pragma OPENCL EXTENSION cl_khr_fp64 : enable

Warning:

cl_khr_fp64  extension is now part of core

but idk if your on-die gpu would need this or not.

Error:

__kernel  void Float(float *_high_index,
kernel arguments must point to addrSpace global, local, or constant

so it should be for example:

__kernel  void Float(__global float *_high_index,

Error:

kernel  can't be declared with types

      bool/half/size_t/ptrdiff_t/intptr_t/uintptr_t/pointer-to-pointer

      __kernel void Interest(sinterest *_interest_index,

because opencl doesn't let you to use device specific pointers in a shared buffer of structs. Once the buffer is copied to another device, its fields would point to an undefined location. But you can trick compiler if you insist on to use single device(or do proper update pass for all structs after copying to another device). So it is a "pointer-to-pointer" error.

Also with an additional memory specification :

typedef struct tag_sinterest{
   unsigned long addrHigh; //size_t is better if you export to 32-bit env.
   unsigned long addrLow;
   }sinterest;

 ...
__kernel void Interest(__global sinterest *_interest_index,

and then correct the rest of the code yourself. Same correction is needed for:

typedef struct tag_sfutures{
  int time;
  float put;
  sinterest *interest; <---------- unsigned long ? to fool compiler and
  }sfutures;                       do proper address assignemnt yourself  

Error: Again, memory space qualifier

      pointer arguments must point to addrSpace global, local, or constant
     __kernel  void Float(float *_high_index,
                                 ^

should be like,

      pointer arguments must point to addrSpace global, local, or constant
     __kernel  void Float(__global float *_high_index,
                                 ^

Use clGetProgramBuildInfo function for future errors and warnings.

huseyin tugrul buyukisik
  • 11,469
  • 4
  • 45
  • 97