使用python

时间:2016-05-01 13:28:32

标签: python c opencl

尽管成功构建了以下openCL代码,但我仍然遇到内部错误。错误消息不是很有用,因为它没有指出行或列。任何身体都可以发现这个。内核代码(用于openCL程序)能够在OpenCL(TM)代码生成器(64位)下独立编译

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

日志是:

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

来源是:

    #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;
        }
    }    

修改 我正在使用Windows 10 64位,我的视频卡是intel HD 4000.我的openCL是1.2,python 2.7,我正在使用模块opencl4py

1 个答案:

答案 0 :(得分:1)

在我的64位opencl 1.2平台和64位项目以及w10和离散gpu上:

错误:

#pragma OPENCL_EXTENSION cl_khr_fp64 : enable

应该没有&#39; _&#39;像这样:

#pragma OPENCL EXTENSION cl_khr_fp64 : enable

警告:

cl_khr_fp64  extension is now part of core

但是如果你的on-die gpu需要这个,那就是idk。

错误:

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

所以它应该是例如:

__kernel  void Float(__global float *_high_index,

错误:

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,

因为opencl不允许您在结构的共享缓冲区中使用特定于设备的指针。将缓冲区复制到另一个设备后,其字段将指向未定义的位置。但是如果您坚持使用单个设备(或者在复制到另一个设备后对所有结构执行适当的更新传递),您可以欺骗编译器。所以它是一个&#34;指向指针&#34;错误。

还有额外的内存规格:

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,

然后自己更正其余的代码。需要进行相同的修正:

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

错误:再次,内存空间限定符

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

应该是,

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

将clGetProgramBuildInfo函数用于将来的错误和警告。