Kokkos Core Kernels Package  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Public Types | Public Member Functions | Public Attributes | List of all members
Kokkos::pair< T1, T2 > Struct Template Reference

Replacement for std::pair that works on CUDA devices. More...

#include <Kokkos_Pair.hpp>

Public Types

typedef T1 first_type
 The first template parameter of this class. More...
 
typedef T2 second_type
 The second template parameter of this class. More...
 

Public Member Functions

KOKKOS_DEFAULTED_FUNCTION constexpr pair ()=default
 Default constructor. More...
 
KOKKOS_FORCEINLINE_FUNCTION
constexpr 
pair (first_type const &f, second_type const &s)
 Constructor that takes both elements of the pair. More...
 
template<class U , class V >
KOKKOS_FORCEINLINE_FUNCTION
constexpr 
pair (const pair< U, V > &p)
 Copy constructor. More...
 
template<class U , class V >
KOKKOS_FORCEINLINE_FUNCTION
constexpr 
pair (const volatile pair< U, V > &p)
 Copy constructor. More...
 
template<class U , class V >
KOKKOS_FORCEINLINE_FUNCTION
pair< T1, T2 > & 
operator= (const pair< U, V > &p)
 Assignment operator. More...
 
template<class U , class V >
KOKKOS_FORCEINLINE_FUNCTION void operator= (const volatile pair< U, V > &p) volatile
 Assignment operator, for volatile *this. More...
 
std::pair< T1, T2 > to_std_pair () const
 Return the std::pair version of this object. More...
 

Public Attributes

first_type first
 The first element of the pair. More...
 
second_type second
 The second element of the pair. More...
 

Detailed Description

template<class T1, class T2>
struct Kokkos::pair< T1, T2 >

Replacement for std::pair that works on CUDA devices.

The instance methods of std::pair, including its constructors, are not marked as __device__ functions. Thus, they cannot be called on a CUDA device, such as an NVIDIA GPU. This struct implements the same interface as std::pair, but can be used on a CUDA device as well as on the host.

Definition at line 65 of file Kokkos_Pair.hpp.

Member Typedef Documentation

template<class T1, class T2>
typedef T1 Kokkos::pair< T1, T2 >::first_type

The first template parameter of this class.

Definition at line 67 of file Kokkos_Pair.hpp.

template<class T1, class T2>
typedef T2 Kokkos::pair< T1, T2 >::second_type

The second template parameter of this class.

Definition at line 69 of file Kokkos_Pair.hpp.

Constructor & Destructor Documentation

template<class T1, class T2>
KOKKOS_DEFAULTED_FUNCTION constexpr Kokkos::pair< T1, T2 >::pair ( )
default

Default constructor.

This calls the default constructors of T1 and T2. It won't compile if those default constructors are not defined and public.

template<class T1, class T2>
KOKKOS_FORCEINLINE_FUNCTION constexpr Kokkos::pair< T1, T2 >::pair ( first_type const &  f,
second_type const &  s 
)
inline

Constructor that takes both elements of the pair.

This calls the copy constructors of T1 and T2. It won't compile if those copy constructors are not defined and public.

Definition at line 87 of file Kokkos_Pair.hpp.

template<class T1, class T2>
template<class U , class V >
KOKKOS_FORCEINLINE_FUNCTION constexpr Kokkos::pair< T1, T2 >::pair ( const pair< U, V > &  p)
inline

Copy constructor.

This calls the copy constructors of T1 and T2. It won't compile if those copy constructors are not defined and public.

Definition at line 96 of file Kokkos_Pair.hpp.

template<class T1, class T2>
template<class U , class V >
KOKKOS_FORCEINLINE_FUNCTION constexpr Kokkos::pair< T1, T2 >::pair ( const volatile pair< U, V > &  p)
inline

Copy constructor.

This calls the copy constructors of T1 and T2. It won't compile if those copy constructors are not defined and public.

Definition at line 104 of file Kokkos_Pair.hpp.

Member Function Documentation

template<class T1, class T2>
template<class U , class V >
KOKKOS_FORCEINLINE_FUNCTION pair<T1, T2>& Kokkos::pair< T1, T2 >::operator= ( const pair< U, V > &  p)
inline

Assignment operator.

This calls the assignment operators of T1 and T2. It won't compile if the assignment operators are not defined and public.

Definition at line 112 of file Kokkos_Pair.hpp.

template<class T1, class T2>
template<class U , class V >
KOKKOS_FORCEINLINE_FUNCTION void Kokkos::pair< T1, T2 >::operator= ( const volatile pair< U, V > &  p) volatile
inline

Assignment operator, for volatile *this.

Parameters
p[in] Input; right-hand side of the assignment.

This calls the assignment operators of T1 and T2. It will not compile if the assignment operators are not defined and public.

This operator returns void instead of volatile pair<T1, T2>& . See Kokkos Issue #177 for the explanation. In practice, this means that you should not chain assignments with volatile lvalues.

Definition at line 130 of file Kokkos_Pair.hpp.

template<class T1, class T2>
std::pair<T1, T2> Kokkos::pair< T1, T2 >::to_std_pair ( ) const
inline

Return the std::pair version of this object.

This is not a device function; you may not call it on a CUDA device. It is meant to be called on the host, if the user wants an std::pair instead of a Kokkos::pair.

Note
This is not a conversion operator, since defining a conversion operator made the relational operators have ambiguous definitions.

Definition at line 151 of file Kokkos_Pair.hpp.

Member Data Documentation

template<class T1, class T2>
first_type Kokkos::pair< T1, T2 >::first

The first element of the pair.

Definition at line 72 of file Kokkos_Pair.hpp.

template<class T1, class T2>
second_type Kokkos::pair< T1, T2 >::second

The second element of the pair.

Definition at line 74 of file Kokkos_Pair.hpp.


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