9.1
general documentation
mdspan< T, N, L > Class Template Reference

#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 mdspan (mdspan &&other)
 Move constructor. More...
 
CS_F_HOST_DEVICE ~mdspan ()
 Desstructor method using dimensions. More...
 
CS_F_HOST mdspanoperator= (const mdspan &other)
 Assignment operator. More...
 
CS_F_HOST mdspanoperator= (mdspan &&other)
 
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 cs_lnum_t size ()
 Getter for total size. 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)
 Getter for extent along a given dimension. More...
 
CS_F_HOST_DEVICE cs_lnum_t extent (int i) const
 Getter for extent along a given dimension. More...
 
CS_F_HOST_DEVICE T * data ()
 Getter for data raw pointer. More...
 
template<typename U >
CS_F_HOST_DEVICE U * data ()
 Getter for data raw pointer with recast (casts T* to U*) 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...
 
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_DEVICE void zero ()
 Set all values of the data array to 0. More...
 
CS_F_HOST_DEVICE void zero (cs_dispatch_context &ctx)
 Set all values of the data array to 0. More...
 
CS_F_HOST_DEVICE void copy_data (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. More...
 
CS_F_HOST_DEVICE 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_DEVICE 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_DEVICE 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_DEVICE 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_DEVICE 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...
 

Friends

template<class _T_ , int _N_, layout _L_>
class array
 
CS_F_HOST friend void swap (mdspan &first, mdspan &second)
 Class swap operator used for assignment or move. More...
 

Constructor & Destructor Documentation

◆ mdspan() [1/5]

Default constructor method leading to "empty container".

◆ mdspan() [2/5]

CS_F_HOST_DEVICE mdspan ( T *  data,
Args...  indices 
)
inline

Constructor method using only global size (works for N=1).

Parameters
[in]datadata pointer (raw)
[in]indicestotal size of data (1D)

◆ mdspan() [3/5]

CS_F_HOST_DEVICE mdspan ( T *  data,
const cs_lnum_t(&)  dims[N] 
)
inline

Constructor method using dimensions.

Parameters
[in]datadata pointer (raw)
[in]dimsarray of sizes along dimensions

◆ mdspan() [4/5]

CS_F_HOST_DEVICE mdspan ( const mdspan< T, N, L > &  other)
inline

Constructor method using copy. May be a shallow copy.

◆ mdspan() [5/5]

CS_F_HOST mdspan ( mdspan< T, N, L > &&  other)
inline

Move constructor.

Parameters
[in]otherreference to other instance

◆ ~mdspan()

CS_F_HOST_DEVICE ~mdspan ( )
inline

Desstructor method using dimensions.

Member Function Documentation

◆ copy_data() [1/6]

CS_F_HOST_DEVICE void copy_data ( const T *  data,
const cs_lnum_t  n_vals = -1 
)
inline

Copy data from const raw pointer, we suppose that data size is same as that of the array.

Parameters
[in]dataPointer to copy
[in]n_valsNumber of values to copy. If -1, default, we use array size

◆ copy_data() [2/6]

CS_F_HOST_DEVICE void copy_data ( cs_dispatch_context ctx,
const T *  data,
const cs_lnum_t  n_vals = -1 
)
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.

Parameters
[in]ctxReference to dispatch context
[in]dataPointer to copy
[in]n_valsNumber of values to copy. If -1, default, we use array size

◆ copy_data() [3/6]

CS_F_HOST_DEVICE void copy_data ( cs_dispatch_context ctx,
mdspan< T, N, L > &  other,
const cs_lnum_t  n_vals = -1 
)
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.

Parameters
[in]ctxReference to dispatch context
[in]otherReference to another mdspan object
[in]n_valsNumber of values to copy. If -1, default, we use array size

◆ copy_data() [4/6]

CS_F_HOST_DEVICE void copy_data ( cs_dispatch_context ctx,
T *  data,
const cs_lnum_t  n_vals = -1 
)
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.

Parameters
[in]ctxReference to dispatch context
[in]dataPointer to copy
[in]n_valsNumber of values to copy. If -1, default, we use array size

◆ copy_data() [5/6]

CS_F_HOST_DEVICE void copy_data ( mdspan< T, N, L > &  other,
const cs_lnum_t  n_vals = -1 
)
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.

Parameters
[in]otherReference to another mdspan object
[in]n_valsNumber of values to copy. If -1, default, we use array size

◆ copy_data() [6/6]

CS_F_HOST_DEVICE void copy_data ( T *  data,
const cs_lnum_t  n_vals = -1 
)
inline

Copy data from raw pointer, we suppose that data size is same as that of the array.

Parameters
[in]dataPointer to copy
[in]n_valsNumber of values to copy. If -1, default, we use array size

◆ data() [1/2]

CS_F_HOST_DEVICE T * data ( )
inline

Getter for data raw pointer.

Returns
raw pointer

◆ data() [2/2]

CS_F_HOST_DEVICE U * data ( )
inline

Getter for data raw pointer with recast (casts T* to U*)

Template Parameters
U: data type used to cast T* into U*
Returns
raw pointer (U*)

◆ extent() [1/2]

CS_F_HOST_DEVICE cs_lnum_t extent ( int  i)
inline

Getter for extent along a given dimension.

Returns
extent.

◆ extent() [2/2]

CS_F_HOST_DEVICE cs_lnum_t extent ( int  i) const
inline

Getter for extent along a given dimension.

Returns
extent.

◆ operator()() [1/6]

CS_F_HOST_DEVICE std::enable_if_t< cs::always_true< Args... >::value &&(N!=2) &&(N!=1), T & > operator() ( Args...  indices)
inline

Overloaded () operator to access the (i,j,k)-th value tuple.

Returns
const reference to the (i,j,k)-th value
Parameters
[in]indicesInput arguments (parameter pack)

◆ operator()() [2/6]

CS_F_HOST_DEVICE std::enable_if_t< cs::always_true< Args... >::value &&(N!=2) &&(N!=1), T & > operator() ( Args...  indices) const
inline

Overloaded () operator to access the (i,j,k)-th value tuple.

Returns
const reference to the (i,j,k)-th value
Parameters
[in]indicesInput arguments (parameter pack)

◆ operator()() [3/6]

CS_F_HOST_DEVICE std::enable_if_t< cs::always_true< Id1 >::value &&N==1, T & > operator() ( Id1  i)
inline

Overloaded () operator to access the ith value (val[i]).

Returns
raw pointer to the i-th value
Parameters
[in]iIndex of value to get

◆ operator()() [4/6]

CS_F_HOST_DEVICE std::enable_if_t< cs::always_true< Id1 >::value &&N==1, T & > operator() ( Id1  i) const
inline

Overloaded [] operator to access the ith value (val[i]).

Returns
raw pointer to the i-th value
Parameters
[in]iIndex of value to get

◆ operator()() [5/6]

CS_F_HOST_DEVICE std::enable_if_t< cs::always_true< Id1, Id2 >::value &&N==2, T & > operator() ( Id1  i,
Id2  j 
)
inline

Overloaded () operator to access the (i,j)-th value couple.

Returns
reference to the (i,j)-th value
Parameters
[in]iIndex along first dimension
[in]jIndex along second dimension

◆ operator()() [6/6]

CS_F_HOST_DEVICE std::enable_if_t< cs::always_true< Id1, Id2 >::value &&N==2, T & > operator() ( Id1  i,
Id2  j 
) const
inline

Overloaded () operator to access the (i,j)-th value couple.

Returns
const reference to the (i,j)-th value
Parameters
[in]iIndex along first dimension
[in]jIndex along second dimension

◆ operator=() [1/2]

CS_F_HOST mdspan & operator= ( const mdspan< T, N, L > &  other)
inline

Assignment operator.

◆ operator=() [2/2]

CS_F_HOST mdspan & operator= ( mdspan< T, N, L > &&  other)
inline

◆ operator[]() [1/2]

CS_F_HOST_DEVICE T & operator[] ( cs_lnum_t  i)
inline

Overloaded [] operator to access the ith value (val[i]).

Returns
raw pointer to the i-th value
Parameters
[in]iIndex of value to get

◆ operator[]() [2/2]

CS_F_HOST_DEVICE T & operator[] ( cs_lnum_t  i) const
inline

Overloaded [] operator to access the ith value (val[i]).

Returns
raw pointer to the i-th value
Parameters
[in]iIndex of value to get

◆ set_to_val() [1/2]

CS_F_HOST void set_to_val ( cs_dispatch_context ctx,
val,
const cs_lnum_t  n_vals = -1 
)
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.

Parameters
ctxReference to dispatch context
[in]valValue to set to entire data array.
[in]n_valsNumber of values to copy. If -1, default, we use array size

◆ set_to_val() [2/2]

CS_F_HOST void set_to_val ( val,
const cs_lnum_t  n_vals = -1 
)
inline

Set all values of the data array to a constant value.

Parameters
[in]valValue to set to entire data array.
[in]n_valsNumber of values to copy. If -1, default, we use array size

◆ set_to_val_on_subset() [1/2]

CS_F_HOST void set_to_val_on_subset ( cs_dispatch_context ctx,
val,
const cs_lnum_t  n_elts,
const cs_lnum_t  elt_ids[] 
)
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.

Parameters
ctxReference to dispatch context
[in]valValue to set to entire data array.
[in]n_eltsNumber of values to set.
[in]elt_idslist of ids in the subset or null (size:n_elts)

◆ set_to_val_on_subset() [2/2]

CS_F_HOST void set_to_val_on_subset ( val,
const cs_lnum_t  n_elts,
const cs_lnum_t  elt_ids[] 
)
inline

Set subset of values of the data array to a constant value.

Parameters
[in]valValue to set to entire data array.
[in]n_eltsNumber of values to set.
[in]elt_idslist of ids in the subset or null (size:n_elts)

◆ size() [1/2]

CS_F_HOST_DEVICE cs_lnum_t size ( )
inline

Getter for total size.

Returns
total size.

◆ size() [2/2]

CS_F_HOST_DEVICE cs_lnum_t size ( ) const
inline

Getter for total size.

Returns
total size.

◆ sub_array()

CS_F_HOST_DEVICE T * sub_array ( Args...  indices)
inline

Get sub array based on index.

Parameters
[in]indicesInput arguments (parameter pack)

◆ sub_view()

CS_F_HOST_DEVICE mdspan< T, N-sizeof...(Args), L > sub_view ( Args...  indices)
inline

Getter for a subspan based on first dimension.

Returns
pointer
Parameters
[in]indicesInput arguments (parameter pack)

◆ zero() [1/2]

CS_F_HOST_DEVICE void zero ( )
inline

Set all values of the data array to 0.

◆ zero() [2/2]

CS_F_HOST_DEVICE void zero ( cs_dispatch_context ctx)
inline

Set all values of the data array to 0.

Parameters
ctxReference to dispatch context

Friends And Related Function Documentation

◆ array

friend class array
friend

◆ swap

CS_F_HOST friend void swap ( mdspan< T, N, L > &  first,
mdspan< T, N, L > &  second 
)
friend

Class swap operator used for assignment or move.

Parameters
[in]firstreference to first instance to swap
[in]secondreference to second instance to swap

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