C/C++/pyton,MT4,MT5,博易大师,文华,金字塔编程,vnpy,python量化,以下凑字数。。。
bool COpenCL::Initialize(const string program,const bool show_log=true)
{
if((m_context=CLContextCreate(CL_USE_ANY))==INVALID_HANDLE)
{
Print("OpenCL not found. Error code=",GetLastError());
return(false);
}
//--- check support working with doubles (cl_khr_fp64)
if(CLGetInfoString(m_context,CL_DEVICE_EXTENSIONS,m_device_extensions))
{
string extenstions[];
StringSplit(m_device_extensions,' ',extenstions);
m_support_cl_khr_fp64=false;
int size=ArraySize(extenstions);
for(int i=0; i<size; i++)
{
if(extenstions[i]=="cl_khr_fp64")
m_support_cl_khr_fp64=true;
}
}
//--- compile the program
string build_error_log;
if((m_program=CLProgramCreate(m_context,program,build_error_log))==INVALID_HANDLE)
{
if(show_log)
{
string loglines[];
StringSp
写交易方案,实现程序化交易,以下凑字数。。。bool COpenCL::KernelCreate(const int kernel_index,const string kernel_name)
{
if(m_context==INVALID_HANDLE || m_program==INVALID_HANDLE)
return(false);
//--- check parameters
if(kernel_index<0 || kernel_index>=m_kernels_total)
return(false);
//---
int kernel_handle=m_kernels[kernel_index];
if(kernel_handle==INVALID_HANDLE || m_kernel_names[kernel_index]!=kernel_name)
{
//--- create kernel
if((kernel_handle=CLKernelCreate(m_program,kernel_name))==INVALID_HANDLE)
{
CLProgramFree(m_program);
CLContextFree(m_context);
Print("OpenCL kernel create failed. Error code=",GetLastError());
return(false);
}
else
{
m_kernels[kernel_index]=kernel_handle;
m_kernel_names[kernel_index]=kernel_name;
}
}
return(true);
}