OpenCL C++ Bindings
cl::Program Class Reference

Program interface that implements cl_program. More...

#include <opencl.hpp>

Inheritance diagram for cl::Program:
cl::detail::Wrapper< cl_program >

Public Types

typedef vector< vector< unsigned char > > Binaries
 
typedef vector< string > Sources
 
- Public Types inherited from cl::detail::Wrapper< cl_program >
typedef cl_program cl_type
 

Public Member Functions

 Program (const string &source, bool build=false, cl_int *err=NULL)
 
 Program (const Context &context, const string &source, bool build=false, cl_int *err=NULL)
 
 Program (const Sources &sources, cl_int *err=NULL)
 
 Program (const Context &context, const Sources &sources, cl_int *err=NULL)
 
 Program (const vector< char > &IL, bool build=false, cl_int *err=NULL)
 
 Program (const Context &context, const vector< char > &IL, bool build=false, cl_int *err=NULL)
 
 Program (const Context &context, const vector< Device > &devices, const Binaries &binaries, vector< cl_int > *binaryStatus=NULL, cl_int *err=NULL)
 
 Program (const Context &context, const vector< Device > &devices, const string &kernelNames, cl_int *err=NULL)
 
 Program (const cl_program &program, bool retainObject=false)
 Constructor from cl_program - takes ownership. More...
 
Programoperator= (const cl_program &rhs)
 
 Program (const Program &program)
 Copy constructor to forward copy to the superclass correctly. Required for MSVC. More...
 
Programoperator= (const Program &program)
 Copy assignment to forward copy to the superclass correctly. Required for MSVC. More...
 
 Program (Program &&program) CL_HPP_NOEXCEPT_
 Move constructor to forward move to the superclass correctly. Required for MSVC. More...
 
Programoperator= (Program &&program)
 Move assignment to forward move to the superclass correctly. Required for MSVC. More...
 
cl_int build (const vector< Device > &devices, const char *options=NULL, void(CL_CALLBACK *notifyFptr)(cl_program, void *)=NULL, void *data=NULL) const
 
cl_int build (const Device &device, const char *options=NULL, void(CL_CALLBACK *notifyFptr)(cl_program, void *)=NULL, void *data=NULL) const
 
cl_int build (const char *options=NULL, void(CL_CALLBACK *notifyFptr)(cl_program, void *)=NULL, void *data=NULL) const
 
cl_int compile (const char *options=NULL, void(CL_CALLBACK *notifyFptr)(cl_program, void *)=NULL, void *data=NULL) const
 
template<typename T >
cl_int getInfo (cl_program_info name, T *param) const
 
template<cl_program_info name>
detail::param_traits< detail::cl_program_info, name >::param_type getInfo (cl_int *err=NULL) const
 
template<typename T >
cl_int getBuildInfo (const Device &device, cl_program_build_info name, T *param) const
 
template<cl_program_build_info name>
detail::param_traits< detail::cl_program_build_info, name >::param_type getBuildInfo (const Device &device, cl_int *err=NULL) const
 
template<cl_program_build_info name>
vector< std::pair< cl::Device, typename detail::param_traits< detail::cl_program_build_info, name >::param_type > > getBuildInfo (cl_int *err=NULL) const
 
cl_int createKernels (vector< Kernel > *kernels)
 
CL_API_PREFIX__VERSION_2_2_DEPRECATED cl_int setReleaseCallback (void(CL_CALLBACK *pfn_notify)(cl_program program, void *user_data), void *user_data=NULL) CL_API_SUFFIX__VERSION_2_2_DEPRECATED
 Registers a callback function to be called when destructors for program scope global variables are complete and before the program is released. More...
 
template<typename T >
std::enable_if<!std::is_pointer< T >::value, cl_int >::type setSpecializationConstant (cl_uint index, const T &value)
 Sets a SPIR-V specialization constant. More...
 
cl_int setSpecializationConstant (cl_uint index, size_type size, const void *value)
 Sets a SPIR-V specialization constant. More...
 
template<>
cl_int getInfo (cl_program_info name, vector< vector< unsigned char > > *param) const
 
template<>
vector< vector< unsigned char > > getInfo (cl_int *err) const
 
template<>
cl_int setSpecializationConstant (cl_uint index, const bool &value)
 
- Public Member Functions inherited from cl::detail::Wrapper< cl_program >
 Wrapper (const cl_type &obj, bool retainObject)
 
 Wrapper (const Wrapper< cl_type > &rhs)
 
 Wrapper (Wrapper< cl_type > &&rhs) CL_HPP_NOEXCEPT_
 
Wrapper< cl_type > & operator= (const Wrapper< cl_type > &rhs)
 
Wrapper< cl_type > & operator= (Wrapper< cl_type > &&rhs)
 
Wrapper< cl_type > & operator= (const cl_type &rhs)
 
const cl_type & operator() () const
 
cl_type & operator() ()
 
cl_type get () const
 

Additional Inherited Members

- Protected Member Functions inherited from cl::detail::Wrapper< cl_program >
cl_int retain () const
 
