PetaVision  Alpha
CheckpointEntryPvp.hpp
1 /*
2  * CheckpointEntryPvp.hpp
3  *
4  * Created on Feb 13, 2017
5  * Author: Pete Schultz
6  */
7 
8 #ifndef CHECKPOINTENTRYPVP_HPP_
9 #define CHECKPOINTENTRYPVP_HPP_
10 
11 #include "CheckpointEntry.hpp"
12 #include "include/PVLayerLoc.h"
13 #include <string>
14 #include <vector>
15 
16 namespace PV {
17 
18 template <typename T>
20  public:
22  std::string const &name,
23  MPIBlock const *mpiBlock,
24  PVLayerLoc const *layerLoc,
25  bool extended);
27  std::string const &objName,
28  std::string const &dataName,
29  MPIBlock const *mpiBlock,
30  PVLayerLoc const *layerLoc,
31  bool extended);
32  virtual void write(std::string const &checkpointDirectory, double simTime, bool verifyWritesFlag)
33  const override;
34  virtual void read(std::string const &checkpointDirectory, double *simTimePtr) const override;
35  virtual void remove(std::string const &checkpointDirectory) const override;
36 
37  protected:
38  void initialize(PVLayerLoc const *layerLoc, bool extended);
39 
40  virtual int getNumFrames() const = 0;
41  virtual T *calcBatchElementStart(int batchElement) const = 0;
42  virtual int calcMPIBatchIndex(int frame) const = 0;
43  virtual void applyTimestamps(std::vector<double> const &timestamps) const {}
44 
45  T *getDataPointer() const { return mDataPointer; }
46  PVLayerLoc const *getLayerLoc() const { return mLayerLoc; }
47  int getXMargins() const { return mXMargins; }
48  int getYMargins() const { return mYMargins; }
49 
50  private:
51  T *mDataPointer = nullptr;
52  PVLayerLoc const *mLayerLoc = nullptr;
53 
54  // If extended is true (reading/writing an extended buffer), use mLayerLoc->halo for the margins
55  // If extended is false (reading/writing a restricted buffer), use 0 for the margins.
56  int mXMargins = 0;
57  int mYMargins = 0;
58 };
59 
60 } // end namespace PV
61 
62 #include "CheckpointEntryPvp.tpp"
63 
64 #endif // CHECKPOINTENTRYPVP_HPP_