artdaq  v2_03_00
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Pages
MPITransfer.hh
1 #ifndef ARTDAQ_TRANSFERPLUGINS_MPITRANSFER_HH
2 #define ARTDAQ_TRANSFERPLUGINS_MPITRANSFER_HH
3 
4 #include <vector>
5 
7 #include "artdaq-core/Data/Fragment.hh"
8 #include "artdaq/TransferPlugins/TransferInterface.hh"
9 
10 /*
11  Protocol: want to do a send for each request object, then wait for for
12  pending requests to complete, followed by a reset to allow another set
13  of sends to be completed.
14 
15  This needs to be separated into a thing for sending and a thing for receiving.
16  There probably needs to be a common class that both use.
17 */
18 
19 namespace artdaq
20 {
25  {
26  public:
38  MPITransfer(fhicl::ParameterSet pset, Role role);
39 
43  virtual ~MPITransfer();
44 
51  CopyStatus copyFragment(Fragment& frag, size_t timeout_usec) override;
52 
59  CopyStatus moveFragment(Fragment&& frag, size_t timeout_usec) override;
60 
67  int receiveFragment(Fragment& frag, size_t timeout_usec) override;
68 
69  private:
70  enum class status_t
71  {
72  SENDING,
73  PENDING,
74  DONE
75  };
76 
77  void cancelReq_(size_t buf, bool blocking_wait = true);
78 
79  void post_(size_t buf);
80 
81  // Identify an available buffer.
82  int findAvailable();
83 
84  TransferInterface::CopyStatus sendFragment(Fragment&& frag, size_t timeout_usec, bool force_async);
85 
86  int nextSource_();
87 
88  status_t src_status_; // Status of each sender.
89  size_t recvd_count_;
90  size_t expected_count_; // After EOD received: expected frags.
91 
92  Fragments payload_;
93 
94 #if USE_TESTSOME
95  int saved_wait_result_;
96  std::vector<int> ready_indices_;
97  std::vector<MPI_Status> ready_statuses_;
98 #endif
99  static std::mutex mpi_mutex_;
100  bool synchronous_sends_;
101 
102  std::vector<MPI_Request> reqs_;
103  int pos_;
104  };
105 }
106 
107 #endif //define ARTDAQ_TRANSFERPLUGINS_MPITRANSFER_HH
Role role() const
Get the TransferInterface::Role of this TransferInterface.
virtual ~MPITransfer()
MPITransfer Destructor.
Definition: MPI_transfer.cc:58
int receiveFragment(Fragment &frag, size_t timeout_usec) override
Receive a Fragment using MPI.
Definition: MPI_transfer.cc:92
MPITransfer(fhicl::ParameterSet pset, Role role)
MPITransfer Constructor.
Definition: MPI_transfer.cc:21
CopyStatus moveFragment(Fragment &&frag, size_t timeout_usec) override
Move a Fragment to the destination.
Role
Used to determine if a TransferInterface is a Sender or Receiver.
This interface defines the functions used to transfer data between artdaq applications.
MPITransfer is a TransferInterface implementation plugin that transfers data using MPI...
Definition: MPITransfer.hh:24
CopyStatus
Returned from the send functions, this enumeration describes the possible return codes. If an exception occurs, it will be thrown and should be handled normally.
CopyStatus copyFragment(Fragment &frag, size_t timeout_usec) override
Copy a Fragment to the destination. Forces asynchronous send.