Tpetra parallel linear algebra
Version of the Day
|
Traits class for packing / unpacking data of type T
, using Kokkos data structures that live in the given space D
.
More...
#include <Tpetra_Details_PackTraits.hpp>
Public Types | |
typedef T | value_type |
The type of data to pack or unpack. More... | |
typedef Kokkos::View< const char *, D, Kokkos::MemoryUnmanaged > | input_buffer_type |
The type of an input buffer of bytes. More... | |
typedef Kokkos::View< char *, D, Kokkos::MemoryUnmanaged > | output_buffer_type |
The type of an output buffer of bytes. More... | |
typedef Kokkos::View< const value_type *, D, Kokkos::MemoryUnmanaged > | input_array_type |
The type of an input array of value_type . More... | |
typedef Kokkos::View < value_type *, D, Kokkos::MemoryUnmanaged > | output_array_type |
The type of an output array of value_type . More... | |
Static Public Member Functions | |
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 make up that value_type instance. More... | |
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 array of value_type . More... | |
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 bytes. More... | |
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 value_type . More... | |
static KOKKOS_INLINE_FUNCTION size_t | packValueCount (const T &) |
Number of bytes required to pack or unpack the given value of type value_type . More... | |
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 ). More... | |
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 ). More... | |
static KOKKOS_INLINE_FUNCTION size_t | unpackValue (T &outVal, const char inBuf[]) |
Unpack the given value from the given output buffer. More... | |
Static Public Attributes | |
static const bool | compileTimeSize = true |
Whether the number of bytes required to pack one instance of value_type is fixed at compile time. More... | |
Traits class for packing / unpacking data of type T
, using Kokkos data structures that live in the given space D
.
T | The type of the data to pack / unpack. |
D | The Kokkos "device" type; where the data live. |
Definition at line 63 of file Tpetra_Details_PackTraits.hpp.
typedef T Tpetra::Details::PackTraits< T, D >::value_type |
The type of data to pack or unpack.
Definition at line 65 of file Tpetra_Details_PackTraits.hpp.
typedef Kokkos::View<const char*, D, Kokkos::MemoryUnmanaged> Tpetra::Details::PackTraits< T, D >::input_buffer_type |
The type of an input buffer of bytes.
Definition at line 83 of file Tpetra_Details_PackTraits.hpp.
typedef Kokkos::View<char*, D, Kokkos::MemoryUnmanaged> Tpetra::Details::PackTraits< T, D >::output_buffer_type |
The type of an output buffer of bytes.
Definition at line 86 of file Tpetra_Details_PackTraits.hpp.
typedef Kokkos::View<const value_type*, D, Kokkos::MemoryUnmanaged> Tpetra::Details::PackTraits< T, D >::input_array_type |
The type of an input array of value_type
.
Definition at line 89 of file Tpetra_Details_PackTraits.hpp.
typedef Kokkos::View<value_type*, D, Kokkos::MemoryUnmanaged> Tpetra::Details::PackTraits< T, D >::output_array_type |
The type of an output array of value_type
.
Definition at line 92 of file Tpetra_Details_PackTraits.hpp.
|
inlinestatic |
Given an instance of value_type
allocated with the right size, return the "number of values" that make up that value_type
instance.
This function helps the pack and unpack code that uses PackTraits correctly handle types that have a size specified at run time. PackTraits still assumes that all instances of value_type
in an input or output array have the same run-time size.
x | [in] Instance of value_type with the correct size (possibly determined at run time). |
x
. Definition at line 110 of file Tpetra_Details_PackTraits.hpp.
|
inlinestatic |
Given an instance of value_type
allocated with the right size, allocate and return a one-dimensional array of value_type
.
This function lets the pack and unpack code that uses PackTraits correctly handle types that have a size specified at run time. In particular, it's helpful if that code needs to allocate temporary buffers of value_type
. PackTraits still assumes that all instances of value_type
in an input or output array have the same run-time size.
x | [in] Instance of value_type with the correct (run-time) size. |
numEnt | [in] Number of entries in the returned array. |
label | [in] Optional string label of the returned Kokkos::View. (Kokkos::View's constructor takes a string label, which Kokkos uses for debugging output.) |
value_type
, all instances of which have the same (run-time) size as x
.Definition at line 141 of file Tpetra_Details_PackTraits.hpp.
|
inlinestatic |
Pack the first numEnt entries of the given input buffer of value_type
, into the output buffer of bytes.
inBuf
must have the same (run-time) size.outBuf | [out] Output buffer of bytes (char ). Must have enough space to hold the packed version of the first numEnt entries of inBuf . |
inBuf | [in] Input buffer of value_type . Must have at least numEnt entries. |
numEnt | [in] Number of entries to pack. |
inBuf
into outBuf
, Definition at line 181 of file Tpetra_Details_PackTraits.hpp.
|
inlinestatic |
Unpack numEnt
value_type
entries from the given input buffer of bytes, to the given output buffer of value_type
.
outBuf
must have the same (run-time) size, and that size must be the same as that of the packed data that live in inBuf
.outBuf | [in] Output buffer of value_type . Must have at least numEnt entries. |
inBuf | [out] Input buffer of bytes (char ). |
numEnt | [in] Number of value_type entries to unpack. |
inBuf
). Definition at line 229 of file Tpetra_Details_PackTraits.hpp.
|
inlinestatic |
Number of bytes required to pack or unpack the given value of type value_type
.
inVal | [in] The input value (see discussion below). |
inVal
.Currently, this function returns the exact amount of bytes, not an upper bound. Thus, one can use this function to predict offsets. That assumes packing without padding for (e.g.,) alignment to something bigger than sizeof(char) = 1
. At some point, we may need to extend this to be an upper bound, rather than an exact value. Compare to MPI_PACK_SIZE, which only claims to offer an upper bound. In that case, one may not use this function to predict offsets for unpacking; like MPI_UNPACK, one would need to start at the beginning of the packed array and unpack sequentially.
We currently assume that all objects of type value_type
require the same number of bytes. Nevertheless, we require an instance of value_type
, in case we want to relax this assumption in the future. That's why the brief description of this function says "the given value of type \c value_type."
Definition at line 287 of file Tpetra_Details_PackTraits.hpp.
|
inlinestatic |
Pack the given value of type value_type
into the given output buffer of bytes (char
).
outBuf
has at least packValueCount(inVal)
entries.outBuf | [out] Output buffer of bytes. |
inVal | [in] Input value to pack. |
inVal
. Definition at line 303 of file Tpetra_Details_PackTraits.hpp.
|
inlinestatic |
Pack the given value of type value_type
into the given output buffer of bytes (char
).
outBuf
has at least packValueCount(inVal)
entries.outBuf | [out] Output buffer of bytes. |
outBufIndex | [in] Index into output buffer (multiplied by the number of bytes needed to pack inVal). |
inVal | [in] Input value to pack. |
inVal
. Definition at line 330 of file Tpetra_Details_PackTraits.hpp.
|
inlinestatic |
Unpack the given value from the given output buffer.
outVal | [in/out] On output: The unpacked value. |
inBuf | [in] The buffer of packed data from which to unpack the output value. |
inBuf
.We assume that the number of bytes required to pack outVal
does not depend on the unpacked data. That is, outVal
on input requires the same number of packed bytes as it should on output.
Definition at line 360 of file Tpetra_Details_PackTraits.hpp.
|
static |
Whether the number of bytes required to pack one instance of value_type
is fixed at compile time.
This is true for "plain old data" (POD) types like float
, double
, and int
. It is also true of structs or classes of POD, like Kokkos::complex. The Sacado and Stokhos packages may have classes for which this is false. If false, then the size of an instance of value_type
may have been determined at run time, for example in its constructor.
Whether or not this is true or false, implementations of PackTraits may assume that all instances of value_type
which the implementation encounters have the same size.
Definition at line 80 of file Tpetra_Details_PackTraits.hpp.