1

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.

Foad S. Farimani
  • 12,396
  • 15
  • 78
  • 193

2 Answers2

4

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.

w-m
  • 10,772
  • 1
  • 42
  • 49
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.

Foad S. Farimani
  • 12,396
  • 15
  • 78
  • 193