1 #ifndef VIENNACL_OCL_PLATFORM_HPP_
2 #define VIENNACL_OCL_PLATFORM_HPP_
25 #include <OpenCL/cl.h>
45 cl_uint num_platforms;
46 cl_platform_id ids[3];
47 #if defined(VIENNACL_DEBUG_ALL)
48 std::cout <<
"ViennaCL: Getting platform..." << std::endl;
50 err = clGetPlatformIDs(1, ids, &num_platforms);
53 assert(num_platforms > 0 &&
"ViennaCL: ERROR: No platform found!");
56 cl_platform_id
id()
const
66 err = clGetPlatformInfo(id_, CL_PLATFORM_VENDOR, 1024 *
sizeof(
char), buffer, NULL);
72 err = clGetPlatformInfo(id_, CL_PLATFORM_VERSION, 1024 *
sizeof(
char), buffer, NULL);
82 std::vector<device>
devices(cl_device_type dtype = CL_DEVICE_TYPE_DEFAULT)
85 #if defined(VIENNACL_DEBUG_ALL) || defined(VIENNACL_DEBUG_DEVICE)
86 std::cout <<
"ViennaCL: Querying devices available at current platform." << std::endl;
91 if (err == CL_DEVICE_NOT_FOUND && dtype == CL_DEVICE_TYPE_DEFAULT)
98 #if defined(VIENNACL_DEBUG_ALL) || defined(VIENNACL_DEBUG_DEVICE)
99 std::cout <<
"ViennaCL: Found " << num_devices <<
" devices." << std::endl;
102 assert(num_devices > 0 &&
"Error in viennacl::ocl::platform::devices(): No OpenCL devices available!");
105 for (cl_uint i=0; i<num_devices; ++i)
106 devices.push_back(
device(device_ids[i]));