8 #include "CheckpointEntryWeightPvp.hpp"     9 #include "io/WeightsFileIO.hpp"    10 #include "io/fileio.hpp"    11 #include "structures/Buffer.hpp"    12 #include "utils/BufferUtilsMPI.hpp"    13 #include "utils/BufferUtilsPvp.hpp"    18 void CheckpointEntryWeightPvp::initialize(Weights *weights, 
bool compressFlag) {
    20    mCompressFlag = compressFlag;
    23 void CheckpointEntryWeightPvp::write(
    24       std::string 
const &checkpointDirectory,
    26       bool verifyWritesFlag)
 const {
    27    std::string path(checkpointDirectory);
    28    path.append(
"/").append(getName()).append(
".pvp");
    29    FileStream *fileStream = 
nullptr;
    30    if (getMPIBlock()->getRank() == 0) {
    31       fileStream = 
new FileStream(path.c_str(), std::ios_base::out, verifyWritesFlag);
    34    WeightsFileIO weightFileIO(fileStream, getMPIBlock(), mWeights);
    35    weightFileIO.writeWeights(simTime, mCompressFlag);
    39 void CheckpointEntryWeightPvp::read(std::string 
const &checkpointDirectory, 
double *simTimePtr)
    43    for (
int arbor = 0; arbor < numArbors; arbor++) {
    49       std::size_t 
const numWeightsInArbor = (std::size_t)(numPatches * nxp * nyp * nfp);
    50       float *weightData                   = mWeights->
getData(arbor);
    52       memset(weightData, 0, numWeightsInArbor * 
sizeof(*weightData));
    55    std::string path(checkpointDirectory);
    56    path.append(
"/").append(getName()).append(
".pvp");
    57    FileStream *fileStream = 
nullptr;
    58    if (getMPIBlock()->getRank() == 0) {
    59       fileStream = 
new FileStream(path.c_str(), std::ios_base::in, 
false);
    62    WeightsFileIO weightFileIO(fileStream, getMPIBlock(), mWeights);
    63    double simTime = weightFileIO.readWeights(0 );
    65       *simTimePtr = simTime;
    70 void CheckpointEntryWeightPvp::remove(std::string 
const &checkpointDirectory)
 const {
    71    deleteFile(checkpointDirectory, 
"pvp");
 float * getData(int arbor)
int getPatchSizeX() const 
int getNumDataPatches() const 
int getPatchSizeY() const 
int getPatchSizeF() const