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!"));
73 cl_platform_id
id()
const
83 err = clGetPlatformInfo(id_, CL_PLATFORM_VENDOR, 1024 *
sizeof(
char), buffer, NULL);
89 err = clGetPlatformInfo(id_, CL_PLATFORM_VERSION, 1024 *
sizeof(
char), buffer, NULL);
99 std::vector<device>
devices(cl_device_type dtype = CL_DEVICE_TYPE_DEFAULT)
102 #if defined(VIENNACL_DEBUG_ALL) || defined(VIENNACL_DEBUG_DEVICE)
103 std::cout <<
"ViennaCL: Querying devices available at current platform." << std::endl;
108 if (err == CL_DEVICE_NOT_FOUND && dtype == CL_DEVICE_TYPE_DEFAULT)
115 #if defined(VIENNACL_DEBUG_ALL) || defined(VIENNACL_DEBUG_DEVICE)
116 std::cout <<
"ViennaCL: Found " << num_devices <<
" devices." << std::endl;
119 assert(num_devices > 0 &&
bool(
"Error in viennacl::ocl::platform::devices(): No OpenCL devices available!"));
122 for (cl_uint i=0; i<num_devices; ++i)
123 devices.push_back(
device(device_ids[i]));
136 std::vector< platform > ret;
138 cl_uint num_platforms;
139 cl_platform_id ids[42];
140 #if defined(VIENNACL_DEBUG_ALL)
141 std::cout <<
"ViennaCL: Getting platform..." << std::endl;
143 err = clGetPlatformIDs(42, ids, &num_platforms);
146 for (cl_uint i = 0; i < num_platforms; ++i)
This file provides the forward declarations for the OpenCL layer of ViennaCL.
std::size_t vcl_size_t
Definition: forwards.h:58
std::vector< platform > get_platforms()
Definition: platform.hpp:134
Represents an OpenCL device within ViennaCL.
A class representing a compute device (e.g. a GPU)
Definition: device.hpp:49
#define VIENNACL_ERR_CHECK(err)
Definition: error.hpp:655
Main namespace in ViennaCL. Holds all the basic types such as vector, matrix, etc. and defines operations upon them.
Definition: cpu_ram.hpp:29
#define VIENNACL_OCL_MAX_DEVICE_NUM
Definition: device_utils.hpp:25