Saturday, 15 January 2011

opencl - What is the right way to call clGetPlatformInfo? -


Right now I'm calling clGetPlatformInfo twice to get the result size and to get the second result actually for. If I have to get 20 pieces of information, then I have to call 40 times (80 line codes). Is there a better way to do this?

clGetPlatformInfo example

  char * profile = NULL; Size_t size; ClGetPlatformInfo (platform [0], CL_PLATFORM_PROFILE, NULL, profile, and size); // Profile size gets four array profile = (four *) malloc (size); ClGetPlatformInfo (platform [0], CL_PLATFORM_PROFILE, size, profile, tap); // Profile get four ARR cout & lt; & Lt; Profile & lt; & Lt; Endl;   

clGetDeviceInfo example

  size_t size; Four * vendor = faucet; ClGetDeviceInfo (Tools [0], CL_DEVICE_VENDOR, Faucet, Zero, and Size); Vendor = (four *) maulok (size (four) * size); ClGetDeviceInfo (device [0], CL_DEVICE_VENDOR, size, vendor, tap); Cout & lt; & Lt; Seller & lt; & Lt; Endl;    

No, this is the correct way to use clGetPlatformInfo () Function Returned string is known only in run-time.

For others (like clGetDeviceInfo () with CL_DEVICE_MAX_COMPUTE_UNITS ) you will have the call to function once you already have Know (compile-time) output size ( sizeof (cl_uint) ).

No comments:

Post a Comment