2016-12-11 5 views
0

編集を-64を返します。エラーコードは、私はMinGWの(x86の)およびx86 AMDのOpenCL libaryを使用している以下のはOpenCLのは、呼び出しclGetPlatformIDs時

CL_INVALID_PROPERTY if context property name in properties is not a 
supported property name, if the value specified for a supported property 
name is not valid, or if the same property name is specified more than once. 
However if the extension cl_khr_gl_sharing is enabled, then 
CL_INVALID_PROPERTY is returned if an attribute name other than those listed 
in the table for properties above is specified in properties. 

で、次のコードは、最終チェックの後にNULLを返します:

cl_context CreateContext() 
{ 
    cl_int errNum; 
    cl_uint numPlatforms; 
    cl_platform_id firstPlatformID; 
    cl_context context=NULL; 
    //Select an OpenCL platform 

    errNum=clGetPlatformIDs(1, &firstPlatformID, &numPlatforms); 
    if (errNum!=CL_SUCCESS||numPlatforms<=0) 
    { 
     cerr<<"Failed to find any OpenCL platforms."<<endl; 
     return NULL; 
    } 

    cl_context_properties contextProperties[]= 
    { 
     CL_CONTEXT_PLATFORM, 
     (cl_context_properties) firstPlatformID, 
    }; 
    context=clCreateContextFromType(contextProperties, CL_DEVICE_TYPE_GPU, NULL, NULL, &errNum); 
    cout << errNum << endl; 
    if (errNum!=CL_SUCCESS) 
    { 
     cerr<<"Failed to create an OpenCL GPU context, trying CPU."<<endl; 
     context=clCreateContextFromType(contextProperties,CL_DEVICE_TYPE_CPU, NULL, NULL, &errNum); 

     if (errNum!=CL_SUCCESS) 
     { 
      cerr<<"Failed to create an OpenCL GPU or CPU context."<<endl; 
      return NULL; 
     } 
    } 
    return context; 
} 

それは(インテルのCPU、AMDのGPU)必要がありますが、コンテキストを作成することはできませんように、それは2つのプラットフォームを検出します。 x64のlibaryも同じことをします。誰でもそれを修正する方法を知っていますか?

答えて

0

clCreateContextのドキュメントによれば、cl_context_propertiesのリストをゼロで終了する必要があります。

cl_context_properties contextProperties[] = 
{ 
    CL_CONTEXT_PLATFORM, 
    (cl_context_properties)firstPlatformID, 
    0 
}; 
次の変更のコードは、私の作品では

関連する問題