TIMPI
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | List of all members
libMesh::Parallel::Packing< T, Enable > Class Template Reference

Define data types and (un)serialization functions for use when encoding a potentially-variable-size object of type T. More...

#include <packing.h>

Public Member Functions

template<typename Context >
unsigned int packable_size (const std::pair< T1, T2 > &pr, const Context *ctx)
 
template<typename OutputIter , typename Context >
void pack (const std::pair< T1, T2 > &pr, OutputIter data_out, const Context *ctx)
 
template<typename BufferIter , typename Context >
std::pair< T1, T2 > unpack (BufferIter in, Context *ctx)
 
template<typename Context >
unsigned int packable_size (const std::tuple< T, Types... > &tup, const Context *ctx)
 
template<typename OutputIter , typename Context >
void pack (const std::tuple< T, Types... > &tup, OutputIter data_out, const Context *ctx)
 
template<typename BufferIter , typename Context >
std::tuple< T, Types... > unpack (BufferIter in, Context *ctx)
 
template<typename Context >
unsigned int packable_size (const std::array< T, N > &a, const Context *ctx)
 
template<typename OutputIter , typename Context >
void pack (const std::array< T, N > &a, OutputIter data_out, const Context *ctx)
 
template<typename BufferIter , typename Context >
std::array< T, N > unpack (BufferIter in, Context *ctx)
 

Static Public Member Functions

template<typename OutputIter , typename Context >
static void pack (const T &object, OutputIter data_out, const Context *context)
 
template<typename Context >
static unsigned int packable_size (const T &object, const Context *context)
 
template<typename BufferIter >
static unsigned int packed_size (BufferIter iter)
 
template<typename BufferIter , typename Context >
static T unpack (BufferIter in, Context *ctx)
 

Detailed Description

template<typename T, typename Enable>
class libMesh::Parallel::Packing< T, Enable >

Define data types and (un)serialization functions for use when encoding a potentially-variable-size object of type T.

Users will need to specialize this class for their particular data types.

Definition at line 60 of file packing.h.

Member Function Documentation

◆ pack() [1/4]

template<typename T , typename Enable >
template<typename OutputIter , typename Context >
void libMesh::Parallel::Packing< T, Enable >::pack ( const std::array< T, N > &  a,
OutputIter  data_out,
const Context *  ctx 
)

Definition at line 738 of file packing.h.

740{
741 unsigned int size = packable_size(a, ctx);
742
743 // First write out info about the buffer size
744 put_packed_len<buffer_type>(size, data_out);
745
746 // Now pack the data
747 for (const auto & entry : a)
748 Mixed::pack_comp(entry, data_out, ctx);
749}
static unsigned int packable_size(const T &object, const Context *context)

◆ pack() [2/4]

template<typename T , typename Enable >
template<typename OutputIter , typename Context >
void libMesh::Parallel::Packing< T, Enable >::pack ( const std::pair< T1, T2 > &  pr,
OutputIter  data_out,
const Context *  ctx 
)

Definition at line 443 of file packing.h.

445{
446 unsigned int size = packable_size(pr, ctx);
447
448 // First write out info about the buffer size
449 put_packed_len<buffer_type>(size, data_out);
450
451 // Now pack the data
452 Mixed::pack_comp(pr.first, data_out, ctx);
453
454 // TIMPI uses a back_inserter for `pack_range` so we don't (and can't)
455 // actually increment the iterator with operator+=. operator++ is a no-op
456 //
457 // data_out += packable_size_comp(pr.first, ctx);
458
459 Mixed::pack_comp(pr.second, data_out, ctx);
460}

◆ pack() [3/4]

template<typename T , typename Enable >
template<typename OutputIter , typename Context >
void libMesh::Parallel::Packing< T, Enable >::pack ( const std::tuple< T, Types... > &  tup,
OutputIter  data_out,
const Context *  ctx 
)

Definition at line 654 of file packing.h.

656{
657 unsigned int size = packable_size(tup, ctx);
658
659 // First write out info about the buffer size
660 put_packed_len<buffer_type>(size, data_out);
661
662 // Now pack the data
663 tail_pack_comp<Context, OutputIter, 0>(tup, data_out, ctx);
664}

◆ pack() [4/4]

template<typename T , typename Enable >
template<typename OutputIter , typename Context >
static void libMesh::Parallel::Packing< T, Enable >::pack ( const T &  object,
OutputIter  data_out,
const Context *  context 
)
static

◆ packable_size() [1/4]

