11 #include "checkpointing/Checkpointer.hpp" 12 #include "columns/BaseObject.hpp" 13 #include "columns/Communicator.hpp" 14 #include "columns/Messages.hpp" 15 #include "columns/PV_Init.hpp" 16 #include "include/pv_types.h" 17 #include "io/PVParams.hpp" 18 #include "observerpattern/Observer.hpp" 19 #include "observerpattern/ObserverTable.hpp" 20 #include "observerpattern/Subject.hpp" 21 #include "utils/Clock.hpp" 22 #include "utils/Timer.hpp" 33 #include <arch/cuda/CudaDevice.hpp> 59 virtual void ioParam_dt(
enum ParamsIOFlag ioFlag);
90 virtual void ioParam_nx(
enum ParamsIOFlag ioFlag);
95 virtual void ioParam_ny(
enum ParamsIOFlag ioFlag);
114 virtual Response::Status respond(std::shared_ptr<BaseMessage const> message)
override;
133 void advanceTimeLoop(
Clock &runClock,
int const runClockStartingStep);
134 int advanceTime(
double time);
135 void nonblockingLayerUpdate(std::shared_ptr<LayerUpdateStateMessage const> updateMessage);
136 void nonblockingLayerUpdate(
137 std::shared_ptr<LayerRecvSynapticInputMessage const> recvMessage,
138 std::shared_ptr<LayerUpdateStateMessage const> updateMessage);
139 int processParams(
char const *path);
140 int ioParamsFinishGroup(
enum ParamsIOFlag);
141 int ioParamsStartGroup(
enum ParamsIOFlag ioFlag,
const char *group_name);
153 int run() {
return run(mStopTime, mDeltaTime); }
154 int run(
double stopTime,
double dt);
158 bool getVerifyWrites() {
return mCheckpointer->doesVerifyWrites(); }
159 bool getCheckpointWriteFlag()
const {
return mCheckpointer->getCheckpointWriteFlag(); }
160 char const *getLastCheckpointDir()
const {
return mCheckpointer->getLastCheckpointDir(); }
161 bool getWriteTimescales()
const {
return mWriteTimescales; }
162 const char *getName() {
return mName; }
163 const char *getOutputPath() {
return mCheckpointer->getOutputPath().c_str(); }
164 const char *getPrintParamsFilename()
const {
return mPrintParamsFilename; }
165 double getDeltaTime()
const {
return mDeltaTime; }
166 double simulationTime()
const {
return mSimTime; }
167 double getStopTime()
const {
return mStopTime; }
168 int globalRank() {
return mCommunicator->globalCommRank(); }
169 int columnId() {
return mCommunicator->commRank(); }
170 int getNxGlobal() {
return mNumXGlobal; }
171 int getNyGlobal() {
return mNumYGlobal; }
172 int getNBatch() {
return mNumBatch; }
173 int getNBatchGlobal() {
return mNumBatchGlobal; }
174 int getNumThreads()
const {
return mNumThreads; }
175 int numberOfBorderRegions()
const {
return MAX_NEIGHBORS; }
176 int numberOfColumns() {
return mCommunicator->commSize(); }
177 int numberOfGlobalColumns() {
return mCommunicator->globalCommSize(); }
178 int commColumn() {
return mCommunicator->commColumn(); }
179 int commRow() {
return mCommunicator->commRow(); }
180 int commBatch() {
return mCommunicator->commBatch(); }
181 int numCommColumns() {
return mCommunicator->numCommColumns(); }
182 int numCommRows() {
return mCommunicator->numCommRows(); }
183 int numCommBatches() {
return mCommunicator->numCommBatches(); }
184 Communicator *getCommunicator()
const {
return mCommunicator; }
185 PV_Init *getPV_InitObj()
const {
return mPVInitObj; }
186 FileStream *getPrintParamsStream()
const {
return mPrintParamsStream; }
187 PVParams *parameters()
const {
return mParams; }
188 long int getFinalStep()
const {
return mFinalStep; }
189 unsigned int getRandomSeed() {
return mRandomSeed; }
190 unsigned int seedRandomFromWallClock();
194 std::map<std::string, Observer *> *copyObjectMap() {
195 auto objectMap =
new std::map<std::string, Observer *>;
196 *objectMap = mObjectHierarchy.getObjectMap();
201 int getAutoGPUDevice();
205 PVCuda::CudaDevice *getDevice() {
return mCudaDevice; }
211 void setDescription();
212 int initialize_base();
213 int initialize(
PV_Init *initObj);
214 void ioParams(
enum ParamsIOFlag ioFlag);
215 int ioParamsFillGroup(
enum ParamsIOFlag ioFlag);
217 int checkDirExists(
const char *dirname,
struct stat *pathstat);
218 inline void notifyLoop(std::vector<std::shared_ptr<BaseMessage const>> messages) {
219 bool printFlag = getCommunicator()->globalCommRank() == 0;
222 inline void notifyLoop(std::shared_ptr<BaseMessage const> message) {
223 notifyLoop(std::vector<std::shared_ptr<BaseMessage const>>{message});
226 respondPrepareCheckpointWrite(std::shared_ptr<PrepareCheckpointWriteMessage const> message);
228 void initializeCUDA(std::string
const &in_device);
230 #endif // PV_USE_CUDA 231 void outputParams(
char const *path);
232 void outputParamsHeadComments(
FileStream *fileStream,
char const *commentToken);
246 bool mErrorOnNotANumber;
249 bool mCheckpointReadFlag;
252 bool mParamsProcessedFlag;
254 bool mWriteTimeScaleFieldnames;
256 bool mWriteProgressToErr;
259 bool mOwnsCommunicator;
262 bool mWriteTimescales;
264 char *mPrintParamsFilename;
270 double mProgressInterval;
272 double mNextProgressTime;
282 int *mConnectionStatus;
286 long int mCurrentStep;
292 size_t mLayerArraySize;
293 size_t mConnectionArraySize;
294 std::ofstream mTimeScaleStream;
296 std::vector<Timer *> mPhaseRecvTimers;
297 unsigned int mRandomSeed;
299 PVCuda::CudaDevice *mCudaDevice;
Observer * getNextObject(Observer const *currentObject) const
void notifyLoop(ObserverTable const &table, std::vector< std::shared_ptr< BaseMessage const >> messages, bool printFlag, std::string const &description)
virtual void ioParam_writeProgressToErr(enum ParamsIOFlag ioFlag)
writeProgressToErr: Whether to print timestep progress to the error stream instead of the output stre...
virtual void ioParam_randomSeed(enum ParamsIOFlag ioFlag)
randomSeed: The seed for the random number generator for reproducability
virtual void ioParam_dt(enum ParamsIOFlag ioFlag)
dt: The default delta time to use.
virtual void ioParam_stopTime(enum ParamsIOFlag ioFlag)
mStopTime: The set stopping time for the run
int setNumThreads(bool printMessagesFlag)
virtual void ioParam_errorOnNotANumber(enum ParamsIOFlag ioFlag)
errorOnNotANumber: Specifies if the run should check on each timestep for nans in activity...
virtual void ioParam_ny(enum ParamsIOFlag ioFlag)
ny: Specifies the size of the column
virtual void ioParam_nBatch(enum ParamsIOFlag ioFlag)
ny: Specifies the batch size of the column
virtual void ioParam_nx(enum ParamsIOFlag ioFlag)
nx: Specifies the size of the column
virtual void ioParam_progressInterval(enum ParamsIOFlag ioFlag)
mProgressInterval: Specifies how often a progress report prints out
Observer * getObjectFromName(std::string const &objectName) const
virtual void ioParam_printParamsFilename(enum ParamsIOFlag ioFlag)
mPrintParamsFilename: Specifies the output mParams filename.