42 #ifndef TPETRA_DETAILS_PACKTRAITS_HPP
43 #define TPETRA_DETAILS_PACKTRAITS_HPP
51 #include "Tpetra_ConfigDefs.hpp"
52 #include "Kokkos_Core.hpp"
62 template<
class T,
class D>
108 KOKKOS_INLINE_FUNCTION
113 return static_cast<size_t> (1);
140 static Kokkos::View<value_type*, D>
143 const std::string& label =
"")
145 typedef Kokkos::View<value_type*, D> view_type;
146 typedef typename view_type::size_type size_type;
157 if ( std::is_same< typename view_type::traits::specialize, void >::value ) {
158 return view_type (label, static_cast<size_type> (numEnt));
161 return view_type (label, static_cast<size_type> (numEnt), numVals);
179 KOKKOS_INLINE_FUNCTION
180 static Kokkos::pair<int, size_t>
187 typedef Kokkos::pair<int, size_t> pair_type;
190 return pair_type (errorCode, numBytes);
207 memcpy (outBuf, inBuf, numBytes);
208 return pair_type (errorCode, numBytes);
227 KOKKOS_INLINE_FUNCTION
228 static Kokkos::pair<int, size_t>
235 typedef Kokkos::pair<int, size_t> pair_type;
238 return pair_type (errorCode, numBytes);
257 memcpy (outBuf, inBuf, numBytes);
258 return pair_type (errorCode, numBytes);
285 KOKKOS_INLINE_FUNCTION
301 KOKKOS_INLINE_FUNCTION
313 memcpy (outBuf, &inVal, numBytes);
328 KOKKOS_INLINE_FUNCTION
331 const size_t outBufIndex,
338 const size_t offset = outBufIndex * numBytes;
342 memcpy (outBuf + offset, &inVal, numBytes);
358 KOKKOS_INLINE_FUNCTION
369 memcpy (&outVal, inBuf, numBytes);
377 #endif // TPETRA_DETAILS_PACKTRAITS_HPP
static KOKKOS_INLINE_FUNCTION size_t packValueCount(const T &)
Number of bytes required to pack or unpack the given value of type value_type.
Traits class for packing / unpacking data of type T, using Kokkos data structures that live in the gi...
static KOKKOS_INLINE_FUNCTION Kokkos::pair< int, size_t > packArray(char outBuf[], const value_type inBuf[], const size_t numEnt)
Pack the first numEnt entries of the given input buffer of value_type, into the output buffer of byte...
static KOKKOS_INLINE_FUNCTION size_t packValue(char outBuf[], const T &inVal)
Pack the given value of type value_type into the given output buffer of bytes (char).
Kokkos::View< char *, D, Kokkos::MemoryUnmanaged > output_buffer_type
The type of an output buffer of bytes.
static KOKKOS_INLINE_FUNCTION size_t unpackValue(T &outVal, const char inBuf[])
Unpack the given value from the given output buffer.
static KOKKOS_INLINE_FUNCTION Kokkos::pair< int, size_t > unpackArray(value_type outBuf[], const char inBuf[], const size_t numEnt)
Unpack numEnt value_type entries from the given input buffer of bytes, to the given output buffer of ...
Kokkos::View< const value_type *, D, Kokkos::MemoryUnmanaged > input_array_type
The type of an input array of value_type.
Kokkos::View< const char *, D, Kokkos::MemoryUnmanaged > input_buffer_type
The type of an input buffer of bytes.
static KOKKOS_INLINE_FUNCTION size_t packValue(char outBuf[], const size_t outBufIndex, const T &inVal)
Pack the given value of type value_type into the given output buffer of bytes (char).
static KOKKOS_INLINE_FUNCTION size_t numValuesPerScalar(const value_type &)
Given an instance of value_type allocated with the right size, return the "number of values" that mak...
Kokkos::View< value_type *, D, Kokkos::MemoryUnmanaged > output_array_type
The type of an output array of value_type.
static const bool compileTimeSize
Whether the number of bytes required to pack one instance of value_type is fixed at compile time...
T value_type
The type of data to pack or unpack.
static Kokkos::View< value_type *, D > allocateArray(const value_type &x, const size_t numEnt, const std::string &label="")
Given an instance of value_type allocated with the right size, allocate and return a one-dimensional ...