ViennaCL - The Vienna Computing Library  1.7.0
Free open-source GPU-accelerated linear algebra and solver library.
viennacl::ocl Namespace Reference

OpenCL backend. Manages platforms, contexts, buffers, kernels, etc. More...

Classes

struct  accelerator_tag
 A tag identifying OpenCL devices as accelerators (e.g. Intel Xeon Phi) More...
 
class  backend
 A backend that provides contexts for ViennaCL objects (vector, matrix, etc.) More...
 
class  build_program_failure
 Exception thrown if the OpenCL program cannot be built, usually due to a syntax error in the OpenCL code. More...
 
class  command_queue
 A class representing a command queue. More...
 
class  compiler_not_available
 Exception thrown if the OpenCL just-in-time compiler is not available. More...
 
class  context
 Manages an OpenCL context and provides the respective convenience functions for creating buffers, etc. More...
 
struct  cpu_tag
 A tag identifying OpenCL devices as CPUs. More...
 
struct  default_tag
 A tag denoting the default OpenCL device type (SDK-specific) More...
 
class  device
 A class representing a compute device (e.g. a GPU) More...
 
class  device_not_available
 Exception thrown if the selected compute device is not available (maybe locked by another process). More...
 
class  device_not_found
 Exception thrown in the case that a requested compute device was not found. More...
 
struct  DOUBLE_PRECISION_CHECKER
 Ensures that double precision types are only allocated if it is supported by the device. If double precision is requested for a device not capable of providing that, a double_precision_not_provided_error is thrown. More...
 
class  double_precision_not_provided_error
 Exception thrown if the user wants to use double precision arithmetics, but the device does not support double precision. More...
 
struct  error_checker
 An error reporting class. Template argument is used to avoid problems with external linkage. More...
 
struct  gpu_tag
 A tag identifying OpenCL devices as GPUs. More...
 
class  handle
 Handle class the effectively represents a smart pointer for OpenCL handles. More...
 
class  handle_inc_dec_helper
 Helper for OpenCL reference counting used by class handle. More...
 
class  image_format_mismatch
 Exception thrown if there is a mismatch in image formats for the operands. More...
 
class  image_format_not_supported
 Exception thrown if the requested image format is not supported. More...
 
class  invalid_arg_index
 Exception thrown if the kernel argument index is invalid, e.g. an arg index larger than the number of kernel arguments was provided. More...
 
class  invalid_arg_size
 Exception thrown if the arguments to an OpenCL kernel have an invalid size e.g. not sizeof(cl_mem)). More...
 
class  invalid_arg_value
 Exception thrown if the kernel argument provided has an invalid value. More...
 
class  invalid_binary
 Exception thrown if the OpenCL binary (generated from the jit-compiler or loaded from some other location) won't work on the device (e.g. due to a lack of double precision support). More...
 
class  invalid_buffer_size
 Exception thrown if the provided buffer size is invalid (e.g. zero) More...
 
class  invalid_build_options
 Exception thrown if invalid build options are passed to the OpenCL just-in-time compiler. More...
 
class  invalid_command_queue
 Exception thrown if an invalid OpenCL command queue is provided to an OpenCL function. More...
 
class  invalid_context
 Exception thrown if an invalid OpenCL context is provided to an OpenCL function. More...
 
class  invalid_device
 Exception thrown if an invalid OpenCL device is provided to an OpenCL function. More...
 
class  invalid_device_type
 Exception thrown if an invalid device type is specified. More...
 
class  invalid_event
 Exception thrown if the provided event object (of type cl_event) is invalid. More...
 
class  invalid_event_wait_list
 Exception thrown if the provided event wait list is invalid. More...
 
class  invalid_gl_object
 Exception thrown if the provided OpenGL (not OpenCL) object is invalid. More...
 
class  invalid_global_offset
 Exception thrown if the provided offset for get_global_id() in OpenCL kernels is invalid. More...
 
