使用 python 构建时出现 opencl 内部错误
opencl internal error on build with python
尽管成功构建了以下 openCL 代码,但我仍然收到内部错误。错误消息不是很有帮助,因为它没有指出行或列。任何人都可以发现这一点。内核代码(用于 openCL 程序)能够在 OpenCL(TM) Code Builder(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
在我的支持 opencl 1.2 的 64 位平台和 64 位项目以及 w10 和离散 gpu 上:
错误:
#pragma OPENCL_EXTENSION cl_khr_fp64 : enable
应该像这样没有'_':
#pragma OPENCL EXTENSION cl_khr_fp64 : enable
警告:
cl_khr_fp64 extension is now part of core
但不知道你的片上 gpu 是否需要这个。
错误:
__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 不允许您在结构的共享缓冲区中使用特定于设备的指针。一旦缓冲区被复制到另一个设备,它的字段将指向一个未定义的位置。但是如果你坚持使用单个设备(或者在复制到另一个设备后对所有结构进行适当的更新传递),你可以欺骗编译器。所以这是一个 "pointer-to-pointer" 错误。
还有额外的内存规格:
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
错误:再次,内存space限定符
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 函数处理未来的错误和警告。
尽管成功构建了以下 openCL 代码,但我仍然收到内部错误。错误消息不是很有帮助,因为它没有指出行或列。任何人都可以发现这一点。内核代码(用于 openCL 程序)能够在 OpenCL(TM) Code Builder(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
在我的支持 opencl 1.2 的 64 位平台和 64 位项目以及 w10 和离散 gpu 上:
错误:
#pragma OPENCL_EXTENSION cl_khr_fp64 : enable
应该像这样没有'_':
#pragma OPENCL EXTENSION cl_khr_fp64 : enable
警告:
cl_khr_fp64 extension is now part of core
但不知道你的片上 gpu 是否需要这个。
错误:
__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 不允许您在结构的共享缓冲区中使用特定于设备的指针。一旦缓冲区被复制到另一个设备,它的字段将指向一个未定义的位置。但是如果你坚持使用单个设备(或者在复制到另一个设备后对所有结构进行适当的更新传递),你可以欺骗编译器。所以这是一个 "pointer-to-pointer" 错误。
还有额外的内存规格:
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
错误:再次,内存space限定符
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 函数处理未来的错误和警告。