DPC++ Runtime
Runtime libraries for oneAPI DPC++
syclcompat::args_selector< n_nondefault_params, n_default_params, R(Ts...)> Class Template Reference

args_selector is a helper class for extracting arguments from an array of pointers to arguments or buffer of arguments to pass to a kernel function. More...

#include <syclcompat/util.hpp>

Public Types

template<int i>
using arg_type = std::tuple_element_t< account_for_default_params< i >(), std::tuple< Ts... > >
 Get the type of the ith argument of R(Ts...) More...
 

Public Member Functions

 args_selector (void **kernel_params, void **extra)
 If kernel_params is nonnull, then args_selector will extract arguments from kernel_params. More...
 
template<int i>
arg_type< i > & get ()
 Get a reference to the ith argument extracted from kernel_params or extra. More...
 

Detailed Description

template<int n_nondefault_params, int n_default_params, typename R, typename... Ts>
class syclcompat::args_selector< n_nondefault_params, n_default_params, R(Ts...)>

args_selector is a helper class for extracting arguments from an array of pointers to arguments or buffer of arguments to pass to a kernel function.

Parameters
R(Ts...)The type of the kernel
n_nondefault_paramsThe number of nondefault parameters of the kernel (excluding parameters that like sycl::nd_item, etc.)
n_default_paramsThe number of default parameters of the kernel

Example usage: With the following kernel: void foo(sycl::float2 x, int n, sycl::nd_item<3> item_ct1, float f=.1) {} and with the declaration: args_selector<2, 1, decltype(foo)> selector(kernelParams, extra); void kernelParams[2 + 1] = { (void*)float2_var, int_var, float_var } we have: selector.get<0>() returns a reference to sycl::float*, selector.get<1>() returns a reference to int, selector.get<2>() returns a reference to float

Definition at line 952 of file util.hpp.

Member Typedef Documentation

◆ arg_type

template<int n_nondefault_params, int n_default_params, typename R , typename... Ts>
template<int i>
using syclcompat::args_selector< n_nondefault_params, n_default_params, R(Ts...)>::arg_type = std::tuple_element_t<account_for_default_params<i>(), std::tuple<Ts...> >

Get the type of the ith argument of R(Ts...)

Parameters
[in]iIndex of parameter to get
Returns
Type of ith parameter

Definition at line 971 of file util.hpp.

Constructor & Destructor Documentation

◆ args_selector()

template<int n_nondefault_params, int n_default_params, typename R , typename... Ts>
syclcompat::args_selector< n_nondefault_params, n_default_params, R(Ts...)>::args_selector ( void **  kernel_params,
void **  extra 
)
inline

If kernel_params is nonnull, then args_selector will extract arguments from kernel_params.

Otherwise, it will extract them from extra.

Parameters
[in]kernel_paramsArray of pointers to arguments a or null pointer.
[in]extraArray containing pointer to argument buffer.

Definition at line 1014 of file util.hpp.

Member Function Documentation

◆ get()

template<int n_nondefault_params, int n_default_params, typename R , typename... Ts>
template<int i>
arg_type<i>& syclcompat::args_selector< n_nondefault_params, n_default_params, R(Ts...)>::get ( )
inline

Get a reference to the ith argument extracted from kernel_params or extra.

Parameters
[in]iIndex of argument to get
Returns
Reference to the ith argument

Definition at line 1021 of file util.hpp.


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