class  invalid_global_work_size
 Exception thrown if the total number of work items is invalid (for example, not divisible by the number of work items per work group). More...
 
class  invalid_host_ptr
 Exception thrown if the provided pointer to host memory is invalid. More...
 
class  invalid_image_format_descriptor
 Exception thrown if an invalid image format descriptor is provided. More...
 
class  invalid_image_size
 Exception thrown if the image size provided is invalid (e.g. zero). More...
 
class  invalid_kernel
 Exception thrown if the provided kernel object (of type cl_kernel) is invalid (e.g. not initialized, from different context, or corrupted). More...
 
class  invalid_kernel_args
 Exception thrown if the kernel arguments are invalid and/or do not fit the kernel parameter list. More...
 
class  invalid_kernel_definition
 Exception thrown if the kernel definition (number of arguments, argument types, etc.) is not the same for all devices for which the program has been built. More...
 
class  invalid_kernel_name
 Exception thrown if the provided kernel name is invalid (e.g. not part of the program provided). More...
 
class  invalid_mem_object
 Exception thrown if an invalid OpenCL memory object (of type cl_mem) is passed to an OpenCL funciton. More...
 
class  invalid_mip_level
 Exception thrown if the provided miplevel is greater than zero, but the OpenGL implementation does not support creating from non-zero mipmap levels. More...
 
class  invalid_operation
 Exception thrown if interoperability of OpenCL with other frameworks collide. More...
 
class  invalid_platform
 Exception thrown if an invalid OpenCL platform is provided to an OpenCL function. More...
 
class  invalid_program
 Exception thrown if an OpenCL program object handle is invalid (e.g. not initialized). More...
 
class  invalid_program_executable
 Exception thrown if there is no built program exectuable available for the device. More...
 
class  invalid_property
 Exception thrown if an invalid property is provided to a function (vague value). More...
 
class  invalid_queue_properties
 Exception thrown if invalid OpenCL command queue properties are provided when creating a command queue. More...
 
class  invalid_sampler
 Exception thrown if an invalid sampler is provided for an image. More...
 
class  invalid_value
 Exception thrown is an invalid value is provided to an OpenCL function. More...
 
