Define a templated mdspan class (non owner of data) More...
#include <cs_mdspan.h>
Collaboration diagram for mdspan< T, N, L >:Public Member Functions | |
| CS_F_HOST_DEVICE | mdspan () |
| Default constructor method leading to "empty container". More... | |
| template<typename... Args> | |
| CS_F_HOST_DEVICE | mdspan (T *data, Args... indices) |
| Constructor method using only global size (works for N=1). More... | |
| CS_F_HOST_DEVICE | mdspan (T *data, const cs_lnum_t(&dims)[N]) |
| Constructor method using dimensions. More... | |
| CS_F_HOST_DEVICE | mdspan (const mdspan &other) |
| Constructor method using copy. May be a shallow copy. More... | |
| CS_F_HOST_DEVICE | mdspan (mdspan &&other) |
| Move constructor. More... | |
| CS_F_HOST_DEVICE | ~mdspan () |
| Desstructor method using dimensions. More... | |
| CS_F_HOST mdspan & | operator= (const mdspan &other) |
| Assignment operator. More... | |
| CS_F_HOST_DEVICE mdspan & | operator= (mdspan &&other) |
| CS_F_HOST_DEVICE | operator T* () const |
| Cast operator to "T*" from this class. More... | |
| CS_F_HOST_DEVICE T & | operator[] (cs_lnum_t i) |
| Overloaded [] operator to access the ith value (val[i]). More... | |
| CS_F_HOST_DEVICE T & | operator[] (cs_lnum_t i) const |
| Overloaded [] operator to access the ith value (val[i]). More... | |
| template<typename Id1 > | |
| CS_F_HOST_DEVICE std::enable_if_t< cs::always_true< Id1 >::value &&N==1, T & > | operator() (Id1 i) |
| Overloaded () operator to access the ith value (val[i]). More... | |
| template<typename Id1 > | |
| CS_F_HOST_DEVICE std::enable_if_t< cs::always_true< Id1 >::value &&N==1, T & > | operator() (Id1 i) const |
| Overloaded [] operator to access the ith value (val[i]). More... | |
| template<typename Id1 , typename Id2 > | |
| CS_F_HOST_DEVICE std::enable_if_t< cs::always_true< Id1, Id2 >::value &&N==2, T & > | operator() (Id1 i, Id2 j) |
| Overloaded () operator to access the (i,j)-th value couple. More... | |
| template<typename Id1 , typename Id2 > | |
| CS_F_HOST_DEVICE std::enable_if_t< cs::always_true< Id1, Id2 >::value &&N==2, T & > | operator() (Id1 i, Id2 j) const |
| Overloaded () operator to access the (i,j)-th value couple. More... | |
| template<typename... Args> | |
| CS_F_HOST_DEVICE std::enable_if_t< cs::always_true< Args... >::value &&(N!=2) &&(N!=1), T & > | operator() (Args... indices) |
| Overloaded () operator to access the (i,j,k)-th value tuple. More... | |
| template<typename... Args> | |
| CS_F_HOST_DEVICE std::enable_if_t< cs::always_true< Args... >::value &&(N!=2) &&(N!=1), T & > | operator() (Args... indices) const |
| Overloaded () operator to access the (i,j,k)-th value tuple. More... | |
| CS_F_HOST_DEVICE void | set_data_ptr (T *data_ptr) const |
| Set data pointer. More... | |
| template<typename... Args> | |
| CS_F_HOST_DEVICE void | update_data (T *data_ptr, Args... dims) |
| Update data pointer and dimensions of span. More... | |
| CS_F_HOST_DEVICE bool | empty () const |
| Check if object is empty or not. More... | |
| CS_F_HOST_DEVICE cs_lnum_t | size () const |
| Getter for total size. More... | |
| CS_F_HOST_DEVICE cs_lnum_t | extent (int i) const |
| Getter for extent along a given dimension. More... | |
| CS_F_HOST_DEVICE cs_lnum_t | offset (int i) const |
| Getter for extent along a given dimension. More... | |
| CS_F_HOST_DEVICE T * | data () const |
| Getter for data raw pointer. More... | |
| template<typename U > | |
| CS_F_HOST_DEVICE U * | data () const |
| Getter for data raw pointer with recast (casts T* to U*) More... | |
| CS_F_HOST_DEVICE mdspan< T, 1, L > | view_1d () |
| Get span 1D view of the array, same total size. More... | |
| template<typename... Args> | |
| CS_F_HOST_DEVICE mdspan< T, N-sizeof...(Args), L > | sub_view (Args... indices) |
| Getter for a subspan based on first dimension. More... | |
| template<typename... Args> | |
| CS_F_HOST_DEVICE T * | sub_array (Args... indices) |
| Get sub array based on index. More... | |
| template<typename... Args> | |
| CS_F_HOST_DEVICE T * | sub_array (Args... indices) const |
| Get sub array based on index. More... | |
| CS_F_HOST void | set_to_val (T val, const cs_lnum_t n_vals=-1) |
| Set all values of the data array to a constant value. More... | |
| CS_F_HOST void | set_to_val (cs_dispatch_context &ctx, T val, const cs_lnum_t n_vals=-1) |
| Set all values of the data array to a constant value while providing a dispatch context. It is up to the call to synchronize the context after this call. More... | |
| CS_F_HOST void | set_to_val_on_subset (T val, const cs_lnum_t n_elts, const cs_lnum_t elt_ids[]) |
| Set subset of values of the data array to a constant value. More... | |
| CS_F_HOST void | set_to_val_on_subset (cs_dispatch_context &ctx, T val, const cs_lnum_t n_elts, const cs_lnum_t elt_ids[]) |
| Set a subset of values of the data array to a constant value while providing a dispatch context. It is up to the call to synchronize the context after this call. More... | |
| CS_F_HOST void | zero () |
| Set all values of the data array to 0. More... | |
| CS_F_HOST void | zero (cs_dispatch_context &ctx) |
| Set all values of the data array to 0. More... | |
| CS_F_HOST void | copy_data (const T *data, const cs_lnum_t n_vals=-1) |
| Copy data from const raw pointer, we suppose that data size is same as that of the array. More... | |
| CS_F_HOST void | copy_data (mdspan &other, const cs_lnum_t n_vals=-1) |
| Copy data from another mdspan, we suppose that data size is same as that of the array. An assert test the sizes in debug. More... | |
| CS_F_HOST void | copy_data (cs_dispatch_context &ctx, T *data, const cs_lnum_t n_vals=-1) |
| Copy data from raw pointer, we suppose that data size is same as that of the array. A dispatch_context is provided, hence no implicit synchronization which should be done by the caller. More... | |
| CS_F_HOST void | copy_data (cs_dispatch_context &ctx, const T *data, const cs_lnum_t n_vals=-1) |
| Copy data from const raw pointer, we suppose that data size is same as that of the array. A dispatch_context is provided, hence no implicit synchronization which should be done by the caller. More... | |
| CS_F_HOST void | copy_data (cs_dispatch_context &ctx, mdspan &other, const cs_lnum_t n_vals=-1) |
| Copy data from another mdspan, we suppose that data size is same as that of the array. An assert test the sizes in debug. More... | |
Protected Member Functions | |
| template<typename... Args> | |
| CS_F_HOST_DEVICE cs_lnum_t | data_offset_ (Args... indices) const |
| Helper function to compute value offset. More... | |
| template<typename... Args> | |
| CS_F_HOST_DEVICE cs_lnum_t | contiguous_data_offset_ (Args... indices) const |
| Helper function to compute value offset. More... | |
| CS_F_HOST_DEVICE void | set_size_ (const cs_lnum_t(&dims)[N]) |
| Set size of array based on dimensions. More... | |
| template<typename... Args> | |
| CS_F_HOST_DEVICE void | set_size_ (Args... dims) |
| Set size of N indices (variadic template) More... | |
| template<typename... Args> | |
| CS_F_HOST_DEVICE bool | check_bounds_ (Args... dims) const |
| Check if provided arguments are within array bounds. More... | |
Static Protected Member Functions | |
| template<typename... Args> | |
| static CS_F_HOST_DEVICE void | check_operator_args_ (Args...) |
| Helper function to static check operator input arguments. More... | |
| template<typename... Args> | |
| static CS_F_HOST_DEVICE void | check_sub_function_args_ (Args...) |
| Helper function to static check sub-function input arguments. More... | |
Protected Attributes | |
| cs_lnum_t | _extent [N] |
| cs_lnum_t | _offset [N] |
| cs_lnum_t | _size |
| T * | _data |
Friends | |
| template<class _T_ , int _N_, layout _L_> | |
| class | array |
| CS_F_HOST_DEVICE friend void | swap (mdspan &first, mdspan &second) |
| Class swap operator used for assignment or move. More... | |
Define a templated mdspan class (non owner of data)
| T | : data type |
| N | : number of dimensions (int) |
| L | : memory layout (cs::layout) |
|
inline |
Default constructor method leading to "empty container".
|
inline |
Constructor method using only global size (works for N=1).
| [in] | data | data pointer (raw) |
| [in] | indices | total size of data (1D) |
|
inline |
Constructor method using dimensions.
| [in] | data | data pointer (raw) |
| [in] | dims | array of sizes along dimensions |
|
inline |
Constructor method using copy. May be a shallow copy.
|
inline |
Move constructor.
| [in] | other | reference to other instance |
|
inline |
Desstructor method using dimensions.
|
inlineprotected |
Check if provided arguments are within array bounds.
|
inlinestaticprotected |
Helper function to static check operator input arguments.
|
inlinestaticprotected |
Helper function to static check sub-function input arguments.
|
inlineprotected |
Helper function to compute value offset.
| [in] | indices | Input arguments (parameter pack) |
Copy data from const raw pointer, we suppose that data size is same as that of the array.
| [in] | data | Pointer to copy |
| [in] | n_vals | Number of values to copy. If -1, default, we use array size |
|
inline |
Copy data from const raw pointer, we suppose that data size is same as that of the array. A dispatch_context is provided, hence no implicit synchronization which should be done by the caller.
| [in] | ctx | Reference to dispatch context |
| [in] | data | Pointer to copy |
| [in] | n_vals | Number of values to copy. If -1, default, we use array size |
|
inline |
Copy data from another mdspan, we suppose that data size is same as that of the array. An assert test the sizes in debug.
| [in] | ctx | Reference to dispatch context |
| [in] | other | Reference to another mdspan object |
| [in] | n_vals | Number of values to copy. If -1, default, we use array size |
|
inline |
Copy data from raw pointer, we suppose that data size is same as that of the array. A dispatch_context is provided, hence no implicit synchronization which should be done by the caller.
| [in] | ctx | Reference to dispatch context |
| [in] | data | Pointer to copy |
| [in] | n_vals | Number of values to copy. If -1, default, we use array size |
Copy data from another mdspan, we suppose that data size is same as that of the array. An assert test the sizes in debug.
| [in] | other | Reference to another mdspan object |
| [in] | n_vals | Number of values to copy. If -1, default, we use array size |
|
inline |
Getter for data raw pointer.
|
inline |
Getter for data raw pointer with recast (casts T* to U*)
| U | : data type used to cast T* into U* |
|
inlineprotected |
Helper function to compute value offset.
| [in] | indices | Input arguments (parameter pack) |
|
inline |
Check if object is empty or not.
|
inline |
Getter for extent along a given dimension.
|
inline |
Getter for extent along a given dimension.
|
inline |
Cast operator to "T*" from this class.
|
inline |
Overloaded () operator to access the (i,j,k)-th value tuple.
| [in] | indices | Input arguments (parameter pack) |
|
inline |
Overloaded () operator to access the (i,j,k)-th value tuple.
| [in] | indices | Input arguments (parameter pack) |
|
inline |
Overloaded () operator to access the ith value (val[i]).
| [in] | i | Index of value to get |
|
inline |
Overloaded [] operator to access the ith value (val[i]).
| [in] | i | Index of value to get |
|
inline |
Overloaded () operator to access the (i,j)-th value couple.
| [in] | i | Index along first dimension |
| [in] | j | Index along second dimension |
|
inline |
Overloaded () operator to access the (i,j)-th value couple.
| [in] | i | Index along first dimension |
| [in] | j | Index along second dimension |
|
inline |
|
inline |
Overloaded [] operator to access the ith value (val[i]).
| [in] | i | Index of value to get |
|
inline |
Overloaded [] operator to access the ith value (val[i]).
| [in] | i | Index of value to get |
|
inline |
Set data pointer.
| [in] | data_ptr | new pointer |
|
inlineprotected |
Set size of N indices (variadic template)
| [in] | dims | Array of dimensions' sizes |
|
inlineprotected |
Set size of array based on dimensions.
| [in] | dims | array of sizes along dimensions |
|
inline |
Set all values of the data array to a constant value while providing a dispatch context. It is up to the call to synchronize the context after this call.
| ctx | Reference to dispatch context | |
| [in] | val | Value to set to entire data array. |
| [in] | n_vals | Number of values to copy. If -1, default, we use array size |
Set all values of the data array to a constant value.
| [in] | val | Value to set to entire data array. |
| [in] | n_vals | Number of values to copy. If -1, default, we use array size |
|
inline |
Set a subset of values of the data array to a constant value while providing a dispatch context. It is up to the call to synchronize the context after this call.
| ctx | Reference to dispatch context | |
| [in] | val | Value to set to entire data array. |
| [in] | n_elts | Number of values to set. |
| [in] | elt_ids | list of ids in the subset or null (size:n_elts) |
|
inline |
Set subset of values of the data array to a constant value.
| [in] | val | Value to set to entire data array. |
| [in] | n_elts | Number of values to set. |
| [in] | elt_ids | list of ids in the subset or null (size:n_elts) |
|
inline |
Getter for total size.
|
inline |
Get sub array based on index.
| [in] | indices | Input arguments (parameter pack) |
|
inline |
Get sub array based on index.
| [in] | indices | Input arguments (parameter pack) |
|
inline |
Getter for a subspan based on first dimension.
| [in] | indices | Input arguments (parameter pack) |
|
inline |
Update data pointer and dimensions of span.
| [in] | data_ptr | New data pointer |
| [in] | dims | New dimensions (integer types) |
|
inline |
Get span 1D view of the array, same total size.
|
inline |
Set all values of the data array to 0.
|
inline |
Set all values of the data array to 0.
| ctx | Reference to dispatch context |
|
friend |
|
friend |
Class swap operator used for assignment or move.
| [in] | first | reference to first instance to swap |
| [in] | second | reference to second instance to swap |
|
mutableprotected |
|
protected |
|
protected |
|
protected |