SENSEI
A frame work for generic in situ analytics
InTransitDataAdaptor.h
1 #ifndef sensei_InTransitDataAdaptor_h
2 #define sensei_InTransitDataAdaptor_h
3 
4 #include "DataAdaptor.h"
5 #include "Partitioner.h"
6 
7 /// @cond
8 namespace pugi { class xml_node; }
9 /// @endcond
10 
11 namespace sensei
12 {
13 
14 /** Defines the control API for in transit data movement. The
15  * InTransitDataAdaptor layers a control API onto the sensei::DataAdaptor API.
16  * In what follows the simulation is the sender of data and the end point and
17  * or sensei::AnalysisAdaptor is the receiver of data. The InTransitDataAdaptor
18  * control API gives end point control over how data lands. A data receiver may
19  * epxlicitly specifiy how data lands (see SetReceiverMeshMetadata) or use one
20  * of a number of common paritioning strategies (see sensei::Partitioner and
21  * derived classes). Typically by an AnalysisAdaptor which needs explicit
22  * control over how data is partitioned will use SetReceiverMeshMetadata. When
23  * no receiver MeshMetadata has been provided a sensei::Partitioner is used.
24  * The partioner may be specified in XML, and if it is not, then the default is
25  * sensei::BlockPartitioner.
26  */
27 class SENSEI_EXPORT InTransitDataAdaptor : public sensei::DataAdaptor
28 {
29 public:
30  senseiTypeMacro(InTransitDataAdaptor, sensei::DataAdaptor);
31 
32  /** Pass in a string containing transport specific connection information.
33  * This is optional, as XML may be used to specify connection as well.
34  * When used the details will be specific to the transport, for instance
35  * ADIOS uses a file to negotiate the connection, hence for ADIOS
36  * connection info will be a path to that file.
37  */
38  virtual int SetConnectionInfo(const std::string &info);
39 
40  /// Return the current connection info.
41  virtual const std::string &GetConnectionInfo() const;
42 
43  /** Initialize the adaptor from an XML node. The default implementation
44  * handles initializing a sensei::ConfigurablePartitioner. If the
45  * ConfigurablePartitioner fails to initialize, then a we fall back to a
46  * default initialized sensei::BlockPartitioner.
47  */
48  virtual int Initialize(pugi::xml_node &node);
49 
50  /// Get metadta object describing the data that is available in the simulation.
51  virtual int GetSenderMeshMetadata(unsigned int id, MeshMetadataPtr &metadata) = 0;
52 
53  /** This API that enables one to specify how the data is partitioned on the
54  * analysis/local side. Analyses that need control over how data lands can
55  * use this to say where data lands. The metadata object passed here will be
56  * returned to the Analysis, and the transport layer will use it to move
57  * blocks onto the correct ranks. Care, should be taken as there will be
58  * variablility in terms of what various transport layers support. The
59  * requirement for SENSEI 3.0 is that blocks are elemental. In other words
60  * given M ranks and P blocks on the sender/simulation side, a partitioning
61  * with N ranks and P blocks on the receiver/analysis side is supported. A
62  * transport may support more sophistocated partitioning, but it's not
63  * required. An analysis need not use this API, in that case the default is
64  * handled by the transport layer. See comments in
65  * InTransitDataAdaptor::Initialize for the universal partioning options as
66  * well as comments in the specific transport's implementation.
67  *
68  * The default implementation manages the metadata objects, derived classes
69  * must handle the details of initiallizing these objects. Get calls will
70  * return -1 if no object has been set for a given id.
71  */
72  virtual int SetReceiverMeshMetadata(unsigned int id, MeshMetadataPtr &metadata);
73 
74  /// Returns the current receiver mesh metadata.
75  virtual int GetReceiverMeshMetadata(unsigned int id, MeshMetadataPtr &metadata);
76 
77  /** Set/get the partitioner. The partitioner is used when no receiver mesh
78  * metadata has been set. The Initialize method will initialize an instance
79  * of a ConfigurablePartitioner using user provided XML, if that fails will
80  * fall back to a default initialized instance of BlockPartitioner.
81  */
82  virtual void SetPartitioner(const sensei::PartitionerPtr &partitioner);
83 
84  /// Return the current partitioner.
85  virtual sensei::PartitionerPtr GetPartitioner();
86 
87  /// Opens a stream and connects to the simulation.
88  virtual int OpenStream() = 0;
89 
90  /// Closes a stream and disconnects from the simulation.
91  virtual int CloseStream() = 0;
92 
93  /// Signals the that we are finished with this time step.
94  virtual int AdvanceStream() = 0;
95 
96  /// Returns true while there is more data to process.
97  virtual int StreamGood() = 0;
98 
99  /// Called before the application is brought down. It is safe to use MPI here.
100  virtual int Finalize() = 0;
101 
102 protected:
105 
107  void operator=(const InTransitDataAdaptor&) = delete;
108 
109  struct InternalsType;
110  InternalsType *Internals;
111 };
112 
113 }
114 #endif
int Initialize(MPI_Comm comm, const std::string &fileName, InTransitDataAdaptor *&dataAdaptor)
Creates a sensei::ConfigurableAnalysis adaptor and sensei::InTransitDataAdaptor based on a SENSEI XML...
Defines the control API for in transit data movement.
Definition: InTransitDataAdaptor.h:27
SENSEI.
Definition: ADIOS2AnalysisAdaptor.h:27
Definition: ADIOS2DataAdaptor.h:10
Base class that defines the interface for fetching data from a simulation.
Definition: DataAdaptor.h:25