TECA
The Toolkit for Extreme Climate Analysis
teca_variant_array_util Namespace Reference

some functions helping us manipulate teca_variant_array More...

Functions

void synchronize_stream ()
 synchronize the default stream. More...
 
template<typename... array_t>
void sync_host_access_any (const array_t &... arrays)
 
template<typename TT , typename... PP>
auto va_static_cast (PP &&... args)
 
template<typename TT , typename... PP>
auto va_dynamic_cast (PP &&... args)
 
template<typename TT >
void assert_type ()
 terminates recursion More...
 
template<typename TT , typename... PP>
void assert_type (const const_p_teca_variant_array &va, PP &&... args)
 
template<typename TT >
auto get_host_accessible ()
 terminates recursion More...
 
template<typename TT , typename... PP>
auto get_host_accessible (const std::shared_ptr< const TT > &va, PP &&... args)
 
template<typename TT , typename... V>
auto get_host_accessible (const std::shared_ptr< TT > &va, V &&... args)
 
template<typename TT , typename... PP>
auto get_host_accessible (const const_p_teca_variant_array &va, PP &&... args)
 
template<typename TT , typename... V>
auto get_host_accessible (const p_teca_variant_array &va, V &&... args)
 
template<typename TT >
auto get_cuda_accessible ()
 terminates recursion More...
 
template<typename TT , typename... PP>
auto get_cuda_accessible (const const_p_teca_variant_array &va, PP &&... args)
 
template<typename TT , typename... V>
auto get_cuda_accessible (const p_teca_variant_array &va, V &&... args)
 
template<typename TT , typename... V>
auto data (V &&... args)
 
template<typename TT >
auto New (size_t n_elem, teca_variant_array::allocator alloc=teca_variant_array::allocator::malloc)
 
template<typename TT , typename NT = typename TT::element_type>
auto New (size_t n_elem, NT init_val, teca_variant_array::allocator alloc=teca_variant_array::allocator::malloc)
 

Detailed Description

some functions helping us manipulate teca_variant_array

Function Documentation

◆ assert_type() [1/2]

template<typename TT >
void teca_variant_array_util::assert_type ( )

terminates recursion

◆ assert_type() [2/2]

template<typename TT , typename... PP>
void teca_variant_array_util::assert_type ( const const_p_teca_variant_array va,
PP &&...  args 
)

Check that a number of p_teca_variant_array are teca_variant_array_impl<NT> instances. This will terminate execution if the check fails. Unlike asssert this check is always applied.

Template Parameters
TTteca_variant_array_impl<NT>
PPa parameter pack
Parameters
vaa p_teca_variant_array instance
argssome number of p_teca_variant_array instances.

◆ data()

template<typename TT , typename... V>
auto teca_variant_array_util::data ( V &&...  args)

Calls teca_varaint_array_impl<NT>::data on a number of p_teca_variant_array instances. The instances are first static_cast to teca_variant_array_impl<NT>*. One should only use this method when one is certain that this static_cast is appropriate. See va_assert_type for one way to validate that the types are as expected.

Template Parameters
TTteca_variant_array_impl<NT>
PPa paramater pack
Parameters
argsany number of p_teca_variant_array instances
Returns
a tuple of NT* one for each p_teca_variant_array passed in.

◆ get_cuda_accessible() [1/3]

template<typename TT >
auto teca_variant_array_util::get_cuda_accessible ( )

terminates recursion

◆ get_cuda_accessible() [2/3]

template<typename TT , typename... PP>
auto teca_variant_array_util::get_cuda_accessible ( const const_p_teca_variant_array va,
PP &&...  args 
)

Calls teca_varaint_array_impl<NT>::get_cuda_accessible on a number of p_teca_variant_array instances. The instances are first static_cast to teca_variant_array_impl<NT>*. One should only use this method when one is certain that this static_cast is appropriate. See va_assert_type for one way to validate that the types are as expected.

Template Parameters
TTteca_variant_array_impl<NT>
PPa paramater pack
Parameters
vaa p_teca_variant_array instance
argsany number of p_teca_variant_array instances
Returns
a tuple of std::shared_ptr<NT> and NT* one for each p_teca_variant_array passed in.

◆ get_cuda_accessible() [3/3]

template<typename TT , typename... V>
auto teca_variant_array_util::get_cuda_accessible ( const p_teca_variant_array va,
V &&...  args 
)

Calls teca_varaint_array_impl<NT>::get_cuda_accessible on a number of p_teca_variant_array instances. The instances are first static_cast to teca_variant_array_impl<NT>*. One should only use this method when one is certain that this static_cast is appropriate. See va_assert_type for one way to validate that the types are as expected.

Template Parameters
TTteca_variant_array_impl<NT>
PPa paramater pack
Parameters
vaa const_p_teca_variant_array instance
argsany number of p_teca_variant_array instances
Returns
a tuple of std::shared_ptr<const NT> and const NT* one for each p_teca_variant_array passed in.

◆ get_host_accessible() [1/5]

template<typename TT >
auto teca_variant_array_util::get_host_accessible ( )

terminates recursion

◆ get_host_accessible() [2/5]

template<typename TT , typename... PP>
auto teca_variant_array_util::get_host_accessible ( const const_p_teca_variant_array va,
PP &&...  args 
)

