1 #ifndef VIENNACL_OCL_PLATFORM_HPP_
2 #define VIENNACL_OCL_PLATFORM_HPP_
26 #include <OpenCL/cl.h>
52 cl_uint num_platforms;
53 cl_platform_id ids[42];
54 #if defined(VIENNACL_DEBUG_ALL)
55 std::cout <<
"ViennaCL: Getting platform..." << std::endl;
57 err = clGetPlatformIDs(42, ids, &num_platforms);
59 assert(num_platforms > pf_index &&
bool(
"ViennaCL: ERROR: Not enough platforms found!"));
61 assert(num_platforms > 0 &&
bool(
"ViennaCL: ERROR: No platform found!"));
66 void operator=(cl_platform_id pf_id) { id_ = pf_id; }
68 cl_platform_id
id()
const {
return id_; }
75 err = clGetPlatformInfo(id_, CL_PLATFORM_VENDOR, 1024 *
sizeof(
char), buffer, NULL);
81 err = clGetPlatformInfo(id_, CL_PLATFORM_VERSION, 1024 *
sizeof(
char), buffer, NULL);
91 std::vector<device>
devices(cl_device_type dtype = CL_DEVICE_TYPE_DEFAULT)
94 #if defined(VIENNACL_DEBUG_ALL) || defined(VIENNACL_DEBUG_DEVICE)
95 std::cout <<
"ViennaCL: Querying devices available at current platform." << std::endl;
100 if (err == CL_DEVICE_NOT_FOUND && dtype == CL_DEVICE_TYPE_DEFAULT)
107 #if defined(VIENNACL_DEBUG_ALL) || defined(VIENNACL_DEBUG_DEVICE)
108 std::cout <<
"ViennaCL: Found " << num_devices <<
" devices." << std::endl;
111 assert(num_devices > 0 &&
bool(
"Error in viennacl::ocl::platform::devices(): No OpenCL devices available!"));
114 for (cl_uint i=0; i<num_devices; ++i)
115 devices.push_back(
device(device_ids[i]));
126 std::vector< platform > ret;
128 cl_uint num_platforms;
129 cl_platform_id ids[42];
130 #if defined(VIENNACL_DEBUG_ALL)
131 std::cout <<
"ViennaCL: Getting platform..." << std::endl;
133 err = clGetPlatformIDs(42, ids, &num_platforms);
136 for (cl_uint i = 0; i < num_platforms; ++i)
This file provides the forward declarations for the OpenCL layer of ViennaCL.
std::vector< platform > get_platforms()
Represents an OpenCL device within ViennaCL.
A class representing a compute device (e.g. a GPU)
#define VIENNACL_ERR_CHECK(err)
#define VIENNACL_OCL_MAX_DEVICE_NUM