cl_int release () const
 
- Protected Attributes inherited from cl::detail::Wrapper< cl_program >
cl_type object_
 

Detailed Description

Program interface that implements cl_program.

Definition at line 6270 of file opencl.hpp.

Member Typedef Documentation

◆ Binaries

typedef vector<vector<unsigned char> > cl::Program::Binaries

Definition at line 6274 of file opencl.hpp.

◆ Sources

typedef vector<string> cl::Program::Sources

Definition at line 6275 of file opencl.hpp.

Constructor & Destructor Documentation

◆ Program() [1/12]

cl::Program::Program ( const string &  source,
bool  build = false,
cl_int *  err = NULL 
)
inline

Definition at line 6281 of file opencl.hpp.

◆ Program() [2/12]

cl::Program::Program ( const Context context,
const string &  source,
bool  build = false,
cl_int *  err = NULL 
)
inline

Definition at line 6320 of file opencl.hpp.

◆ Program() [3/12]

cl::Program::Program ( const Sources &  sources,
cl_int *  err = NULL 
)
inline

Create a program from a vector of source strings and the default context. Does not compile or link the program.

Definition at line 6361 of file opencl.hpp.

◆ Program() [4/12]

cl::Program::Program ( const Context context,
const Sources &  sources,
cl_int *  err = NULL 
)
inline

Create a program from a vector of source strings and a provided context. Does not compile or link the program.

Definition at line 6396 of file opencl.hpp.

◆ Program() [5/12]

cl::Program::Program ( const vector< char > &  IL,
bool  build = false,
cl_int *  err = NULL 
)
inline

Program constructor to allow construction of program from SPIR-V or another IL. Valid for either OpenCL >= 2.1 or when CL_HPP_USE_IL_KHR is defined.

Definition at line 6433 of file opencl.hpp.

◆ Program() [6/12]

cl::Program::Program ( const Context context,
const vector< char > &  IL,
bool  build = false,
cl_int *  err = NULL 
)
inline

Program constructor to allow construction of program from SPIR-V or another IL for a specific context. Valid for either OpenCL >= 2.1 or when CL_HPP_USE_IL_KHR is defined.

Definition at line 6487 of file opencl.hpp.

◆ Program() [7/12]

cl::Program::Program ( const Context context,
const vector< Device > &  devices,
const Binaries &  binaries,
vector< cl_int > *  binaryStatus = NULL,
cl_int *  err = NULL 
)
inline

Construct a program object from a list of devices and a per-device list of binaries.

Parameters
contextA valid OpenCL context in which to construct the program.
devicesA vector of OpenCL device objects for which the program will be created.
binariesA vector of pairs of a pointer to a binary object and its length.
binaryStatusAn optional vector that on completion will be resized to match the size of binaries and filled with values to specify if each binary was successfully loaded. Set to CL_SUCCESS if the binary was successfully loaded. Set to CL_INVALID_VALUE if the length is 0 or the binary pointer is NULL. Set to CL_INVALID_BINARY if the binary provided is not valid for the matching device.
errif non-NULL will be set to CL_SUCCESS on successful operation or one of the following errors: CL_INVALID_CONTEXT if context is not a valid context. CL_INVALID_VALUE if the length of devices is zero; or if the length of binaries does not match the length of devices; or if any entry in binaries is NULL or has length 0. CL_INVALID_DEVICE if OpenCL devices listed in devices are not in the list of devices associated with context. CL_INVALID_BINARY if an invalid program binary was encountered for any device. binaryStatus will return specific status for each device. CL_OUT_OF_HOST_MEMORY if there is a failure to allocate resources required by the OpenCL implementation on the host.

Definition at line 6554 of file opencl.hpp.

◆ Program() [8/12]

cl::Program::Program ( const Context context,
const vector< Device > &  devices,
const string &  kernelNames,
cl_int *  err = NULL 
)
inline

Create program using builtin kernels.

Parameters
kernelNamesSemi-colon separated list of builtin kernel names

Definition at line 6618 of file opencl.hpp.

◆ Program() [9/12]

cl::Program::Program ( )
inline

Definition at line 6647 of file opencl.hpp.

◆ Program() [10/12]

cl::Program::Program ( const cl_program &  program,
bool  retainObject = false 
)
inlineexplicit

Constructor from cl_program - takes ownership.

Parameters
retainObjectwill cause the constructor to retain its cl object. Defaults to false to maintain compatibility with earlier versions.

Definition at line 6656 of file opencl.hpp.

◆ Program() [11/12]

cl::Program::Program ( const Program program)
inline

Copy constructor to forward copy to the superclass correctly. Required for MSVC.

Definition at line 6668 of file opencl.hpp.

◆ Program() [12/12]

cl::Program::Program ( Program &&  program)
inline

Move constructor to forward move to the superclass correctly. Required for MSVC.

Definition at line 6682 of file opencl.hpp.

Member Function Documentation

◆ build() [1/3]

cl_int cl::Program::build ( const char *  options = NULL,
void(CL_CALLBACK *notifyFptr)(cl_program, void *)  = NULL,
void *  data = NULL 
) const
inline

