what is the content of cl_platform_id data structure?

◇◆丶佛笑我妖孽 提交于 2021-01-28 05:48:23

问题


I understand that cl_platform_id is a data structure like:

typedef struct{
   foo1 bar1;
   foo2 bar2;
   ...;
}cl_platform_id;

But what are the content of this structure? for example if I want to print these content to the console what data type should I use?

I tried integer but I got the error:

warning: format specifies type 'int' but the argument has type 'cl_platform_id' (aka 'struct _cl_platform_id *') [-Wformat]

Thanks for your help in advance.


回答1:


The cl_platform_id is an abstract (opaque) type, it is not intended to be directly used. Instead, query the information that you want to know with clGetPlatformInfo on your cl_platform_id. You can get strings (like CL_PLATFORM_NAME) that you can then print.




回答2:


Thanks to the w-m's answer I was pointed towards the right direction and was to write a snippet to print the platform information:

cl_platform_info Param_Name[5]={CL_PLATFORM_PROFILE, CL_PLATFORM_VERSION, CL_PLATFORM_NAME, CL_PLATFORM_VENDOR, CL_PLATFORM_EXTENSIONS};
cl_platform_info param_name;
size_t param_value_size;
for(int j=0;j<5;j++){
  param_name=Param_Name[j];
  err = clGetPlatformInfo( platforms[i], param_name, 0, NULL, &param_value_size);
  char* param_value = (char*)malloc( sizeof(char) * param_value_size);
  err = clGetPlatformInfo( platforms[i], param_name, param_value_size, param_value, NULL );
  printf("%s\n", param_value);
  free(param_value);
}

The complete code can be found here in this GitHub Gist.



来源:https://stackoverflow.com/questions/50665770/what-is-the-content-of-cl-platform-id-data-structure

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!