25 #include "buildandrun.hpp" 37 int (*custominit)(
HyPerCol *,
int,
char **),
38 int (*customexit)(
HyPerCol *,
int,
char **)) {
39 PV_Init initObj(&argc, &argv,
false );
40 int status = buildandrun(&initObj, custominit, customexit);
46 int (*custominit)(
HyPerCol *,
int,
char **),
47 int (*customexit)(
HyPerCol *,
int,
char **)) {
48 if (initObj->isExtraProc()) {
53 if (initObj->getWorldRank() == 0) {
55 if (progName == NULL) {
56 progName =
"PetaVision";
58 ErrorLog().printf(
"%s was called without having set a params file\n", progName);
60 MPI_Barrier(initObj->getCommunicator()->communicator());
64 int numParamSweepValues = initObj->
getParams()->getParameterSweepSize();
66 int status = PV_SUCCESS;
67 if (numParamSweepValues) {
68 for (
int k = 0; k < numParamSweepValues; k++) {
69 if (initObj->getWorldRank() == 0) {
71 "Parameter sweep: starting run %d of %d\n", k + 1, numParamSweepValues);
73 status = buildandrun1paramset(initObj, custominit, customexit, k) == PV_SUCCESS
79 status = buildandrun1paramset(initObj, custominit, customexit) == PV_SUCCESS ? status
90 int (*custominit)(
HyPerCol *,
int,
char **),
91 int (*customexit)(
HyPerCol *,
int,
char **)) {
92 return buildandrun(initObj, custominit, customexit);
95 int buildandrun1paramset(
97 int (*custominit)(
HyPerCol *,
int,
char **),
98 int (*customexit)(
HyPerCol *,
int,
char **),
100 if (sweepindex >= 0) {
101 initObj->
getParams()->setParameterSweepValues(sweepindex);
105 int status = PV_SUCCESS;
108 if (custominit || customexit) {
112 if (custominit != NULL) {
113 status = (*custominit)(hc, argc, argv);
114 if (status != PV_SUCCESS) {
115 ErrorLog().printf(
"custominit function failed with return value %d\n", status);
119 if (status == PV_SUCCESS && hc->getFinalStep() > 0L) {
121 if (status != PV_SUCCESS) {
122 ErrorLog().printf(
"HyPerCol::run() returned with error code %d\n", status);
125 if (status == PV_SUCCESS && customexit != NULL) {
126 status = (*customexit)(hc, argc, argv);
127 if (status != PV_SUCCESS) {
128 ErrorLog().printf(
"customexit function failed with return value %d\n", status);
131 if (custominit || customexit) {
static void freeArgs(int argc, char **argv)
char ** getArgsCopy() const
char const * getProgramName() const