Definition at line 6739 of file opencl.hpp.

◆ build() [2/3]

cl_int cl::Program::build ( const Device device,
const char *  options = NULL,
void(CL_CALLBACK *notifyFptr)(cl_program, void *)  = NULL,
void *  data = NULL 
) const
inline

Definition at line 6718 of file opencl.hpp.

◆ build() [3/3]

cl_int cl::Program::build ( const vector< Device > &  devices,
const char *  options = NULL,
void(CL_CALLBACK *notifyFptr)(cl_program, void *)  = NULL,
void *  data = NULL 
) const
inline

Definition at line 6693 of file opencl.hpp.

◆ compile()

cl_int cl::Program::compile ( const char *  options = NULL,
void(CL_CALLBACK *notifyFptr)(cl_program, void *)  = NULL,
void *  data = NULL 
) const
inline

Definition at line 6756 of file opencl.hpp.

◆ createKernels()

cl_int cl::Program::createKernels ( vector< Kernel > *  kernels)
inline

Definition at line 6863 of file opencl.hpp.

◆ getBuildInfo() [1/3]

template<cl_program_build_info name>
vector< std::pair< cl::Device, typename detail::param_traits< detail::cl_program_build_info, name >::param_type > > cl::Program::getBuildInfo ( cl_int *  err = NULL) const
inline

Build info function that returns a vector of device/info pairs for the specified info type and for all devices in the program. On an error reading the info for any device, an empty vector of info will be returned.

Definition at line 6826 of file opencl.hpp.

◆ getBuildInfo() [2/3]

template<cl_program_build_info name>
detail::param_traits< detail::cl_program_build_info, name >::param_type cl::Program::getBuildInfo ( const Device device,
cl_int *  err = NULL 
) const
inline

Definition at line 6808 of file opencl.hpp.

◆ getBuildInfo() [3/3]

template<typename T >
cl_int cl::Program::getBuildInfo ( const Device device,
cl_program_build_info  name,
T *  param 
) const
inline

Definition at line 6797 of file opencl.hpp.

◆ getInfo() [1/4]

template<>
vector< vector< unsigned char > > cl::Program::getInfo ( cl_int *  err) const
inline

Definition at line 7033 of file opencl.hpp.

◆ getInfo() [2/4]

template<cl_program_info name>
detail::param_traits< detail::cl_program_info, name >::param_type cl::Program::getInfo ( cl_int *  err = NULL) const
inline

Definition at line 6785 of file opencl.hpp.

◆ getInfo() [3/4]

template<typename T >
cl_int cl::Program::getInfo ( cl_program_info  name,
T *  param 
) const
inline

Definition at line 6776 of file opencl.hpp.

◆ getInfo() [4/4]

template<>
cl_int cl::Program::getInfo ( cl_program_info  name,
vector< vector< unsigned char > > *  param 
) const
inline

Definition at line 7033 of file opencl.hpp.

◆ operator=() [1/3]

Program & cl::Program::operator= ( const cl_program &  rhs)
inline

Definition at line 6659 of file opencl.hpp.

◆ operator=() [2/3]

Program & cl::Program::operator= ( const Program program)
inline

Copy assignment to forward copy to the superclass correctly. Required for MSVC.

Definition at line 6673 of file opencl.hpp.

◆ operator=() [3/3]

Program & cl::Program::operator= ( Program &&  program)
inline

Move assignment to forward move to the superclass correctly. Required for MSVC.

Definition at line 6687 of file opencl.hpp.

◆ setReleaseCallback()

CL_API_PREFIX__VERSION_2_2_DEPRECATED cl_int cl::Program::setReleaseCallback ( void(CL_CALLBACK *pfn_notify)(cl_program program, void *user_data)  ,
void *  user_data = NULL 
)
inline

Registers a callback function to be called when destructors for program scope global variables are complete and before the program is released.

Wraps clSetProgramReleaseCallback().

Each call to this function registers the specified user callback function on a callback stack associated with program. The registered user callback functions are called in the reverse order in which they were registered.

Definition at line 6905 of file opencl.hpp.

◆ setSpecializationConstant() [1/3]

template<>
cl_int cl::Program::setSpecializationConstant ( cl_uint  index,
const bool &  value 
)
inline

Definition at line 7074 of file opencl.hpp.

◆ setSpecializationConstant() [2/3]

template<typename T >
std::enable_if<!std::is_pointer< T >::value, cl_int >::type cl::Program::setSpecializationConstant ( cl_uint  index,
const T &  value 
)
inline

Sets a SPIR-V specialization constant.

Wraps clSetProgramSpecializationConstant().

Definition at line 6924 of file opencl.hpp.

◆ setSpecializationConstant() [3/3]

cl_int cl::Program::setSpecializationConstant ( cl_uint  index,
size_type  size,
const void *  value 
)
inline

Sets a SPIR-V specialization constant.

Wraps clSetProgramSpecializationConstant().

Definition at line 6939 of file opencl.hpp.


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