TIMPI
Public Member Functions | Private Attributes | List of all members
TIMPI::PostWaitUnpackNestedBuffer< Container > Struct Template Reference

#include <post_wait_unpack_nested_buffer.h>

Inheritance diagram for TIMPI::PostWaitUnpackNestedBuffer< Container >:
[legend]

Public Member Functions

 PostWaitUnpackNestedBuffer (const std::vector< char > &buffer, Container &out, const DataType &timpi_mpi_var(T_type), const Communicator &comm_in)
 
 ~PostWaitUnpackNestedBuffer ()
 
virtual void run () override
 

Private Attributes

const std::vector< char > & recvbuf
 
Container & recv
 
DataType type
 
const Communicatorcomm
 

Detailed Description

template<typename Container>
struct TIMPI::PostWaitUnpackNestedBuffer< Container >

Definition at line 33 of file post_wait_unpack_nested_buffer.h.

Constructor & Destructor Documentation

◆ PostWaitUnpackNestedBuffer()

template<typename Container >
TIMPI::PostWaitUnpackNestedBuffer< Container >::PostWaitUnpackNestedBuffer ( const std::vector< char > &  buffer,
Container &  out,
const DataType timpi_mpi_varT_type,
const Communicator comm_in 
)
inline

Definition at line 34 of file post_wait_unpack_nested_buffer.h.

References TIMPI::PostWaitUnpackNestedBuffer< Container >::type.

37  :
38  recvbuf(buffer), recv(out), comm(comm_in) {
39  timpi_call_mpi(MPI_Type_dup(T_type, &(type.operator data_type &())));
40 #ifndef TIMPI_HAVE_MPI
41  timpi_not_implemented(); // This makes no sense without MPI_Unpack
42 #endif
43  }
MPI_Datatype data_type
Data types for communication.
Definition: data_type.h:33

◆ ~PostWaitUnpackNestedBuffer()

template<typename Container >
TIMPI::PostWaitUnpackNestedBuffer< Container >::~PostWaitUnpackNestedBuffer ( )
inline

Definition at line 45 of file post_wait_unpack_nested_buffer.h.

References TIMPI::PostWaitUnpackNestedBuffer< Container >::type.

45  {
46 #ifdef TIMPI_HAVE_MPI
47  // Not bothering with return type; we can't throw in a destructor
48  MPI_Type_free(&(type.operator data_type &()));
49 #endif
50  }
MPI_Datatype data_type
Data types for communication.
Definition: data_type.h:33

Member Function Documentation

◆ run()

template<typename Container >
virtual void TIMPI::PostWaitUnpackNestedBuffer< Container >::run ( )
inlineoverridevirtual

Implements TIMPI::PostWaitWork.

Definition at line 52 of file post_wait_unpack_nested_buffer.h.

References TIMPI::PostWaitUnpackNestedBuffer< Container >::comm, TIMPI::Communicator::get(), TIMPI::PostWaitUnpackNestedBuffer< Container >::recv, TIMPI::PostWaitUnpackNestedBuffer< Container >::recvbuf, and TIMPI::PostWaitUnpackNestedBuffer< Container >::type.

52  {
53 #ifdef TIMPI_HAVE_MPI
54  // We should at least have one header datum, for outer vector size
55  timpi_assert (!recvbuf.empty());
56 
57  // Unpack the received buffer
58  int bufsize = cast_int<int>(recvbuf.size());
59  int recvsize, pos=0;
60  timpi_call_mpi
61  (MPI_Unpack (recvbuf.data(), bufsize, &pos,
62  &recvsize, 1, StandardType<unsigned int>(),
63  comm.get()));
64 
65  // ... size the outer buffer
66  recv.resize (recvsize);
67 
68  const std::size_t n_vecs = recvsize;
69  for (std::size_t i = 0; i != n_vecs; ++i)
70  {
71  int subvec_size;
72 
73  timpi_call_mpi
74  (MPI_Unpack (recvbuf.data(), bufsize, &pos,
75  &subvec_size, 1,
76  StandardType<unsigned int>(),
77  comm.get()));
78 
79  // ... size the inner buffer
80  recv[i].resize (subvec_size);
81 
82  // ... unpack the inner buffer if it is not empty
83  if (!recv[i].empty())
84  timpi_call_mpi
85  (MPI_Unpack (recvbuf.data(), bufsize, &pos, recv[i].data(),
86  subvec_size, type, comm.get()));
87  }
88 #endif //TIMPI_HAVE_MPI
89  }
communicator & get()
Definition: communicator.h:165

Member Data Documentation

◆ comm

template<typename Container >
const Communicator& TIMPI::PostWaitUnpackNestedBuffer< Container >::comm
private

◆ recv

template<typename Container >
Container& TIMPI::PostWaitUnpackNestedBuffer< Container >::recv
private

◆ recvbuf

template<typename Container >
const std::vector<char>& TIMPI::PostWaitUnpackNestedBuffer< Container >::recvbuf
private

◆ type

template<typename Container >
DataType TIMPI::PostWaitUnpackNestedBuffer< Container >::type
private

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