From: Kevin M. Rosenberg Date: Mon, 19 Jun 2000 17:58:13 +0000 (+0000) Subject: r102: fixed mpi bug X-Git-Tag: debian-4.5.3-3~915 X-Git-Url: http://git.kpe.io/?p=ctsim.git;a=commitdiff_plain;h=207332eec9416d299766abb697312cfd27eb890e r102: fixed mpi bug --- diff --git a/src/ctrec.cpp b/src/ctrec.cpp index 42dadc0..2d94be9 100644 --- a/src/ctrec.cpp +++ b/src/ctrec.cpp @@ -9,7 +9,7 @@ ** This is part of the CTSim program ** Copyright (C) 1983-2000 Kevin Rosenberg ** -** $Id: ctrec.cpp,v 1.11 2000/06/18 10:27:11 kevin Exp $ +** $Id: ctrec.cpp,v 1.12 2000/06/19 17:58:13 kevin Exp $ ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License (version 2) as @@ -176,11 +176,11 @@ ctrec_main (int argc, char * argv[]) break; case O_VERSION: #ifdef VERSION - cout << "Version " << VERSION << endl; + cout << "Version " << VERSION << endl; #else - cout << "Unknown version number" << endl; + cout << "Unknown version number" << endl; #endif - exit(0); + return (0); case O_HELP: case '?': ctrec_usage(argv[0]); @@ -370,7 +370,17 @@ ReduceImageMPI (MPIWorld& mpiWorld, ImageFile* imLocal, ImageFile* imGlobal) int main (int argc, char* argv[]) { - return (ctrec_main(argc, argv)); + int retval = 1; + + try { + retval = ctrec_main(argc, argv); + } catch (exception e) { + cerr << "Exception: " << e.what() << endl; + } catch (...) { + cerr << "Unknown exception" << endl; + } + + return (retval); } #endif diff --git a/src/if-1.cpp b/src/if-1.cpp index f85a269..07359a0 100644 --- a/src/if-1.cpp +++ b/src/if-1.cpp @@ -9,7 +9,7 @@ ** This is part of the CTSim program ** Copyright (C) 1983-2000 Kevin Rosenberg ** -** $Id: if-1.cpp,v 1.7 2000/06/18 10:27:11 kevin Exp $ +** $Id: if-1.cpp,v 1.8 2000/06/19 17:58:13 kevin Exp $ ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License (version 2) as @@ -189,7 +189,17 @@ if1_main (int argc, char *const argv[]) int main (int argc, char *const argv[]) { - return (if1_main(argc, argv)); + int retval = 1; + + try { + retval = if1_main(argc, argv); + } catch (exception e) { + cerr << "Exception: " << e.what() << endl; + } catch (...) { + cerr << "Unknown exception" << endl; + } + + return (retval); } #endif diff --git a/src/if-2.cpp b/src/if-2.cpp index 89e6cc8..0d35a12 100644 --- a/src/if-2.cpp +++ b/src/if-2.cpp @@ -9,7 +9,7 @@ ** This is part of the CTSim program ** Copyright (C) 1983-2000 Kevin Rosenberg ** -** $Id: if-2.cpp,v 1.5 2000/06/18 10:27:11 kevin Exp $ +** $Id: if-2.cpp,v 1.6 2000/06/19 17:58:13 kevin Exp $ ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License (version 2) as @@ -216,7 +216,17 @@ if2_main (int argc, char *const argv[]) int main (int argc, char *const argv[]) { - return (if2_main(argc, argv)); + int retval = 1; + + try { + retval = if2_main(argc, argv); + } catch (exception e) { + cerr << "Exception: " << e.what() << endl; + } catch (...) { + cerr << "Unknown exception" << endl; + } + + return (retval); } #endif diff --git a/src/if2img.cpp b/src/if2img.cpp index 018e504..c3a4bfe 100644 --- a/src/if2img.cpp +++ b/src/if2img.cpp @@ -9,7 +9,7 @@ ** This is part of the CTSim program ** Copyright (C) 1983-2000 Kevin Rosenberg ** -** $Id: if2img.cpp,v 1.6 2000/06/18 10:27:11 kevin Exp $ +** $Id: if2img.cpp,v 1.7 2000/06/19 17:58:13 kevin Exp $ ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License (version 2) as @@ -255,7 +255,7 @@ if2img_main (int argc, char *const argv[]) #else cout << "Unknown version number" << endl; #endif - exit(0); + return (0); case O_HELP: case '?': if2img_usage(argv[0]); @@ -282,7 +282,7 @@ if2img_main (int argc, char *const argv[]) pim = new ImageFile (in_file); ImageFile& im = *pim; if (! im.fileRead()) { - sys_error (ERR_SEVERE, "File %s does not exist", in_file); + sys_error (ERR_FATAL, "File %s does not exist", in_file); return (1); } @@ -631,8 +631,8 @@ sdf2d_to_gif (ImageFile& im, char *outfile, int nxcell, int nycell, double densm delete rowp; if ((out = fopen(outfile,"w")) == NULL) { - sys_error(ERR_SEVERE,"Error opening output file %s for writing", outfile); - exit(1); + sys_error(ERR_FATAL, "Error opening output file %s for writing", outfile); + return (1); } gdImageGif(gif,out); fclose(out); @@ -646,6 +646,16 @@ sdf2d_to_gif (ImageFile& im, char *outfile, int nxcell, int nycell, double densm int main (int argc, char *const argv[]) { - return (if2img_main(argc, argv)); + int retval = 1; + + try { + retval = if2img_main(argc, argv); + } catch (exception e) { + cerr << "Exception: " << e.what() << endl; + } catch (...) { + cerr << "Unknown exception" << endl; + } + + return (retval); } #endif diff --git a/src/ifinfo.cpp b/src/ifinfo.cpp index f0a475d..c911aa5 100644 --- a/src/ifinfo.cpp +++ b/src/ifinfo.cpp @@ -9,7 +9,7 @@ ** This is part of the CTSim program ** Copyright (C) 1983-2000 Kevin Rosenberg ** -** $Id: ifinfo.cpp,v 1.8 2000/06/18 10:27:11 kevin Exp $ +** $Id: ifinfo.cpp,v 1.9 2000/06/19 17:58:13 kevin Exp $ ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License (version 2) as @@ -236,6 +236,16 @@ ifinfo_main (int argc, char *const argv[]) int main (int argc, char *const argv[]) { - return (ifinfo_main(argc, argv)); + int retval = 1; + + try { + retval = ifinfo_main(argc, argv); + } catch (exception e) { + cerr << "Exception: " << e.what() << endl; + } catch (...) { + cerr << "Unknown exception" << endl; + } + + return (retval); } #endif diff --git a/src/phm2if.cpp b/src/phm2if.cpp index 573cb7c..0eb5c9e 100644 --- a/src/phm2if.cpp +++ b/src/phm2if.cpp @@ -9,7 +9,7 @@ ** This is part of the CTSim program ** Copyright (C) 1983-2000 Kevin Rosenberg ** -** $Id: phm2if.cpp,v 1.10 2000/06/18 10:27:11 kevin Exp $ +** $Id: phm2if.cpp,v 1.11 2000/06/19 17:58:13 kevin Exp $ ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License (version 2) as @@ -270,7 +270,7 @@ phm2if_main (int argc, char* argv[]) #endif #ifdef HAVE_MPI - TimerMPI timerBcast (mpiWorld.getComm()); + TimerCollectiveMPI timerBcast (mpiWorld.getComm()); mpiWorld.getComm().Bcast (&opt_verbose, 1, MPI::INT, 0); mpiWorld.getComm().Bcast (&opt_debug, 1, MPI::INT, 0); mpiWorld.getComm().Bcast (&opt_trace, 1, MPI::INT, 0); @@ -305,7 +305,7 @@ phm2if_main (int argc, char* argv[]) else { if (mpiWorld.getRank() == 0) cerr << "phmnum < 0" << endl; - exit(1); + return (1); } #endif @@ -323,12 +323,12 @@ phm2if_main (int argc, char* argv[]) image_filter_response (*imGlobal, opt_filter_domain, opt_filter_bw, opt_filter, opt_filter_param, opt_trace); } } else { - TimerMPI timerRasterize (mpiWorld.getComm()); + TimerCollectiveMPI timerRasterize (mpiWorld.getComm()); phm_to_imagefile (phm, *imLocal, mpiWorld.getMyStartWorkUnit(), mpiWorld.getMyLocalWorkUnits(), opt_nsample, opt_trace); if (opt_verbose) timerRasterize.timerEndAndReport ("Time to rasterize phantom"); - TimerMPI timerGather (mpiWorld.getComm()); + TimerCollectiveMPI timerGather (mpiWorld.getComm()); mpi_gather_image (mpiWorld, imGlobal, imLocal, opt_debug); if (opt_verbose) timerGather.timerEndAndReport ("Time to gather image"); @@ -405,6 +405,16 @@ void mpi_gather_image (MPIWorld& mpiWorld, ImageFile* imGlobal, ImageFile* imLoc int main (int argc, char* argv[]) { - return (phm2if_main(argc, argv)); + int retval = 1; + + try { + retval = phm2if_main(argc, argv); + } catch (exception e) { + cerr << "Exception: " << e.what() << endl; + } catch (...) { + cerr << "Unknown exception" << endl; + } + + return (retval); } #endif diff --git a/src/phm2pj.cpp b/src/phm2pj.cpp index fe83154..fa8d0a9 100644 --- a/src/phm2pj.cpp +++ b/src/phm2pj.cpp @@ -9,7 +9,7 @@ ** This is part of the CTSim program ** Copyright (C) 1983-2000 Kevin Rosenberg ** -** $Id: phm2pj.cpp,v 1.1 2000/06/17 20:12:15 kevin Exp $ +** $Id: phm2pj.cpp,v 1.2 2000/06/19 17:58:13 kevin Exp $ ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License (version 2) as @@ -91,10 +91,11 @@ phm2pj_main (int argc, char* argv[]) char *opt_outfile = NULL; string opt_desc; string opt_phmfilename; - int opt_ndet, opt_nview; + int opt_ndet; + int opt_nview; int opt_nray = 1; int opt_trace = 0; - int opt_phmnum = -1; + int optPhmNum = -1; int opt_verbose = 0; int opt_debug = 0; double opt_rotangle = 1; @@ -118,11 +119,11 @@ phm2pj_main (int argc, char* argv[]) switch (c) { case O_PHANTOM: - if ((opt_phmnum = opt_set_phantom (optarg)) < 0) { + if ((optPhmNum = opt_set_phantom (optarg)) < 0) { phm2pj_usage(argv[0]); return (1); } - phm.create (opt_phmnum); + phm.create (optPhmNum); break; case O_PHMFILE: #ifdef HAVE_MPI @@ -169,11 +170,11 @@ phm2pj_main (int argc, char* argv[]) break; case O_VERSION: #ifdef VERSION - cout << "Version: " << VERSION << endl; + cout << "Version: " << VERSION << endl; #else - cout << "Unknown version number" << endl; + cout << "Unknown version number" << endl; #endif - exit(0); + return (0); case O_HELP: case '?': phm2pj_usage(argv[0]); @@ -214,8 +215,8 @@ phm2pj_main (int argc, char* argv[]) desc << "Raysum_Collect: NDet=" << opt_ndet << ", Nview=" << opt_nview << ", NRay=" << opt_nray << ", RotAngle=" << opt_rotangle << ", "; if (opt_phmfilename.length()) { desc << "PhantomFile=" << opt_phmfilename; - } else if (opt_phmnum != -1) { - desc << "Phantom=" << name_of_phantom(opt_phmnum); + } else if (optPhmNum != -1) { + desc << "Phantom=" << name_of_phantom(optPhmNum); } if (opt_desc.length()) { desc << ": " << opt_desc; @@ -226,17 +227,19 @@ phm2pj_main (int argc, char* argv[]) #endif #ifdef HAVE_MPI + TimerCollectiveMPI timerBcast(mpiWorld.getComm()); mpiWorld.getComm().Bcast (&opt_rotangle, 1, MPI::DOUBLE, 0); mpiWorld.getComm().Bcast (&opt_nview, 1, MPI::INT, 0); mpiWorld.getComm().Bcast (&opt_ndet, 1, MPI::INT, 0); mpiWorld.getComm().Bcast (&opt_nray, 1, MPI::INT, 0); - mpiWorld.getComm().Bcast (&opt_phmnum, 1, MPI::INT, 0); + mpiWorld.getComm().Bcast (&optPhmNum, 1, MPI::INT, 0); mpiWorld.getComm().Bcast (&opt_verbose, 1, MPI::INT, 0); mpiWorld.getComm().Bcast (&opt_debug, 1, MPI::INT, 0); mpiWorld.getComm().Bcast (&opt_trace, 1, MPI::INT, 0); + timerBcast.timerEndAndReport ("Time to broadcast variables"); - if (mpiWorld.getRank() > 0 && opt_phmnum >= 0) - phm.create (opt_phmnum); + if (mpiWorld.getRank() > 0 && optPhmNum >= 0) + phm.create (optPhmNum); #endif opt_rotangle *= PI; @@ -246,24 +249,28 @@ phm2pj_main (int argc, char* argv[]) mpiWorld.setTotalWorkUnits (opt_nview); Projections pjGlobal; - if (mpiWorld.getRank() == 0) { - pjGlobal = Projections (scanner); - } + if (mpiWorld.getRank() == 0) + pjGlobal.initFromScanner (scanner); - Scanner localScanner (phm, opt_geometry, opt_ndet, mpiWorld.getMyLocalWorkUnits(), opt_nray, opt_rotangle); - Projections pjLocal (localScanner); + if (opt_verbose) + pjGlobal.printScanInfo(); + + Projections pjLocal (scanner); + pjLocal.setNView (mpiWorld.getMyLocalWorkUnits()); + if (opt_debug) cout << "pjLocal->nview = " << pjLocal.nView() << " (process " << mpiWorld.getRank() << ")" << endl;; - TimerMPI timerProject (mpiWorld.getComm()); - localScanner.collectProjections (pjLocal, phm, mpiWorld.getMyStartWorkUnit(), opt_trace); + TimerCollectiveMPI timerProject (mpiWorld.getComm()); + scanner.collectProjections (pjLocal, phm, mpiWorld.getMyStartWorkUnit(), opt_trace); if (opt_verbose) timerProject.timerEndAndReport ("Time to collect projections"); - TimerMPI timerGather (mpiWorld.getComm()); + TimerCollectiveMPI timerGather (mpiWorld.getComm()); GatherProjectionsMPI (mpiWorld, pjGlobal, pjLocal, opt_debug); - if (opt_verbose) - timerGather.timerEndAndReport ("Time to gather projections"); + if (opt_verbose) + timerGather.timerEndAndReport ("Time to gather projections"); + #else Projections pjGlobal (scanner); scanner.collectProjections (pjGlobal, phm, 0, opt_trace); @@ -281,7 +288,7 @@ phm2pj_main (int argc, char* argv[]) cout << endl; pjGlobal.printScanInfo(); cout << endl; - cout << "Remark: " << pjGlobal.remark() << endl; + cout << " Remark: " << pjGlobal.remark() << endl; cout << "Run time: " << pjGlobal.calcTime() << " seconds" << endl; } } @@ -317,7 +324,7 @@ void GatherProjectionsMPI (MPIWorld& mpiWorld, Projections& pjGlobal, Projection MPI::Status status; double viewAngle; int nDet; - DetectorArray detArray = pjGlobal.getDetectorArray(iw); + DetectorArray& detArray = pjGlobal.getDetectorArray(iw); DetectorValue* detval = detArray.detValues(); mpiWorld.getComm().Recv(&viewAngle, 1, MPI::DOUBLE, iProc, 0, status); @@ -327,7 +334,6 @@ void GatherProjectionsMPI (MPIWorld& mpiWorld, Projections& pjGlobal, Projection } } } - } #endif @@ -336,7 +342,17 @@ void GatherProjectionsMPI (MPIWorld& mpiWorld, Projections& pjGlobal, Projection int main (int argc, char* argv[]) { - return (phm2pj_main(argc, argv)); + int retval = 1; + + try { + retval = phm2pj_main(argc, argv); + } catch (exception e) { + cerr << "Exception: " << e.what() << endl; + } catch (...) { + cerr << "Unknown exception" << endl; + } + + return (retval); } #endif diff --git a/src/pj2if.cpp b/src/pj2if.cpp index 530f23b..26c5376 100644 --- a/src/pj2if.cpp +++ b/src/pj2if.cpp @@ -9,7 +9,7 @@ ** This is part of the CTSim program ** Copyright (C) 1983-2000 Kevin Rosenberg ** -** $Id: pj2if.cpp,v 1.2 2000/06/18 10:27:11 kevin Exp $ +** $Id: pj2if.cpp,v 1.3 2000/06/19 17:58:13 kevin Exp $ ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License (version 2) as @@ -140,6 +140,16 @@ pj2if_main (const int argc, char *const argv[]) int main (const int argc, char *const argv[]) { - return (pj2if_main(argc, argv)); + int retval = 1; + + try { + retval = pj2if_main(argc, argv); + } catch (exception e) { + cerr << "Exception: " << e.what() << endl; + } catch (...) { + cerr << "Unknown exception" << endl; + } + + return (retval); } #endif