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 
55 #if MPI_VERSION > 3
56 # define TIMPI_COUNT_TYPE MPI_COUNT
57 # define TIMPI_UNPACK MPI_Unpack_c
58 #else
59 # define TIMPI_COUNT_TYPE MPI_INT
60 # define TIMPI_UNPACK MPI_Unpack
61 #endif
62 
63  // We should at least have one header datum, for outer vector size
64  timpi_assert (!recvbuf.empty());
65 
66  // Unpack the received buffer
67  CountType bufsize = cast_int<CountType>(recvbuf.size());
68  CountType recvsize, pos=0;
69  timpi_call_mpi
70  (TIMPI_UNPACK(recvbuf.data(), bufsize, &pos, &recvsize, 1,
71  TIMPI_COUNT_TYPE, comm.get()));
72 
73  // ... size the outer buffer
74  recv.resize (recvsize);
75 
76  const std::size_t n_vecs = recvsize;
77  for (std::size_t i = 0; i != n_vecs; ++i)
78  {
79  CountType subvec_size;
80 
81  timpi_call_mpi
82  (TIMPI_UNPACK(recvbuf.data(), bufsize, &pos, &subvec_size, 1,
83  TIMPI_COUNT_TYPE, comm.get()));
84 
85  // ... size the inner buffer
86  recv[i].resize (subvec_size);
87 
88  // ... unpack the inner buffer if it is not empty
89  if (!recv[i].empty())
90  timpi_call_mpi
91  (TIMPI_UNPACK(recvbuf.data(), bufsize, &pos, recv[i].data(),
92  subvec_size, type, comm.get()));
93  }
94 #endif //TIMPI_HAVE_MPI
95  }
MPI_Count CountType
Definition: status.h:47
communicator & get()
Definition: communicator.h:167

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: