![]() |
Home | Libraries | People | FAQ | More |
boost::compute::context — A compute context.
// In header: <boost/compute/context.hpp> class context { public: // public member functions context(); explicit context(const device &, const cl_context_properties * = 0); explicit context(const std::vector< device > &, const cl_context_properties * = 0); explicit context(cl_context, bool = true); context(const context &); context & operator=(const context &); context(context &&) noexcept; context & operator=(context &&) noexcept; ~context(); cl_context & get() const; device get_device() const; std::vector< device > get_devices() const; template<typename T> T get_info(cl_context_info) const; template<int Enum> unspecified get_info() const; bool operator==(const context &) const; bool operator!=(const context &) const; };
The context class represents a compute context.
A context object manages a set of OpenCL resources including memory buffers and program objects. Before allocating memory on the device or executing kernels you must set up a context object.
To create a context for the default device on the system:
// get the default compute device boost::compute::device gpu = boost::compute::system::default_device(); // create a context for the device boost::compute::context context(gpu);
Once a context is created, memory can be allocated using the buffer class and kernels can be executed using the command_queue class.
See Also: device, command_queue
context
public member functionscontext();Create a null context object.
explicit context(const device & device, const cl_context_properties * properties = 0);
Creates a new context for device
with properties
.
See the documentation for
explicit context(const std::vector< device > & devices, const cl_context_properties * properties = 0);
Creates a new context for devices
with properties
.
See the documentation for
explicit context(cl_context context, bool retain = true);
Creates a new context object for context
. If retain
is true
, the reference count for context
will be incremented.
context(const context & other);Creates a new context object as a copy of
other
. context & operator=(const context & other);Copies the context object from
other
to *this
. context(context && other) noexcept;Move-constructs a new context object from
other
. context & operator=(context && other) noexcept;Move-assigns the context from
other
to *this
. ~context();Destroys the context object.
cl_context & get() const;Returns the underlying OpenCL context.
device get_device() const;
Returns the device for the context. If the context contains multiple devices, the first is returned.
std::vector< device > get_devices() const;Returns a vector of devices for the context.
template<typename T> T get_info(cl_context_info info) const;
Returns information about the context.
See the documentation for
template<int Enum> unspecified get_info() const;This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
bool operator==(const context & other) const;Returns
true
if the context is the same as other
. bool operator!=(const context & other) const;Returns
true
if the context is different from other
.