2013-06-25 60 views
0

我有ATI HD 5470的Radeon,在我的戴爾1558,和AMDAPP SDK 2.8我win7-64 問題在安裝時我使用的OpenCL代碼爲細末設備也說:OpenCL設備不存在

「找不到任何設備:沒有錯誤」

我知道,我已經安裝了最新的催化劑驅動程序& 其他所有我的程序運行良好,GPU, 但我不知道爲什麼做這個報告。這裏是我用來查找設備的代碼: 感謝每一位幫助我找出問題所在?

#include <stdio.h> 
#include <stdlib.h> 
#include <string.h> 
#ifdef MAC 
#include <OpenCL/cl.h> 
#else 
#include <CL/cl.h> 
#endif 
int main() { 
cl_platform_id platform; 
cl_device_id *devices; 
cl_uint num_devices, addr_data; 
cl_int i, err; 
char name_data[48], ext_data[4096]; 
err = clGetPlatformIDs(1, &platform, NULL); 
if(err < 0) { 
perror("Couldn't find any platforms"); 
exit(1); 
} 
err = clGetDeviceIDs(platform, CL_DEVICE_TYPE_ALL, 
1, NULL, &num_devices); 
if(err < 0) { 
perror("Couldn't find any devices"); 
exit(1); 
} 
devices = (cl_device_id*) 
malloc(sizeof(cl_device_id) * num_devices); 
clGetDeviceIDs(platform, CL_DEVICE_TYPE_ALL, 
num_devices, devices, NULL); 
for(i=0; i<num_devices; i++) { 
err = clGetDeviceInfo(devices[i], CL_DEVICE_NAME, 
sizeof(name_data), name_data, NULL); 
if(err < 0) { 
perror("Couldn't read extension data"); 
exit(1); 
} 
clGetDeviceInfo(devices[i], CL_DEVICE_ADDRESS_BITS, 
sizeof(ext_data), &addr_data, NULL); 
clGetDeviceInfo(devices[i], CL_DEVICE_EXTENSIONS, 
sizeof(ext_data), ext_data, NULL); 
printf("NAME: %s\nADDRESS_WIDTH: %u\nEXTENSIONS: %s", 
name_data, addr_data, ext_data); 
} 
free(devices); 
return 0; 
} 
+0

請提供OCL API的錯誤代碼以供進一步分析。因爲你在程序中硬編碼了你自己的錯誤句子! – DarkZeros

回答

0

第一次調用clGetDeviceIDs(),因爲第三個參數爲1,返回我的機器上的錯誤改變1到0變過去那種。接下來的問題是對clGetDeviceInfo的調用失敗。這是因爲name_data太小。不知道opencl是否有直接的方法來找到所需的大小,但通過一個更大的緩衝區解決了這個問題。最後一個問題是,第二次調用clGetDeviceInfo時有一個打字錯誤,其中使用了sizeof(addr_data),但使用了sizeof(ext_data)。對於我的測試,這會導致局部變量i被覆蓋,導致無限循環。一旦被固定,代碼打印:

NAME:ATI RV710 ADDRESS_WIDTH:32個 EXTENSIONS:cl_khr_gl_sharing cl_amd_device_attribute_query cl_khr_d3d10_sharing名稱:Intel(R)核心(TM)i7-2600K CPU @ 3.40GHz ADDRESS_WIDTH:64 擴展:cl_khr_fp64 cl_amd_fp64 cl_khr_global_int32_base_atomics cl_khr_global_int32_extended_atomics cl_khr_local_i nt32_base_atomics cl_khr_local_int32_extended_atomics cl_khr_int64_base_atomics cl_khr_int64_extended_atomics cl_khr_byt e_addressable_store cl_khr_gl_sharing cl_ext_device_fission cl_amd_device_attribute_query cl_amd_vec3 cl_amd_printf cl_a md_media_ops cl_amd_popcnt cl_khr_d3d10_s haring

+0

嗨,非常感謝,我用你的建議,它運作良好 –