int main(int argc, char * argv[]) { int rank = 0; PV_Init * initObj = new PV_Init(&argc, &argv, false/*allowUnrecognizedArguments*/); MPI_Comm_rank(MPI_COMM_WORLD, &rank); char const * paramFile1 = "input/CheckpointParameters1.params"; char const * paramFile2 = "input/CheckpointParameters2.params"; int status = PV_SUCCESS; PV_Arguments * arguments = initObj->getArguments(); if (arguments->getParamsFile()!=NULL) { if (rank==0) { fprintf(stderr, "%s should be run without the params file argument.\n", arguments->getProgramName()); } status = PV_FAILURE; } if (arguments->getCheckpointReadDir()!=NULL) { if (rank==0) { fprintf(stderr, "%s should be run without the checkpoint directory argument.\n", argv[0]); } status = PV_FAILURE; } if (arguments->getRestartFlag()) { if (rank==0) { fprintf(stderr, "%s should be run without the restart flag.\n", argv[0]); } status = PV_FAILURE; } if (status != PV_SUCCESS) { if (rank==0) { fprintf(stderr, "This test uses two hard-coded params files, %s and %s. The second run is started from a checkpoint from the first run, and the results of the two runs are compared.\n", paramFile1, paramFile2); } MPI_Barrier(MPI_COMM_WORLD); exit(EXIT_FAILURE); } if (rank==0) { char const * rmcommand = "rm -rf checkpoints1 checkpoints2 output"; status = system(rmcommand); if (status != 0) { fprintf(stderr, "deleting old checkpoints and output directories failed: \"%s\" returned %d\n", rmcommand, status); exit(EXIT_FAILURE); } } ParamGroupHandler * customGroupHandler = new CustomGroupHandler; arguments->setParamsFile(paramFile1); arguments->setBatchWidth(2); status = rebuildandrun(initObj, NULL, NULL, &customGroupHandler, 1); if( status != PV_SUCCESS ) { fprintf(stderr, "%s: rank %d running with params file %s returned error %d.\n", arguments->getProgramName(), rank, paramFile1, status); exit(status); } arguments->setParamsFile(paramFile2); arguments->setCheckpointReadDir("checkpoints1/batchsweep_00/Checkpoint12:checkpoints1/batchsweep_01/Checkpoint12"); status = rebuildandrun(initObj, NULL, &customexit, &customGroupHandler, 1); if( status != PV_SUCCESS ) { fprintf(stderr, "%s: rank %d running with params file %s returned error %d.\n", arguments->getProgramName(), rank, paramFile2, status); } delete customGroupHandler; delete initObj; return status==PV_SUCCESS ? EXIT_SUCCESS : EXIT_FAILURE; }
int main(int argc, char * argv[]) { PV_Init* initObj = new PV_Init(&argc, &argv, false/*allowUnrecognizedArguments*/); PV_Arguments * arguments = initObj->getArguments(); if (arguments->getParamsFile()==NULL) { int rank = 0; MPI_Comm_rank(MPI_COMM_WORLD, &rank); if (rank==0) { fprintf(stderr, "%s does not take a -p argument; the necessary param file is hardcoded.\n", argv[0]); } MPI_Barrier(MPI_COMM_WORLD); exit(EXIT_FAILURE); } arguments->setParamsFile("input/test_gauss2d.params"); const char * pre_layer_name = "test_gauss2d pre"; const char * post_layer_name = "test_gauss2d post"; const char * pre2_layer_name = "test_gauss2d pre 2"; const char * post2_layer_name = "test_gauss2d post 2"; initObj->initialize(); PV::HyPerCol * hc = new PV::HyPerCol("test_gauss2d column", initObj); PV::Example * pre = new PV::Example(pre_layer_name, hc); assert(pre); PV::Example * post = new PV::Example(post_layer_name, hc); assert(post); PV::HyPerConn * cHyPer = new HyPerConn("test_gauss2d hyperconn", hc); PV::HyPerConn * cKernel = new HyPerConn("test_gauss2d kernelconn", hc); PV::Example * pre2 = new PV::Example(pre2_layer_name, hc); assert(pre2); PV::Example * post2 = new PV::Example(post2_layer_name, hc); assert(post2); PV::HyPerConn * cHyPer1to2 = new HyPerConn("test_gauss2d hyperconn 1 to 2", hc); assert(cHyPer1to2); PV::HyPerConn * cKernel1to2 = new HyPerConn("test_gauss2d kernelconn 1 to 2", hc); assert(cKernel1to2); PV::HyPerConn * cHyPer2to1 = new HyPerConn("test_gauss2d hyperconn 2 to 1", hc); assert(cHyPer2to1); PV::HyPerConn * cKernel2to1 = new HyPerConn("test_gauss2d kernelconn 2 to 1", hc); assert(cKernel2to1); int status = 0; for (int l=0; l<hc->numberOfLayers(); l++) { status = hc->getLayer(l)->communicateInitInfo(); assert(status==PV_SUCCESS); } for (int c=0; c<hc->numberOfConnections(); c++) { status = hc->getConnection(c)->communicateInitInfo(); assert(status==PV_SUCCESS); } for (int l=0; l<hc->numberOfLayers(); l++) { status = hc->getLayer(l)->allocateDataStructures(); assert(status==PV_SUCCESS); } for( int c=0; c<hc->numberOfConnections(); c++ ) { BaseConnection * baseConn = hc->getConnection(c); HyPerConn * conn = dynamic_cast<HyPerConn *>(baseConn); conn->allocateDataStructures(); conn->writeWeights(0, true); } const int axonID = 0; int num_pre_extended = pre->clayer->numExtended; assert(num_pre_extended == cHyPer->getNumWeightPatches()); for (int kPre = 0; kPre < num_pre_extended; kPre++) { //printf("testing testing 1 2 3...\n"); status = check_kernel_vs_hyper(cHyPer, cKernel, kPre, axonID); assert(status==0); status = check_kernel_vs_hyper(cHyPer1to2, cKernel1to2, kPre, axonID); assert(status==0); status = check_kernel_vs_hyper(cHyPer2to1, cKernel2to1, kPre, axonID); assert(status==0); } delete hc; delete initObj; return 0; }