Calls teca_varaint_array_impl<NT>::get_host_accessible on a number of p_teca_variant_array instances. The instances are first static_cast to teca_variant_array_impl<NT>*. One should only use this method when one is certain that this static_cast is appropriate. See va_assert_type for one way to validate that the types are as expected.

Template Parameters
TTteca_variant_array_impl<NT>
PPa paramater pack
Parameters
vaa p_teca_variant_array instance
argsany number of p_teca_variant_array instances
Returns
a tuple of std::shared_ptr<NT> and NT* one for each p_teca_variant_array passed in.

◆ get_host_accessible() [3/5]

template<typename TT , typename... V>
auto teca_variant_array_util::get_host_accessible ( const p_teca_variant_array va,
V &&...  args 
)

Calls teca_varaint_array_impl<NT>::get_host_accessible on a number of p_teca_variant_array instances. The instances are first static_cast to teca_variant_array_impl<NT>*. One should only use this method when one is certain that this static_cast is appropriate. See va_assert_type for one way to validate that the types are as expected.

Template Parameters
TTteca_variant_array_impl<NT>
PPa paramater pack
Parameters
vaa const_p_teca_variant_array instance
argsany number of p_teca_variant_array instances
Returns
a tuple of std::shared_ptr<const NT> and const NT* one for each p_teca_variant_array passed in.

◆ get_host_accessible() [4/5]

template<typename TT , typename... PP>
auto teca_variant_array_util::get_host_accessible ( const std::shared_ptr< const TT > &  va,
PP &&...  args 
)

Calls teca_varaint_array_impl<NT>::get_host_accessible on a number of p_teca_variant_array instances. The instances are first static_cast to teca_variant_array_impl<NT>*. One should only use this method when one is certain that this static_cast is appropriate. See va_assert_type for one way to validate that the types are as expected.

Template Parameters
TTteca_variant_array_impl<NT>
PPa paramater pack
Parameters
vaa p_teca_variant_array instance
argsany number of p_teca_variant_array instances
Returns
a tuple of std::shared_ptr<NT> and NT* one for each p_teca_variant_array passed in.

◆ get_host_accessible() [5/5]

template<typename TT , typename... V>
auto teca_variant_array_util::get_host_accessible ( const std::shared_ptr< TT > &  va,
V &&...  args 
)

Calls teca_varaint_array_impl<NT>::get_host_accessible on a number of p_teca_variant_array instances. The instances are first static_cast to teca_variant_array_impl<NT>*. One should only use this method when one is certain that this static_cast is appropriate. See va_assert_type for one way to validate that the types are as expected.

Template Parameters
TTteca_variant_array_impl<NT>
PPa paramater pack
Parameters
vaa const_p_teca_variant_array instance
argsany number of p_teca_variant_array instances
Returns
a tuple of std::shared_ptr<const NT> and const NT* one for each p_teca_variant_array passed in.

◆ New() [1/2]

template<typename TT , typename NT = typename TT::element_type>
auto teca_variant_array_util::New ( size_t  n_elem,
NT  init_val,
teca_variant_array::allocator  alloc = teca_variant_array::allocator::malloc 
)

Allocates a teca_variant_array_impl<NT> instance and returns the newly allocated array and a pointer to it's memory.

Template Parameters
TTteca_variant_array_impl<NT>
Parameters
n_elemthe size of the array
init_vala value to initialize the contents of the array to
allocthe allocator to use
Returns
a tuple of p_teca_variant_array_impl<NT> and NT*

◆ New() [2/2]

template<typename TT >
auto teca_variant_array_util::New ( size_t  n_elem,
teca_variant_array::allocator  alloc = teca_variant_array::allocator::malloc 
)

Allocates a teca_variant_array_impl<NT> instance and returns the newly allocated array and a pointer to it's memory.

Template Parameters
TTteca_variant_array_impl<NT>
Parameters
n_elemthe size of the array
allocthe allocator to use
Returns
a tuple of p_teca_variant_array_impl<NT> and NT*

◆ sync_host_access_any()

template<typename... array_t>
void teca_variant_array_util::sync_host_access_any ( const array_t &...  arrays)

synchronize the default stream once if any of the passed arrays are not accessible on the host. this should be done after all get_host_accessible are issued and before the data is accessed.

◆ synchronize_stream()

void teca_variant_array_util::synchronize_stream ( )
inline

synchronize the default stream.

◆ va_dynamic_cast()

template<typename TT , typename... PP>
auto teca_variant_array_util::va_dynamic_cast ( PP &&...  args)

dynamic_cast a number of p_teca_variant_array into their derived type teca_variant_array_impl<NT>*. Can be used with p_const_teca_variant_array as well.

Template Parameters
TTteca_variant_array_impl<NT>
PPa parameter pack
Parameters
argssome number of p_teca_variant_array instances.
Returns
a std::tuple of teca_variant_array_impl<NT>* one for each of args in the same order.

◆ va_static_cast()

template<typename TT , typename... PP>
auto teca_variant_array_util::va_static_cast ( PP &&...  args)

static_cast a number of p_teca_variant_array into their derived type teca_variant_array_impl<NT>*. Can be used with p_const_teca_variant_array as well.

Template Parameters
TTteca_variant_array_impl<NT>
PPa parameter pack
Parameters
argssome number of p_teca_variant_array instances.
Returns
a std::tuple of teca_variant_array_impl<NT>* one for each of args in the same order.