PetaVision  Alpha
Publisher.hpp
1 /*
2  * Publisher.hpp
3  *
4  * Created on: Jul 19, 2016
5  * Author: pschultz
6  */
7 
8 #ifndef PUBLISHER_HPP_
9 #define PUBLISHER_HPP_
10 
11 #include "arch/mpi/mpi.h"
12 #include "checkpointing/Checkpointer.hpp"
13 #include "columns/DataStore.hpp"
14 #include "include/PVLayerLoc.h"
15 #include "include/pv_types.h"
16 #include "structures/MPIBlock.hpp"
17 #include "utils/BorderExchange.hpp"
18 
19 namespace PV {
20 
21 class Publisher {
22 
23  public:
24  Publisher(MPIBlock const &mpiBlock, PVLayerCube *cube, int numLevels, bool isSparse);
25  virtual ~Publisher();
26 
27  void
28  checkpointDataStore(Checkpointer *checkpointer, char const *objectName, char const *bufferName);
29 
34  int publish(double lastUpdateTime);
35 
42  void copyForward(double lastUpdateTime);
43  int exchangeBorders(const PVLayerLoc *loc, int delay = 0);
44  int isExchangeFinished(int delay = 0);
45 
50  PVLayerCube createCube(int delay = 0);
51 
52  int wait(int delay = 0);
53 
54  void increaseTimeLevel();
55 
56  void updateAllActiveIndices();
57  void updateActiveIndices(int delay = 0);
58 
59  private:
60  float *recvBuffer(int bufferId) { return store->buffer(bufferId); }
61  float *recvBuffer(int bufferId, int delay) { return store->buffer(bufferId, delay); }
62 
63  long *recvNumActiveBuffer(int bufferId) { return store->numActiveBuffer(bufferId); }
64  long *recvNumActiveBuffer(int bufferId, int delay) {
65  return store->numActiveBuffer(bufferId, delay);
66  }
67 
68  SparseList<float>::Entry *recvActiveIndicesBuffer(int bufferId) {
69  return store->activeIndicesBuffer(bufferId);
70  }
71  SparseList<float>::Entry *recvActiveIndicesBuffer(int bufferId, int delay) {
72  return store->activeIndicesBuffer(bufferId, delay);
73  }
74 
75  DataStore *store;
76 
77  PVLayerCube *mLayerCube;
78 
79  BorderExchange *mBorderExchanger = nullptr;
80 
81  RingBuffer<std::vector<MPI_Request>> *mpiRequestsBuffer = nullptr;
82  // std::vector<MPI_Request> requests;
83  MPI_Datatype *neighborDatatypes;
84 };
85 
86 } /* namespace PV */
87 
88 #endif /* PUBLISHER_HPP_ */
PVLayerCube createCube(int delay=0)
Definition: Publisher.cpp:60
int wait(int delay=0)
Definition: Publisher.cpp:166
int publish(double lastUpdateTime)
Definition: Publisher.cpp:77
void copyForward(double lastUpdateTime)
Definition: Publisher.cpp:101