** This is part of the CTSim program
** Copyright (C) 1983-2000 Kevin Rosenberg
**
-** $Id: ctrec.cpp,v 1.2 2000/06/07 07:43:19 kevin Exp $
+** $Id: ctrec.cpp,v 1.3 2000/06/07 10:12:05 kevin Exp $
** $Log: ctrec.cpp,v $
+** Revision 1.3 2000/06/07 10:12:05 kevin
+** Upgraded from MPI to MPI++
+**
** Revision 1.2 2000/06/07 07:43:19 kevin
** Converted to IF data files and C++
**
}
-#ifdef MPI_CT
+#ifdef HAVE_MPI
static void mpi_scatter_rs (RAYSUM *rs_global, RAYSUM *rs_local, const int debug);
#endif
int opt_interp_param = 1;
BackprojType opt_backproj = O_BPROJ_DIFF2;
int nx, ny;
-#ifdef MPI_CT
+#ifdef HAVE_MPI
ImageFile *im_local;
RAYSUM *rs_local;
int mpi_argc = argc;
double mpi_detinc, mpi_rotinc, mpi_phmlen;
double mpi_t1, mpi_t2, mpi_t, mpi_t_g;
- MPI_Init(&mpi_argc, &mpi_argv);
- MPI_Comm_dup (MPI_COMM_WORLD, &mpi_ct.comm);
- MPI_Comm_size(mpi_ct.comm, &mpi_ct.nproc);
- MPI_Comm_rank(mpi_ct.comm, &mpi_ct.my_rank);
+ MPI::Init (mpi_argc, mpi_argv);
+ mpi_ct.comm = MPI::COMM_WORLD.Dup();
+ mpi_ct.nproc = mpi_ct.comm.Get_size();
+ mpi_ct.my_rank = mpi_ct.comm.Get_rank();
- if (mpi_ct.nproc > MPI_MAX_PROCESS) {
+ if (mpi_ct.nproc > CT_MPI_MAX_PROCESS) {
sys_error(ERR_FATAL, "Number of mpi processes (%d) exceeds max processes (%d)",
- mpi_ct.nproc, MPI_MAX_PROCESS);
+ mpi_ct.nproc, CT_MPI_MAX_PROCESS);
exit(1);
}
#endif
-#ifdef MPI_CT
- time_start = MPI_Wtime();
+#ifdef HAVE_MPI
+ time_start = MPI::Wtime();
#else
time_start = td_current_sec();
#endif
-#ifdef MPI_CT
+#ifdef HAVE_MPI
if (mpi_ct.my_rank == 0) {
#endif
while (1) {
if (opt_verbose)
fprintf (stdout, "%s\n", remark);
-#ifdef MPI_CT
+#ifdef HAVE_MPI
}
#endif
-#ifdef MPI_CT
+#ifdef HAVE_MPI
if (mpi_ct.my_rank == 0) {
rs_global = raysum_open (rs_name);
raysum_read (rs_global);
mpi_rotinc = rs_global->rot_inc;
}
- mpi_t1 = MPI_Wtime();
- MPI_Bcast(&opt_verbose, 1, MPI_INT, 0, mpi_ct.comm);
- MPI_Bcast(&opt_debug, 1, MPI_INT, 0, mpi_ct.comm);
- MPI_Bcast(&opt_trace, 1, MPI_INT, 0, mpi_ct.comm);
- MPI_Bcast(&opt_filter, 1, MPI_INT, 0, mpi_ct.comm);
- MPI_Bcast(&opt_interp, 1, MPI_INT, 0, mpi_ct.comm);
- MPI_Bcast(&opt_filter_param, 1, MPI_DOUBLE, 0, mpi_ct.comm);
- MPI_Bcast(&opt_interp_param, 1, MPI_INT, 0, mpi_ct.comm);
- MPI_Bcast(&opt_backproj, 1, MPI_INT, 0, mpi_ct.comm);
- MPI_Bcast(&mpi_ndet, 1, MPI_INT, 0, mpi_ct.comm);
- MPI_Bcast(&mpi_nview, 1, MPI_INT, 0, mpi_ct.comm);
- MPI_Bcast(&mpi_detinc, 1, MPI_DOUBLE, 0, mpi_ct.comm);
- MPI_Bcast(&mpi_phmlen, 1, MPI_DOUBLE, 0, mpi_ct.comm);
- MPI_Bcast(&mpi_rotinc, 1, MPI_DOUBLE, 0, mpi_ct.comm);
- MPI_Bcast(&nx, 1, MPI_INT, 0, mpi_ct.comm);
- MPI_Bcast(&ny, 1, MPI_INT, 0, mpi_ct.comm);
+ mpi_t1 = MPI::Wtime();
+ mpi_ct.comm.Bcast (&opt_verbose, 1, MPI::INT, 0);
+ mpi_ct.comm.Bcast (&opt_debug, 1, MPI::INT, 0);
+ mpi_ct.comm.Bcast (&opt_trace, 1, MPI::INT, 0);
+ mpi_ct.comm.Bcast (&opt_filter, 1, MPI::INT, 0);
+ mpi_ct.comm.Bcast (&opt_interp, 1, MPI::INT, 0);
+ mpi_ct.comm.Bcast (&opt_filter_param, 1, MPI::DOUBLE, 0);
+ mpi_ct.comm.Bcast (&opt_interp_param, 1, MPI::INT, 0);
+ mpi_ct.comm.Bcast (&opt_backproj, 1, MPI::INT, 0);
+ mpi_ct.comm.Bcast (&mpi_ndet, 1, MPI::INT, 0);
+ mpi_ct.comm.Bcast (&mpi_nview, 1, MPI::INT, 0);
+ mpi_ct.comm.Bcast (&mpi_detinc, 1, MPI::DOUBLE, 0);
+ mpi_ct.comm.Bcast (&mpi_phmlen, 1, MPI::DOUBLE, 0);
+ mpi_ct.comm.Bcast (&mpi_rotinc, 1, MPI::DOUBLE, 0);
+ mpi_ct.comm.Bcast (&nx, 1, MPI::INT, 0);
+ mpi_ct.comm.Bcast (&ny, 1, MPI::INT, 0);
if (opt_verbose) {
- mpi_t2 = MPI_Wtime();
+ mpi_t2 = MPI::Wtime();
mpi_t = mpi_t2 - mpi_t1;
- MPI_Reduce(&mpi_t, &mpi_t_g, 1, MPI_DOUBLE, MPI_MAX, 0, mpi_ct.comm);
+ mpi_ct.comm.Reduce(&mpi_t, &mpi_t_g, 1, MPI::DOUBLE, MPI::MAX, 0);
if (mpi_ct.my_rank == 0)
printf("Time to Bcast vars = %f secs, Max time = %f\n", mpi_t, mpi_t_g);
}
rs_local->rot_inc = mpi_rotinc;
if (opt_verbose)
- mpi_t1 = MPI_Wtime();
+ mpi_t1 = MPI::Wtime();
mpi_scatter_rs(rs_global, rs_local, opt_debug);
if (opt_verbose) {
- mpi_t2 = MPI_Wtime();
+ mpi_t2 = MPI::Wtime();
mpi_t = mpi_t2 - mpi_t1;
- MPI_Reduce(&mpi_t, &mpi_t_g, 1, MPI_DOUBLE, MPI_MAX, 0, mpi_ct.comm);
+ mpi_ct.comm.Reduce(&mpi_t, &mpi_t_g, 1, MPI::DOUBLE, MPI::MAX, 0);
if (mpi_ct.my_rank == 0)
printf("Time to scatter rs = %f secs, Max time = %f sec\n", mpi_t, mpi_t_g);
}
#endif
-#ifdef MPI_CT
- mpi_t1 = MPI_Wtime();
+#ifdef HAVE_MPI
+ mpi_t1 = MPI::Wtime();
proj_reconst (*im_local, rs_local, opt_filter, opt_filter_param,
opt_interp, opt_interp_param, opt_backproj, opt_trace);
- mpi_t2 = MPI_Wtime();
+ mpi_t2 = MPI::Wtime();
mpi_t = mpi_t2 - mpi_t1;
- MPI_Reduce(&mpi_t, &mpi_t_g, 1, MPI_DOUBLE, MPI_MAX, 0, mpi_ct.comm);
+ mpi_ct.comm.Reduce(&mpi_t, &mpi_t_g, 1, MPI::DOUBLE, MPI::MAX, 0);
if (mpi_ct.my_rank == 0 && opt_verbose)
printf("Time to reconstruct = %f, Max time = %f\n", mpi_t, mpi_t_g);
#else
opt_interp, opt_interp_param, opt_backproj, opt_trace);
#endif
-#ifdef MPI_CT
+#ifdef HAVE_MPI
if (opt_verbose)
- mpi_t1 = MPI_Wtime();
+ mpi_t1 = MPI::Wtime();
int nxLocal = im_local->adf.nx();
int nyLocal = im_local->adf.ny();
if (mpi_ct.my_rank == 0)
recvbuf = vGlobal[ix];
- MPI_Reduce(vLocal[ix], recvbuf, nyLocal, MPI_FLOAT, MPI_SUM, 0, mpi_ct.comm);
+ mpi_ct.comm.Reduce(vLocal[ix], recvbuf, nyLocal, MPI::FLOAT, MPI::SUM, 0);
}
if (opt_verbose) {
- mpi_t2 = MPI_Wtime();
+ mpi_t2 = MPI::Wtime();
mpi_t = mpi_t2 - mpi_t1;
- MPI_Reduce(&mpi_t, &mpi_t_g, 1, MPI_DOUBLE, MPI_MAX, 0, mpi_ct.comm);
+ mpi_ct.comm.Reduce (&mpi_t, &mpi_t_g, 1, MPI::DOUBLE, MPI::MAX, 0);
if (mpi_ct.my_rank == 0)
printf("Time to reduce image = %f secs, max time = %f\n", mpi_t, mpi_t_g);
}
if (mpi_ct.my_rank == 0)
- time_end = MPI_Wtime();
+ time_end = MPI::Wtime();
#else
time_end = td_current_sec();
#endif
-#ifdef MPI_CT
+#ifdef HAVE_MPI
if (mpi_ct.my_rank == 0)
#endif
{
cout << "Time active = " << calctime << " sec" << endl;
}
-#ifdef MPI_CT
- MPI_Finalize();
+#ifdef HAVE_MPI
+ MPI::Finalize();
#endif
return (0);
}
-#ifdef MPI_CT
+#ifdef HAVE_MPI
static void mpi_scatter_rs (RAYSUM *rs_global, RAYSUM *rs_local, const int opt_debug)
{
int iproc;
end_work_unit = mpi_ct.start_work_unit[iproc] + mpi_ct.local_work_units[iproc] - 1;
for (iw = mpi_ct.start_work_unit[iproc]; iw <= end_work_unit; iw++) {
- MPI_Send(&rs_global->view[iw]->ndet, 1, MPI_INT, iproc, 0, mpi_ct.comm);
- MPI_Send(&rs_global->view[iw]->view_angle, 1, MPI_DOUBLE, iproc, 0, mpi_ct.comm);
- MPI_Send(rs_global->view[iw]->detval, rs_global->ndet, MPI_FLOAT, iproc, 0, mpi_ct.comm);
+ mpi_ct.comm.Send(&rs_global->view[iw]->ndet, 1, MPI::INT, iproc, 0);
+ mpi_ct.comm.Send(&rs_global->view[iw]->view_angle, 1, MPI::DOUBLE, iproc, 0);
+ mpi_ct.comm.Send(rs_global->view[iw]->detval, rs_global->ndet, MPI::FLOAT, iproc, 0);
}
}
}
end_work_unit = mpi_ct.local_work_units[mpi_ct.my_rank] - 1;
for (iw = 0; iw <= end_work_unit; iw++) {
- MPI_Status status;
+ MPI::Status status;
- MPI_Recv(&rs_local->view[iw]->ndet, 1, MPI_INT, 0, 0, mpi_ct.comm, &status);
- MPI_Recv(&rs_local->view[iw]->view_angle, 1, MPI_DOUBLE, 0, 0, mpi_ct.comm, &status);
- MPI_Recv(rs_local->view[iw]->detval, rs_local->ndet, MPI_FLOAT, 0, 0, mpi_ct.comm, &status);
+ mpi_ct.comm.Recv(&rs_local->view[iw]->ndet, 1, MPI::INT, 0, 0, status);
+ mpi_ct.comm.Recv(&rs_local->view[iw]->view_angle, 1, MPI::DOUBLE, 0, 0, status);
+ mpi_ct.comm.Recv(rs_local->view[iw]->detval, rs_local->ndet, MPI::FLOAT, 0, 0, status);
}
rs_local->nview = mpi_ct.local_work_units[mpi_ct.my_rank];
if (opt_debug) {
- MPI_Barrier(MPI_COMM_WORLD);
+ mpi_ct.comm.Barrier();
fprintf(stdout, "Done with mpi_scatter_rs in process %2d\n", mpi_ct.my_rank);
}
}