Hi,
I am new to opencl and c++ (i do have extended C skills 😉 )
After reading some tutorials and the specification i decided to print some information regarding my platform and devices.
It does compile fine however i only get the GPU information and not the CPU information. When i change the line :
platforms.front().getDevices(CL_DEVICE_TYPE_ALL,&devices);
to
platforms.front().getDevices(CL_DEVICE_TYPE_GPU,&devices);
or
platforms.front().getDevices(CL_DEVICE_TYPE_CPU,&devices);
it does show the info (cpu and gpu) i want, but when i use *_ALL the GPU information is printed twice. Am i doint something wrong in the iterator (i don't think so).
Probably something stupid, any help is apriciated?
Regards, Anon5710
#include <iostream> #include <vector> #include <cstdlib> #include <stdio.h> #define __CL_ENABLE_EXCEPTIONS #include <CL/cl.hpp> int main(int argc, char *argv[]) { try { // get platforms std::vector<cl::Platform> platforms; cl::Platform::get(&platforms); // iterate over available platforms for(std::vector<cl::Platform>::const_iterator pltfmIt=platforms.begin(); pltfmIt != platforms.end(); ++pltfmIt ) { std::cout << "Platform Profile : " << platforms.front().getInfo<CL_PLATFORM_PROFILE>() << std::endl; std::cout << "Platform version : " << platforms.front().getInfo<CL_PLATFORM_VERSION>() << std::endl; std::cout << "Platform name : " << platforms.front().getInfo<CL_PLATFORM_NAME>() << std::endl; std::cout << "Platform vendor : " << platforms.front().getInfo<CL_PLATFORM_VENDOR>() << std::endl; std::cout << "Platform extensions : " << platforms.front().getInfo<CL_PLATFORM_EXTENSIONS>() << std::endl; // get devices std::vector<cl::Device> devices; platforms.front().getDevices(CL_DEVICE_TYPE_ALL,&devices); // iterate over available devices for(std::vector<cl::Device>::const_iterator dvIt=devices.begin(); dvIt != devices.end(); ++dvIt ) { std::cout << "Device name : " << devices.front().getInfo<CL_DEVICE_NAME>() << std::endl; std::cout << "Device type : " << devices.front().getInfo<CL_DEVICE_TYPE>() << std::endl; std::cout << "Device vendor ID : " << devices.front().getInfo<CL_DEVICE_VENDOR_ID>() << std::endl; std::cout << "Maximum compute units on device : " << devices.front().getInfo<CL_DEVICE_MAX_COMPUTE_UNITS>() << std::endl; std::cout << "Maximum work items demensions : " << devices.front().getInfo<CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS>() << std::endl; std::cout << "Maximum workgroup size : " << devices.front().getInfo<CL_DEVICE_MAX_WORK_GROUP_SIZE>() << std::endl; std::cout << "Maximum clock frequency : " << devices.front().getInfo<CL_DEVICE_MAX_CLOCK_FREQUENCY>() << std::endl; std::cout << "Device vendor: " << devices.front().getInfo<CL_DEVICE_VENDOR>() << std::endl; std::cout << "Suported extensions: " << devices.front().getInfo<CL_DEVICE_EXTENSIONS>() << std::endl; } } } catch(cl::Error& err) { std::cerr << "OpenCL error: " << err.what() << "(" << err.err() << ")" << std::endl; return EXIT_FAILURE; } return EXIT_SUCCESS; } OUTPUT: ---------------- Platform Profile : FULL_PROFILE Platform version : OpenCL 1.1 AMD-APP-SDK-v2.5 (684.213) Platform name : AMD Accelerated Parallel Processing Platform vendor : Advanced Micro Devices, Inc. Platform extensions : cl_khr_icd cl_amd_event_callback cl_amd_offline_devices Device name : Juniper Device type : 4 Device vendor ID : 4098 Maximum compute units on device : 9 Maximum work items demensions : 3 Maximum workgroup size : 256 Maximum clock frequency : 710 Device vendor: Advanced Micro Devices, Inc. Suported extensions: cl_khr_global_int32_base_atomics cl_khr_global_int32_extended_atomics cl_khr_local_int32_base_atomics cl_khr_local_int32_extended_atomics cl_khr_3d_image_writes cl_khr_byte_addressable_store cl_khr_gl_sharing cl_ext_atomic_counters_32 cl_amd_device_attribute_query cl_amd_vec3 cl_amd_printf cl_amd_media_ops cl_amd_popcnt Device name : Juniper Device type : 4 Device vendor ID : 4098 Maximum compute units on device : 9 Maximum work items demensions : 3 Maximum workgroup size : 256 Maximum clock frequency : 710 Device vendor: Advanced Micro Devices, Inc. Suported extensions: cl_khr_global_int32_base_atomics cl_khr_global_int32_extended_atomics cl_khr_local_int32_base_atomics cl_khr_local_int32_extended_atomics cl_khr_3d_image_writes cl_khr_byte_addressable_store cl_khr_gl_sharing cl_ext_atomic_counters_32 cl_amd_device_attribute_query cl_amd_vec3 cl_amd_printf cl_amd_media_ops cl_amd_popcnt