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>
111 return static_cast<size_t> (1);
138 static Kokkos::View<value_type*, D>
141 const std::string& label =
"")
143 typedef Kokkos::View<value_type*, D> view_type;
144 typedef typename view_type::size_type size_type;
152 return view_type (label, static_cast<size_type> (numEnt), numVals);
170 const input_array_type& inBuf,
173 #ifdef HAVE_TPETRA_DEBUG 174 TEUCHOS_TEST_FOR_EXCEPTION(
175 static_cast<size_t> (inBuf.dimension_0 ()) < numEnt,
176 std::invalid_argument,
"PackTraits::packArray: inBuf.dimension_0() = " 177 << inBuf.dimension_0 () <<
" < numEnt = " << numEnt <<
".");
178 #endif // HAVE_TPETRA_DEBUG 195 #ifdef HAVE_TPETRA_DEBUG 196 TEUCHOS_TEST_FOR_EXCEPTION(
197 static_cast<size_t> (outBuf.dimension_0 ()) < numBytes,
198 std::invalid_argument,
"PackTraits::packArray: outBuf.dimension_0() = " 199 << outBuf.dimension_0 () <<
" < numBytes = " << numBytes <<
".");
200 #endif // HAVE_TPETRA_DEBUG 205 memcpy (outBuf.ptr_on_device (), inBuf.ptr_on_device (), numBytes);
226 const input_buffer_type& inBuf,
229 #ifdef HAVE_TPETRA_DEBUG 230 TEUCHOS_TEST_FOR_EXCEPTION(
231 static_cast<size_t> (outBuf.size ()) < numEnt, std::invalid_argument,
232 "PackTraits::unpackArray: outBuf.size() = " << outBuf.size ()
233 <<
" < numEnt = " << numEnt <<
".");
234 #endif // HAVE_TPETRA_DEBUG 237 return static_cast<size_t> (0);
252 #ifdef HAVE_TPETRA_DEBUG 253 TEUCHOS_TEST_FOR_EXCEPTION(
254 static_cast<size_t> (inBuf.dimension_0 ()) < numBytes,
255 std::invalid_argument,
"PackTraits::unpackArray: inBuf.dimension_0() = " 256 << inBuf.dimension_0 () <<
" < numBytes = " << numBytes <<
".");
257 #endif // HAVE_TPETRA_DEBUG 262 memcpy (outBuf.ptr_on_device (), inBuf.ptr_on_device (), numBytes);
317 memcpy (outBuf.ptr_on_device (), &inVal, numBytes);
344 memcpy (&outVal, inBuf.ptr_on_device (), numBytes);
352 #endif // TPETRA_DETAILS_PACKTRAITS_HPP Namespace Tpetra contains the class and methods constituting the Tpetra library.
Traits class for packing / unpacking data of type T, using Kokkos data structures that live in the gi...
static size_t packValue(const output_buffer_type &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.
Implementation details of Tpetra.
static size_t packArray(const output_buffer_type &outBuf, const input_array_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...
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 size_t unpackArray(const output_array_type &outBuf, const input_buffer_type &inBuf, const size_t numEnt)
Unpack numEnt value_type entries from the given input buffer of bytes, to the given output buffer of ...
static size_t packValueCount(const T &)
Number of bytes required to pack or unpack the given value of type value_type.
Kokkos::View< value_type *, D, Kokkos::MemoryUnmanaged > output_array_type
The type of an output array of value_type.
static size_t unpackValue(T &outVal, const input_buffer_type &inBuf)
Unpack the given value from the given output buffer.
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 size_t numValuesPerScalar(const value_type &)
Given an instance of value_type allocated with the right size, return the "number of values" that mak...
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 ...