0
我一直在努力使OpenCL在我的筆記本電腦中工作。我遵循this鏈接。我有一個NVIDIA GT525M顯卡和Windows 8.1。 我遵循的步驟如下:運行OpenCL程序時發生clGetPlatformID錯誤。
安裝最新的NVIDIA驅動程序。
安裝Visual Studio 2013社區版。
添加鏈接器和編譯器的路徑。
,然後我試圖運行下面的代碼在該頁面給出:
#include <stdio.h>
#include <CL/cl.h>
int main(void)
{
cl_int err;
cl_uint* numPlatforms=NULL;
err = clGetPlatformIDs(0, NULL,numPlatforms);
if (CL_SUCCESS == err)
printf("\nDetected OpenCL platforms: %d", numPlatforms);
else
printf("\nError calling clGetPlatformIDs. Error code: %d", err);
getchar();
return 0;
}
代碼成功生成,但結果我得到的是:
Error calling clGetPlatformIDs. Error code: -30
我得到零數的平臺。 我一直在尋找一個解決方案,但無法找到一個互聯網。請幫忙。
你怎麼能指望'clGetPlatformIDs(0,NULL,NULL)'工作?請閱讀該功能的文檔,這是非常清楚的。你想要的是聲明'cl_uint numPlatforms = 0;'然後'clGetPlatformIDs(0,NULL,&numPlatforms)'。 –
@AnastasiyaAsadullayeva抱歉在這裏問愚蠢的問題。但文件不是很清楚。 (或者我太愚蠢,無法理解),謝謝你,這工作。 – PPGoodMan
好的,我會編輯答案。 –