KernelArg

struct KernelArg

An argument that will be passed to a kernel. A KernelArg can either be:

  • A scalar such as int, float, double, etc.

  • An array consisting of a pointer value (e.g., int*, float*) and a length that indicates the number of elements of the array’s type.

This class contains method to construct KernelArg and to convert it back into C++ value. Use into_kernel_arg to convert a value into KernelArg.

Public Functions

template<typename T>
inline T to() const

Convert this KernelArg to a value of type T. Throws an exception if this value is not of type T.

Value to_value() const

Convert this KernelArg to a Value. This is only valid for integer types (int, long, short, etc) and floating-point types (float, double, etc). Throws an exception if the inner type of this KernelArg cannot is not an integer or floating-point type.

Value to_value_or_empty() const

Identical to to_value, except returns an empty Value on error instead of throwing an exception.

TypeInfo type() const

Internal type of this object.

Public Static Functions

template<typename T>
static inline KernelArg from_scalar(T value)

Construct a KernelArg from a scalar.

template<typename T>
static inline KernelArg from_array(T *value, size_t nelements)

Construct a KernelArg from an array.