class  invalid_work_dimension
 Exception thrown if the work dimension is invalid (usually this means that the work dimension was set to be larger than three. More...
 
class  invalid_work_group_size
 Exception thrown if the number of work groups is invalid (usually this means that more than 256/512/768/1024 work groups have been specified, but the device(s) cannot support this. More...
 
class  invalid_work_item_size
 Exception thrown if the number of work items per work group invalid (usually this means that more than 256/512/768/1024 work items have been specified, but the device(s) cannot support this. More...
 
class  kernel
 Represents an OpenCL kernel within ViennaCL. More...
 
class  kernel_not_found
 
class  local_mem
 A class representing local (shared) OpenCL memory. Typically used as kernel argument. More...
 
class  map_failure
 Exception thrown if the mapping of device memory to the host memory space failed. More...
 
class  mem_copy_overlap
 Exception thrown if the source buffer overlaps the destination buffer when copying from device memory to device memory. More...
 
class  mem_object_allocation_failure
 Exception thrown if a memory object cannot be allocated. Usually the requested memory buffer is simply too large. More...
 
class  out_of_host_memory
 Exception thrown if the host cannot provide enough memory for the datastructures in the OpenCL backend (temporary arrays, etc.) to perform the requested operation. More...
 
class  out_of_resources
 Exception thrown if the compute device is out of resources (either global memory, registers, etc.) for the requested operation. More...
 
struct  packed_cl_uint
 Helper class for packing four cl_uint numbers into a uint4 type for access inside an OpenCL kernel. More...
 
class  platform
 Wrapper class for an OpenCL platform. More...
 
class  profiling_info_not_available
 Exception thrown if the OpenCL context does not have CL_QUEUE_PROFILING_ENABLE set, if the execution is not complete, or the event object is a user event object. More...
 
class  program
 Wrapper class for an OpenCL program. More...
 
class  program_not_found
 
class  queue_not_found
 
struct  type_to_string
 Helper class for converting a type to its string representation. More...
 
class  unknown_error
 Exception thrown if the returned error cannot be resolved to some defined error constant. Might result from invalid sources, invalid memory operations, etc. More...
 

Enumerations

enum  vendor_id {
  beignet_id = 358, intel_id = 32902, nvidia_id = 4318, amd_id = 4098,
  unknown_id = 0
}
 
enum  device_architecture_family {
  tesla, fermi, kepler, maxwell,
  evergreen, northern_islands, southern_islands, volcanic_islands,
  unknown
}
 

Functions

viennacl::ocl::contextcurrent_context ()
 Convenience function for returning the current context. More...
 
void switch_context (long i)
 Convenience function for switching the current context. More...
 
viennacl::ocl::contextget_context (long i)
 Convenience function for returning the current context. More...
 
void setup_context (long i, std::vector< cl_device_id > const &devices)
 Convenience function for setting devices for a context. More...
 
void setup_context (long i, viennacl::ocl::device const &device)
 Convenience function for setting devices for a context. More...
 
void setup_context (long i, cl_context c, std::vector< cl_device_id > const &devices, std::map< cl_device_id, std::vector< cl_command_queue > > const &queues)
 Convenience function for setting up a context in ViennaCL from an existing OpenCL context. More...
 
void setup_context (long i, cl_context c, std::vector< cl_device_id > const &devices, std::vector< cl_command_queue > const &queues)
 Convenience function for setting up a context in ViennaCL from an existing OpenCL context. More...
 
void setup_context (long i, cl_context c, cl_device_id d, cl_command_queue q)
 Convenience function for setting up a context in ViennaCL from an existing OpenCL context. More...
 
void set_context_device_type (long i, cl_device_type dev_type)
 Convenience function for setting the default device type for a context. More...
 
void set_context_device_type (long i, viennacl::ocl::gpu_tag)
 Convenience function for setting the default device type for a context to GPUs. More...
 
void set_context_device_type (long i, viennacl::ocl::cpu_tag)
 Convenience function for setting the default device type for a context to CPUs. More...
 
void set_context_device_type (long i, viennacl::ocl::default_tag)
 Convenience function for setting the default device type for a context to the default OpenCL device type. More...
 
void set_context_device_type (long i, viennacl::ocl::accelerator_tag)
 Convenience function for setting the default device type for a context to accelerators. More...
 
void set_context_device_num (long i, vcl_size_t num)
 Convenience function for setting the number of default devices per context. More...
 
void set_context_platform_index (long i, vcl_size_t pf_index)
 Convenience function for setting the platform index. More...
 
viennacl::ocl::command_queueget_queue ()
 Convenience function for getting the default queue for the currently active device in the active context. More...
 
viennacl::ocl::command_queueget_queue (viennacl::ocl::device d, unsigned int queue_id=0)
 Convenience function for getting the queue for a particular device in the current active context. More...
 
viennacl::ocl::command_queueget_queue (cl_device_id dev_id, unsigned int queue_id=0)
 Convenience function for getting the queue for a particular device in the current active context. More...
 
viennacl::ocl::kernelget_kernel (std::string const &prog_name, std::string const &kernel_name)
 Convenience function for getting the kernel for a particular program from the current active context. More...
 
void switch_device (viennacl::ocl::device &d)
 Convenience function for switching the active device in the current context. More...
 
viennacl::ocl::device const & current_device ()
 Convenience function for returning the active device in the current context. More...
 
device_architecture_family get_architecture_family (cl_uint vendor_id, std::string const &name)
 
template<typename KernelType >
void enqueue (KernelType &k, viennacl::ocl::command_queue const &queue)
 Enqueues a kernel in the provided queue. More...
 
template<typename KernelType >
void enqueue (KernelType &k)
 Convenience function that enqueues the provided kernel into the first queue of the currently active device in the currently active context. More...
 
void enqueue (viennacl::device_specific::custom_operation &op, viennacl::ocl::command_queue const &queue)
 
void enqueue (viennacl::device_specific::custom_operation &op)
 
std::vector< platformget_platforms ()
 
template<typename T >
void append_double_precision_pragma (viennacl::ocl::context const &, std::string &)
 
template<>
void append_double_precision_pragma< double > (viennacl::ocl::context const &ctx, std::string &source)
 

Detailed Description

OpenCL backend. Manages platforms, contexts, buffers, kernels, etc.

Enumeration Type Documentation

Enumerator
tesla 
fermi 
kepler 
maxwell 
evergreen 
northern_islands 
southern_islands 
volcanic_islands 
unknown 

Definition at line 55 of file device_utils.hpp.

Enumerator
beignet_id 
intel_id 
nvidia_id 
amd_id 
unknown_id 

Definition at line 45 of file device_utils.hpp.

Function Documentation

template<typename T >
void viennacl::ocl::append_double_precision_pragma ( viennacl::ocl::context const &  ,
std::string &   
)

Definition at line 75 of file utils.hpp.

template<>
void viennacl::ocl::append_double_precision_pragma< double > ( viennacl::ocl::context const &  ctx,
std::string &  source 
)
inline

Definition at line 78 of file utils.hpp.

viennacl::ocl::context & viennacl::ocl::current_context ( )
inline

Convenience function for returning the current context.

Examples:
blas3.cpp, custom-context.cpp, and custom-kernels.cpp.

Definition at line 213 of file backend.hpp.

viennacl::ocl::device const & viennacl::ocl::current_device ( )
inline

Convenience function for returning the active device in the current context.

Examples:
amg.cpp, armadillo-with-viennacl.cpp, blas3.cpp, eigen-with-viennacl.cpp, mtl4-with-viennacl.cpp, and spai.cpp.

Definition at line 351 of file backend.hpp.

template<typename KernelType >
void viennacl::ocl::enqueue ( KernelType &  k,
viennacl::ocl::command_queue const &  queue 
)

Enqueues a kernel in the provided queue.

Examples:
custom-context.cpp, custom-kernels.cpp, and matrix-free.cpp.

Definition at line 50 of file enqueue.hpp.

template<typename KernelType >
void viennacl::ocl::enqueue ( KernelType &  k)

Convenience function that enqueues the provided kernel into the first queue of the currently active device in the currently active context.

Definition at line 131 of file enqueue.hpp.

void viennacl::ocl::enqueue ( viennacl::device_specific::custom_operation &  op,
viennacl::ocl::command_queue const &  queue 
)
inline

Definition at line 136 of file enqueue.hpp.

void viennacl::ocl::enqueue ( viennacl::device_specific::custom_operation &  op)
inline

Definition at line 141 of file enqueue.hpp.

device_architecture_family viennacl::ocl::get_architecture_family ( cl_uint  vendor_id,
std::string const &  name 
)
inline

Definition at line 72 of file device_utils.hpp.

viennacl::ocl::context& viennacl::ocl::get_context ( long  i)
inline

Convenience function for returning the current context.

Examples:
amg.cpp, examples/tutorial/libviennacl.cpp, multithreaded.cpp, multithreaded_cg.cpp, and spai.cpp.

Definition at line 225 of file backend.hpp.

viennacl::ocl::kernel& viennacl::ocl::get_kernel ( std::string const &  prog_name,
std::string const &  kernel_name 
)
inline

Convenience function for getting the kernel for a particular program from the current active context.

Definition at line 339 of file backend.hpp.

std::vector< platform > viennacl::ocl::get_platforms ( )
inline
viennacl::ocl::command_queue& viennacl::ocl::get_queue ( )
inline

Convenience function for getting the default queue for the currently active device in the active context.

Definition at line 320 of file backend.hpp.

viennacl::ocl::command_queue& viennacl::ocl::get_queue ( viennacl::ocl::device  d,
unsigned int  queue_id = 0 
)
inline

Convenience function for getting the queue for a particular device in the current active context.

Definition at line 326 of file backend.hpp.

viennacl::ocl::command_queue& viennacl::ocl::get_queue ( cl_device_id  dev_id,
unsigned int  queue_id = 0 
)
inline

Convenience function for getting the queue for a particular device in the current active context.

Definition at line 332 of file backend.hpp.

void viennacl::ocl::set_context_device_num ( long  i,
vcl_size_t  num 
)
inline

Convenience function for setting the number of default devices per context.

Definition at line 302 of file backend.hpp.

void viennacl::ocl::set_context_device_type ( long  i,
cl_device_type  dev_type 
)
inline

Convenience function for setting the default device type for a context.

Definition at line 272 of file backend.hpp.

void viennacl::ocl::set_context_device_type ( long  i,
viennacl::ocl::gpu_tag   
)
inline

Convenience function for setting the default device type for a context to GPUs.

Definition at line 278 of file backend.hpp.

void viennacl::ocl::set_context_device_type ( long  i,
viennacl::ocl::cpu_tag   
)
inline

Convenience function for setting the default device type for a context to CPUs.

Definition at line 284 of file backend.hpp.

void viennacl::ocl::set_context_device_type ( long  i,
viennacl::ocl::default_tag   
)
inline

Convenience function for setting the default device type for a context to the default OpenCL device type.

Definition at line 290 of file backend.hpp.

void viennacl::ocl::set_context_device_type ( long  i,
viennacl::ocl::accelerator_tag   
)
inline

Convenience function for setting the default device type for a context to accelerators.

Definition at line 296 of file backend.hpp.

void viennacl::ocl::set_context_platform_index ( long  i,
vcl_size_t  pf_index 
)
inline

Convenience function for setting the platform index.

Parameters
iContext ID
pf_indexThe platform index as returned by clGetPlatformIDs(). This is not the ID of type cl_platform_id!

Definition at line 313 of file backend.hpp.

void viennacl::ocl::setup_context ( long  i,
std::vector< cl_device_id > const &  devices 
)
inline

Convenience function for setting devices for a context.

Examples:
amg.cpp, custom-context.cpp, multithreaded.cpp, multithreaded_cg.cpp, and spai.cpp.

Definition at line 231 of file backend.hpp.

void viennacl::ocl::setup_context ( long  i,
viennacl::ocl::device const &  device 
)
inline

Convenience function for setting devices for a context.

Definition at line 238 of file backend.hpp.

void viennacl::ocl::setup_context ( long  i,
cl_context  c,
std::vector< cl_device_id > const &  devices,
std::map< cl_device_id, std::vector< cl_command_queue > > const &  queues 
)
inline

Convenience function for setting up a context in ViennaCL from an existing OpenCL context.

Definition at line 247 of file backend.hpp.

void viennacl::ocl::setup_context ( long  i,
cl_context  c,
std::vector< cl_device_id > const &  devices,
std::vector< cl_command_queue > const &  queues 
)
inline

Convenience function for setting up a context in ViennaCL from an existing OpenCL context.

Definition at line 256 of file backend.hpp.

void viennacl::ocl::setup_context ( long  i,
cl_context  c,
cl_device_id  d,
cl_command_queue  q 
)
inline

Convenience function for setting up a context in ViennaCL from an existing OpenCL context.

Definition at line 262 of file backend.hpp.

void viennacl::ocl::switch_context ( long  i)
inline

Convenience function for switching the current context.

Examples:
custom-context.cpp.

Definition at line 219 of file backend.hpp.

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

Convenience function for switching the active device in the current context.

Definition at line 345 of file backend.hpp.