ViennaCL - The Vienna Computing Library  1.2.0
Public Member Functions
context Class Reference

#include <context.hpp>

Public Member Functions

 context ()
std::size_t default_device_num () const
 Returns the maximum number of devices to be set up for the context.
void default_device_num (std::size_t new_num)
 Sets the maximum number of devices to be set up for the context.
cl_device_type default_device_type ()
 Returns the default device type for the context.
void default_device_type (cl_device_type dtype)
 Sets the device type for this context.
std::vector
< viennacl::ocl::device >
const & 
devices () const
 Returns a vector with all devices in this context.
viennacl::ocl::device const & current_device () const
 Returns the current device.
void switch_device (size_t i)
 Switches the current device to the i-th device in this context.
void switch_device (viennacl::ocl::device const &d)
 If the supplied device is used within the context, it becomes the current active device.
void add_device (viennacl::ocl::device const &d)
 Add a device to the context. Must be done before the context is initialized.
void add_device (cl_device_id d)
 Add a device to the context. Must be done before the context is initialized.
void init ()
 Initializes a new context.
void init (cl_context c)
 Initializes the context from an existing, user-supplied context.
viennacl::ocl::handle< cl_mem > create_memory (cl_mem_flags flags, unsigned int size, void *ptr=NULL)
 Creates a memory buffer within the context.
template<typename SCALARTYPE , typename A , template< typename, typename > class VectorType>
viennacl::ocl::handle< cl_mem > create_memory (cl_mem_flags flags, const VectorType< SCALARTYPE, A > &_buffer)
 Creates a memory buffer within the context initialized from the supplied data.
void add_queue (cl_device_id dev, cl_command_queue q)
 Adds an existing queue for the given device to the context.
void add_queue (cl_device_id dev)
 Adds a queue for the given device to the context.
void add_queue (viennacl::ocl::device d)
 Adds a queue for the given device to the context.
viennacl::ocl::command_queueget_queue ()
viennacl::ocl::command_queueget_queue (cl_device_id dev, size_t i=0)
 Returns the queue with the provided index for the given device.
viennacl::ocl::programadd_program (cl_program p, std::string const &prog_name)
 Adds a program to the context.
viennacl::ocl::programadd_program (std::string const &source, std::string const &prog_name)
 Adds a new program with the provided source to the context.
viennacl::ocl::programget_program (std::string const &name)
 Returns the program with the provided name.
viennacl::ocl::programget_program (size_t id)
 Returns the program with the provided id.
size_t program_num ()
 Returns the number of programs within this context.
size_t device_num ()
 Returns the number of devices within this context.
const viennacl::ocl::handle
< cl_context > & 
handle () const
 Returns the context handle.
bool operator< (context const &other) const
 Less-than comparable for compatibility with std:map.

Constructor & Destructor Documentation

context ( )
inline

Member Function Documentation

void add_device ( viennacl::ocl::device const &  d)
inline

Add a device to the context. Must be done before the context is initialized.

void add_device ( cl_device_id  d)
inline

Add a device to the context. Must be done before the context is initialized.

viennacl::ocl::program& add_program ( cl_program  p,
std::string const &  prog_name 
)
inline

Adds a program to the context.

viennacl::ocl::program& add_program ( std::string const &  source,
std::string const &  prog_name 
)
inline

Adds a new program with the provided source to the context.

void add_queue ( cl_device_id  dev,
cl_command_queue  q 
)
inline

Adds an existing queue for the given device to the context.

void add_queue ( cl_device_id  dev)
inline

Adds a queue for the given device to the context.

void add_queue ( viennacl::ocl::device  d)
inline

Adds a queue for the given device to the context.

viennacl::ocl::handle<cl_mem> create_memory ( cl_mem_flags  flags,
unsigned int  size,
void *  ptr = NULL 
)
inline

Creates a memory buffer within the context.

Parameters
flagsOpenCL flags for the buffer creation
sizeSize of the memory buffer in bytes
ptrOptional pointer to CPU memory, with which the OpenCL memory should be initialized
viennacl::ocl::handle<cl_mem> create_memory ( cl_mem_flags  flags,
const VectorType< SCALARTYPE, A > &  _buffer 
)
inline

Creates a memory buffer within the context initialized from the supplied data.

Parameters
flagsOpenCL flags for the buffer creation
_bufferA vector (STL vector, ublas vector, etc.)
viennacl::ocl::device const& current_device ( ) const
inline

Returns the current device.

std::size_t default_device_num ( ) const
inline

Returns the maximum number of devices to be set up for the context.

void default_device_num ( std::size_t  new_num)
inline

Sets the maximum number of devices to be set up for the context.

cl_device_type default_device_type ( )
inline

Returns the default device type for the context.

void default_device_type ( cl_device_type  dtype)
inline

Sets the device type for this context.

size_t device_num ( )
inline

Returns the number of devices within this context.

std::vector<viennacl::ocl::device> const& devices ( ) const
inline

Returns a vector with all devices in this context.

viennacl::ocl::program& get_program ( std::string const &  name)
inline

Returns the program with the provided name.

viennacl::ocl::program& get_program ( size_t  id)
inline

Returns the program with the provided id.

viennacl::ocl::command_queue& get_queue ( )
inline
viennacl::ocl::command_queue& get_queue ( cl_device_id  dev,
size_t  i = 0 
)
inline

Returns the queue with the provided index for the given device.

const viennacl::ocl::handle<cl_context>& handle ( ) const
inline

Returns the context handle.

void init ( )
inline

Initializes a new context.

void init ( cl_context  c)
inline

Initializes the context from an existing, user-supplied context.

bool operator< ( context const &  other) const
inline

Less-than comparable for compatibility with std:map.

size_t program_num ( )
inline

Returns the number of programs within this context.

void switch_device ( size_t  i)
inline

Switches the current device to the i-th device in this context.

void switch_device ( viennacl::ocl::device const &  d)
inline

If the supplied device is used within the context, it becomes the current active device.


The documentation for this class was generated from the following file: