Manages an OpenCL context and provides the respective convenience functions for creating buffers, etc. More...
#include <context.hpp>
Public Member Functions | |
context () | |
std::string | cache_path () const |
Returns the compiled kernel cache path. More... | |
void | cache_path (std::string new_path) |
Sets the compiled kernel cache path. More... | |
vcl_size_t | default_device_num () const |
Returns the maximum number of devices to be set up for the context. More... | |
void | default_device_num (vcl_size_t new_num) |
Sets the maximum number of devices to be set up for the context. More... | |
cl_device_type | default_device_type () |
Returns the default device type for the context. More... | |
void | default_device_type (cl_device_type dtype) |
Sets the device type for this context. More... | |
std::vector < viennacl::ocl::device > const & | devices () const |
Returns a vector with all devices in this context. More... | |
viennacl::ocl::device const & | current_device () const |
Returns the current device. More... | |
void | switch_device (vcl_size_t i) |
Switches the current device to the i-th device in this context. More... | |
void | switch_device (viennacl::ocl::device const &d) |
If the supplied device is used within the context, it becomes the current active device. More... | |
void | add_device (viennacl::ocl::device const &d) |
Add a device to the context. Must be done before the context is initialized. More... | |
void | add_device (cl_device_id d) |
Add a device to the context. Must be done before the context is initialized. More... | |
void | init () |
Initializes a new context. More... | |
void | init (cl_context c) |
Initializes the context from an existing, user-supplied context. More... | |
cl_mem | create_memory_without_smart_handle (cl_mem_flags flags, unsigned int size, void *ptr=NULL) const |
Creates a memory buffer within the context. Does not wrap the OpenCL handle into the smart-pointer-like viennacl::ocl::handle, which saves an OpenCL backend call, yet the user has to ensure that the OpenCL memory handle is free'd or passed to a viennacl::ocl::handle later on. More... | |
viennacl::ocl::handle< cl_mem > | create_memory (cl_mem_flags flags, unsigned int size, void *ptr=NULL) const |
Creates a memory buffer within the context. More... | |
template<typename NumericT , typename A , template< typename, typename > class VectorType> | |
viennacl::ocl::handle< cl_mem > | create_memory (cl_mem_flags flags, const VectorType< NumericT, A > &buffer) const |
Creates a memory buffer within the context initialized from the supplied data. More... | |
void | add_queue (cl_device_id dev, cl_command_queue q) |
Adds an existing queue for the given device to the context. More... | |
void | add_queue (cl_device_id dev) |
Adds a queue for the given device to the context. More... | |
void | add_queue (viennacl::ocl::device d) |
Adds a queue for the given device to the context. More... | |
viennacl::ocl::command_queue & | get_queue () |
viennacl::ocl::command_queue const & | get_queue () const |
viennacl::ocl::command_queue & | get_queue (cl_device_id dev, vcl_size_t i=0) |
Returns the queue with the provided index for the given device. More... | |
viennacl::ocl::command_queue const & | current_queue () |
Returns the current device. More... | |
void | switch_queue (vcl_size_t i) |
Switches the current device to the i-th device in this context. More... | |
void | switch_queue (viennacl::ocl::command_queue const &q) |
If the supplied command_queue is used within the context, it becomes the current active command_queue, the command_queue's device becomes current active device. More... | |
viennacl::ocl::program & | add_program (cl_program p, std::string const &prog_name) |
Adds a program to the context. More... | |
viennacl::ocl::program & | add_program (std::string const &source, std::string const &prog_name) |
Adds a new program with the provided source to the context. Compiles the program and extracts all kernels from it. More... | |
void | delete_program (std::string const &name) |
Delete the program with the provided name. More... | |
viennacl::ocl::program & | get_program (std::string const &name) |
Returns the program with the provided name. More... | |
viennacl::ocl::program const & | get_program (std::string const &name) const |
bool | has_program (std::string const &name) |
Returns whether the program with the provided name exists or not. More... | |
viennacl::ocl::program & | get_program (vcl_size_t id) |
Returns the program with the provided id. More... | |
program_container_type | get_programs () |
vcl_size_t | program_num () |
Returns the number of programs within this context. More... | |
viennacl::ocl::kernel & | get_kernel (std::string const &program_name, std::string const &kernel_name) |
Convenience function for retrieving the kernel of a program directly from the context. More... | |
vcl_size_t | device_num () |
Returns the number of devices within this context. More... | |
const viennacl::ocl::handle < cl_context > & | handle () const |
Returns the context handle. More... | |
std::string | build_options () const |
Returns the current build option string. More... | |
void | build_options (std::string op) |
Sets the build option string, which is passed to the OpenCL compiler in subsequent compilations. Does not effect programs already compiled previously. More... | |
vcl_size_t | platform_index () const |
Returns the platform ID of the platform to be used for the context. More... | |
void | platform_index (vcl_size_t new_index) |
Sets the platform ID of the platform to be used for the context. More... | |
bool | operator< (context const &other) const |
Less-than comparable for compatibility with std:map. More... | |
bool | operator== (context const &other) const |
Manages an OpenCL context and provides the respective convenience functions for creating buffers, etc.
This class was originally written before the OpenCL C++ bindings were standardized. Regardless, it provides a couple of convience functionality which is not covered by the OpenCL C++ bindings.
Definition at line 55 of file context.hpp.
|
inline |
Definition at line 60 of file context.hpp.
|
inline |
Add a device to the context. Must be done before the context is initialized.
Definition at line 146 of file context.hpp.
|
inline |
Add a device to the context. Must be done before the context is initialized.
Definition at line 157 of file context.hpp.
|
inline |
Adds a program to the context.
Definition at line 368 of file context.hpp.
|
inline |
Adds a new program with the provided source to the context. Compiles the program and extracts all kernels from it.
Definition at line 379 of file context.hpp.
|
inline |
Adds an existing queue for the given device to the context.
Definition at line 235 of file context.hpp.
|
inline |
Adds a queue for the given device to the context.
Definition at line 246 of file context.hpp.
|
inline |
Adds a queue for the given device to the context.
Definition at line 263 of file context.hpp.
|
inline |
Returns the current build option string.
Definition at line 614 of file context.hpp.
|
inline |
Sets the build option string, which is passed to the OpenCL compiler in subsequent compilations. Does not effect programs already compiled previously.
Definition at line 617 of file context.hpp.
|
inline |
Returns the compiled kernel cache path.
Definition at line 75 of file context.hpp.
|
inline |
Sets the compiled kernel cache path.
Definition at line 78 of file context.hpp.
|
inline |
Creates a memory buffer within the context.
flags | OpenCL flags for the buffer creation |
size | Size of the memory buffer in bytes |
ptr | Optional pointer to CPU memory, with which the OpenCL memory should be initialized |
Definition at line 216 of file context.hpp.
|
inline |
Creates a memory buffer within the context initialized from the supplied data.
flags | OpenCL flags for the buffer creation |
buffer | A vector (STL vector, ublas vector, etc.) |
Definition at line 227 of file context.hpp.
|
inline |
Creates a memory buffer within the context. Does not wrap the OpenCL handle into the smart-pointer-like viennacl::ocl::handle, which saves an OpenCL backend call, yet the user has to ensure that the OpenCL memory handle is free'd or passed to a viennacl::ocl::handle later on.
flags | OpenCL flags for the buffer creation |
size | Size of the memory buffer in bytes |
ptr | Optional pointer to CPU memory, with which the OpenCL memory should be initialized |
Definition at line 196 of file context.hpp.
|
inline |
Returns the current device.
Definition at line 112 of file context.hpp.
|
inline |
Returns the current device.
Definition at line 323 of file context.hpp.
|
inline |
Returns the maximum number of devices to be set up for the context.
Definition at line 82 of file context.hpp.
|
inline |
Sets the maximum number of devices to be set up for the context.
Definition at line 85 of file context.hpp.
|
inline |
Returns the default device type for the context.
Definition at line 89 of file context.hpp.
|
inline |
Sets the device type for this context.
Definition at line 95 of file context.hpp.
|
inline |
Delete the program with the provided name.
Definition at line 514 of file context.hpp.
|
inline |
Returns the number of devices within this context.
Definition at line 608 of file context.hpp.
|
inline |
Returns a vector with all devices in this context.
Definition at line 106 of file context.hpp.
|
inline |
Convenience function for retrieving the kernel of a program directly from the context.
Definition at line 605 of file context.hpp.
|
inline |
Returns the program with the provided name.
Definition at line 532 of file context.hpp.
|
inline |
Definition at line 551 of file context.hpp.
|
inline |
Returns the program with the provided id.
Definition at line 583 of file context.hpp.
|
inline |
Definition at line 596 of file context.hpp.
|
inline |
Definition at line 266 of file context.hpp.
|
inline |
Definition at line 276 of file context.hpp.
|
inline |
Returns the queue with the provided index for the given device.
Definition at line 301 of file context.hpp.
|
inline |
Returns the context handle.
Definition at line 611 of file context.hpp.
|
inline |
Returns whether the program with the provided name exists or not.
Definition at line 571 of file context.hpp.
|
inline |
Initializes a new context.
Definition at line 167 of file context.hpp.
|
inline |
Initializes the context from an existing, user-supplied context.
Definition at line 173 of file context.hpp.
|
inline |
Less-than comparable for compatibility with std:map.
Definition at line 630 of file context.hpp.
|
inline |
Definition at line 635 of file context.hpp.
|
inline |
Returns the platform ID of the platform to be used for the context.
Definition at line 620 of file context.hpp.
|
inline |
Sets the platform ID of the platform to be used for the context.
Definition at line 623 of file context.hpp.
|
inline |
Returns the number of programs within this context.
Definition at line 602 of file context.hpp.
|
inline |
Switches the current device to the i-th device in this context.
Definition at line 119 of file context.hpp.
|
inline |
If the supplied device is used within the context, it becomes the current active device.
Definition at line 126 of file context.hpp.
|
inline |
Switches the current device to the i-th device in this context.
Definition at line 329 of file context.hpp.
|
inline |
If the supplied command_queue is used within the context, it becomes the current active command_queue, the command_queue's device becomes current active device.
Definition at line 336 of file context.hpp.