int main(int argc, char * argv[]) { int rank = 0; PV_Init initObj(&argc, &argv, false/*allowUnrecognizedArguments*/); rank = initObj.getWorldRank(); char const * paramFile1 = "input/timeBatch.params"; char const * paramFile2 = "input/dimBatch.params"; int status = PV_SUCCESS; if (pv_getopt_str(argc, argv, "-p", NULL, NULL)==0) { if (rank==0) { pvErrorNoExit().printf("%s should be run without the params file argument.\n", argv[0]); } status = PV_FAILURE; } if (pv_getopt_str(argc, argv, "-c", NULL, NULL)==0) { if (rank==0) { pvErrorNoExit().printf("%s should be run without the checkpoint directory argument.\n", argv[0]); } status = PV_FAILURE; } if (pv_getopt(argc, argv, "-r", NULL)==0) { if (rank==0) { pvErrorNoExit().printf("%s should be run without the checkpoint directory argument.\n", argv[0]); } status = PV_FAILURE; } if (status != PV_SUCCESS) { if (rank==0) { pvErrorNoExit().printf("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) { pvError().printf("deleting old checkpoints and output directories failed: \"%s\" returned %d\n", rmcommand, status); } } initObj.setParams(paramFile1); status = rebuildandrun(&initObj); if( status != PV_SUCCESS ) { pvError().printf("%s: rank %d running with params file %s returned status code %d.\n", initObj.getProgramName(), rank, paramFile1, status); } initObj.setParams(paramFile2); status = rebuildandrun(&initObj); if( status != PV_SUCCESS ) { pvError().printf("%s: rank %d running with params file %s returned status code %d.\n", initObj.getProgramName(), rank, paramFile2, status); } return status==PV_SUCCESS ? EXIT_SUCCESS : EXIT_FAILURE; }
/** * @argc * @argv * @input_file * @param_file * @n_time_steps * @device */ int parse_options(int argc, char * argv[], bool * paramusage, bool * require_return, char ** output_path, char ** param_file, char ** log_file, char ** gpu_devices, unsigned int * random_seed, char ** working_dir, int * restart, char ** checkpointReadDir, bool * useDefaultNumThreads, int * numthreads, int * num_rows, int * num_columns, int* batch_width, int * dry_run) { // // Commented out Jan 7, 2016: some simple system tests do not require any arguments; // // other tests may use several different command line set ups and may choose to start // // blank and add separately. // // If there is interest in restoring this feature, it should be called from somewhere // // other than PV_Arguments::initialize // if (argc < 2) { // usage(); // return -1; // } paramusage[0] = true; int arg; for (arg=1; arg<argc; arg++) { paramusage[arg] = false; } if (pv_getopt(argc, argv, "--require-return", paramusage) == 0) { *require_return = true; } pv_getopt_str(argc, argv, "-d", gpu_devices, paramusage); pv_getoptionalopt_int(argc, argv, "-t", numthreads, useDefaultNumThreads, paramusage); pv_getopt_str(argc, argv, "-o", output_path, paramusage); pv_getopt_str(argc, argv, "-p", param_file, paramusage); pv_getopt_str(argc, argv, "-l", log_file, paramusage); pv_getopt_unsigned(argc, argv, "-s", random_seed, paramusage); pv_getopt_str(argc, argv, "-w", working_dir, paramusage); if (pv_getopt(argc, argv, "-r", paramusage) == 0) { *restart = 1; } pv_getopt_str(argc, argv, "-c", checkpointReadDir, paramusage); pv_getopt_int(argc, argv, "-rows", num_rows, paramusage); pv_getopt_int(argc, argv, "-columns", num_columns, paramusage); pv_getopt_int(argc, argv, "-batchwidth", batch_width, paramusage); if (pv_getopt(argc, argv, "-n", paramusage) == 0) { *dry_run = 1; } return 0; }
int main(int argc, char * argv[]) { int rank = 0; PV_Init * initObj = new PV_Init(&argc, &argv); MPI_Comm_rank(MPI_COMM_WORLD, &rank); char const * paramFile1 = "input/CheckpointParameters1.params"; char const * paramFile2 = "input/CheckpointParameters2.params"; int status = PV_SUCCESS; if (pv_getopt_str(argc, argv, "-p", NULL, NULL)==0) { if (rank==0) { fprintf(stderr, "%s should be run without the params file argument.\n", argv[0]); } status = PV_FAILURE; } if (pv_getopt_str(argc, argv, "-c", NULL, NULL)==0) { if (rank==0) { fprintf(stderr, "%s should be run without the checkpoint directory argument.\n", argv[0]); } status = PV_FAILURE; } if (pv_getopt(argc, argv, "-r", NULL)==0) { if (rank==0) { fprintf(stderr, "%s should be run without the checkpoint directory argument.\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; int pv_argc1 = 4 + argc; // command line arguments, plus "-p" plus paramFile1, plus -batchwidth and number int pv_argc2 = 6 + argc; // pv_argc1 arguments with paramFile2 in place of paramFile1, plus "-c", plus checkpoint directory, plus -batchwidth and number assert(pv_argc1 < pv_argc2); // so we can allocate based on pv_argc2 and be sure it will hold pv_argc1 arguments. char ** pv_argv = (char **) calloc((pv_argc2+1), sizeof(char *)); assert(pv_argv!=NULL); int pv_arg=0; for (pv_arg = 0; pv_arg < argc; pv_arg++) { pv_argv[pv_arg] = strdup(argv[pv_arg]); assert(pv_argv[pv_arg]); } assert(pv_arg==argc); pv_argv[pv_arg++] = strdup("-p"); pv_argv[pv_arg++] = strdup(paramFile1); pv_argv[pv_arg++] = strdup("-batchwidth"); pv_argv[pv_arg++] = strdup("2"); assert(pv_arg==pv_argc1 && pv_arg==argc+4); assert(pv_argv[argc]!=NULL && pv_argv[argc+1]!=NULL && pv_argv[argc+2]!=NULL && pv_argv[argc+3]!=NULL && pv_argv[argc+4]==NULL); status = rebuildandrun((int) pv_argc1, pv_argv, initObj, NULL, NULL, &customGroupHandler, 1); if( status != PV_SUCCESS ) { fprintf(stderr, "%s: rank %d running with params file %s returned error %d.\n", pv_argv[0], rank, paramFile1, status); exit(status); } free(pv_argv[argc+1]); pv_argv[argc+1] = strdup(paramFile2); assert(pv_argv[argc+1]); assert(pv_arg==argc+4); pv_argv[pv_arg++] = strdup("-c"); pv_argv[pv_arg++] = strdup("checkpoints1/batchsweep_00/Checkpoint12:checkpoints1/batchsweep_01/Checkpoint12"); assert(pv_arg==pv_argc2 && pv_arg==argc+6); assert(pv_argv[argc+4]!=NULL && pv_argv[argc+5]!=NULL && pv_argv[argc+6]==NULL); status = rebuildandrun(pv_argc2, pv_argv, initObj, NULL, &customexit, &customGroupHandler, 1); if( status != PV_SUCCESS ) { fprintf(stderr, "%s: rank %d running with params file %s returned error %d.\n", pv_argv[0], rank, paramFile2, status); } delete customGroupHandler; for (size_t arg=0; arg<pv_argc2; arg++) { free(pv_argv[arg]); } free(pv_argv); delete initObj; return status==PV_SUCCESS ? EXIT_SUCCESS : EXIT_FAILURE; }