template<typename T , typename Enable >
template<typename Context >
unsigned int libMesh::Parallel::Packing< T, Enable >::packable_size ( const std::array< T, N > &  a,
const Context *  ctx 
)

Definition at line 714 of file packing.h.

716{
717 unsigned int returnval = get_packed_len_entries<buffer_type>(); // size
718 for (const auto & entry : a)
719 returnval += Mixed::packable_size_comp(entry, ctx);
720 return returnval;
721}

◆ packable_size() [2/4]

template<typename T , typename Enable >
template<typename Context >
unsigned int libMesh::Parallel::Packing< T, Enable >::packable_size ( const std::pair< T1, T2 > &  pr,
const Context *  ctx 
)

Definition at line 420 of file packing.h.

422{
423 return get_packed_len_entries<buffer_type>() +
424 Mixed::packable_size_comp(pr.first, ctx) +
425 Mixed::packable_size_comp(pr.second, ctx);
426}

◆ packable_size() [3/4]

template<typename T , typename Enable >
template<typename Context >
unsigned int libMesh::Parallel::Packing< T, Enable >::packable_size ( const std::tuple< T, Types... > &  tup,
const Context *  ctx 
)

Definition at line 632 of file packing.h.

634{
635 return get_packed_len_entries<buffer_type>() +
636 tail_packable_size<Context, 0>(tup, ctx);
637}

◆ packable_size() [4/4]

template<typename T , typename Enable >
template<typename Context >
static unsigned int libMesh::Parallel::Packing< T, Enable >::packable_size ( const T &  object,
const Context *  context 
)
static

◆ packed_size()

template<typename T , std::size_t N>
template<typename BufferIter >
unsigned int libMesh::Parallel::Packing< T, N >::packed_size ( BufferIter  iter)
static

Definition at line 432 of file packing.h.

434{
435 // We recorded the size in the first buffer entries
436 return get_packed_len<buffer_type>(iter);
437}

Referenced by TIMPI::pack_range(), and TIMPI::unpack_range().

◆ unpack() [1/4]

template<typename T , typename Enable >
template<typename BufferIter , typename Context >
static T libMesh::Parallel::Packing< T, Enable >::unpack ( BufferIter  in,
Context *  ctx 
)
static

◆ unpack() [2/4]

template<typename T , typename Enable >
template<typename BufferIter , typename Context >
std::pair< T1, T2 > libMesh::Parallel::Packing< T, Enable >::unpack ( BufferIter  in,
Context *  ctx 
)

Definition at line 466 of file packing.h.

468{
469 std::pair<T1, T2> pr;
470
471 // We ignore total size here but we have to increment past it
472 constexpr int size_bytes = get_packed_len_entries<buffer_type>();
473 in += size_bytes;
474
475 // Unpack the data
476 Mixed::unpack_comp(pr.first, in, ctx);
477
478 // Make sure we increment the iterator
479 in += Mixed::packable_size_comp(pr.first, ctx);
480
481 Mixed::unpack_comp(pr.second, in, ctx);
482
483 return pr;
484}

◆ unpack() [3/4]

template<typename T , typename Enable >
template<typename BufferIter , typename Context >
std::tuple< T, Types... > libMesh::Parallel::Packing< T, Enable >::unpack ( BufferIter  in,
Context *  ctx 
)

Definition at line 670 of file packing.h.

672{
673 std::tuple<T, Types...> tup;
674
675 // We ignore total size here but we have to increment past it
676 constexpr int size_bytes = get_packed_len_entries<buffer_type>();
677 in += size_bytes;
678
679 // Unpack the data
680 tail_unpack_comp<Context, BufferIter, 0>(tup, in, ctx);
681
682 return tup;
683}

◆ unpack() [4/4]

template<typename T , typename Enable >
template<typename BufferIter , typename Context >
std::array< T, N > libMesh::Parallel::Packing< T, Enable >::unpack ( BufferIter  in,
Context *  ctx 
)

Definition at line 755 of file packing.h.

757{
758 std::array<T, N> a;
759
760 // We ignore total size here but we have to increment past it
761 constexpr int size_bytes = get_packed_len_entries<buffer_type>();
762 in += size_bytes;
763
764 // Unpack the data
765 for (auto & entry : a)
766 {
767 Mixed::unpack_comp(entry, in, ctx);
768
769 // Make sure we increment the iterator
770 in += Mixed::packable_size_comp(entry, ctx);
771 }
772
773 return a;
774}

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