** This is part of the CTSim program
** Copyright (C) 1983-2000 Kevin Rosenberg
**
-** $Id: ct.h,v 1.10 2000/06/07 07:43:39 kevin Exp $
+** $Id: ct.h,v 1.11 2000/06/07 10:12:09 kevin Exp $
** $Log: ct.h,v $
+** Revision 1.11 2000/06/07 10:12:09 kevin
+** Upgraded from MPI to MPI++
+**
** Revision 1.10 2000/06/07 07:43:39 kevin
** *** empty log message ***
**
#include <stdint.h> /* Standard ints on Linux */
#endif
-#ifdef MPI_CT
-#include "mpi.h"
+#ifdef HAVE_MPI
+#include "mpi++.h"
#endif
#include "kstddef.h"
#include <string>
#include "kstddef.h"
+#include <sys/types.h>
+#include <unistd.h>
#include <array2d.h>
using namespace std;
kuint32 ny(void) const
{ return adf.ny(); }
-#ifdef MPI_CT
- MPI_Datatype getMPIDataType (void) const
- { return MPI_FLOAT; }
+#ifdef HAVE_MPI
+ MPI::Datatype getMPIDataType (void) const
+ { return MPI::FLOAT; }
#endif
};
+
class F64Image
{
public:
Array2dFile<kfloat64> adf;
-#ifdef MPI_CT
- MPI_Datatype getMPIDataType (void) const
- { return MPI_DOUBLE; }
+#ifdef HAVE_MPI
+ MPI::Datatype getMPIDataType (void) const
+ { return MPI::DOUBLE; }
#endif
F64Image (const char* const fname, unsigned int nx, unsigned int ny) : adf (fname, nx, ny)
** This is part of the CTSim program
** Copyright (C) 1983-2000 Kevin Rosenberg
**
-** $Id: ir.h,v 1.22 2000/06/07 07:43:39 kevin Exp $
+** $Id: ir.h,v 1.23 2000/06/07 10:12:09 kevin Exp $
** $Log: ir.h,v $
+** Revision 1.23 2000/06/07 10:12:09 kevin
+** Upgraded from MPI to MPI++
+**
** Revision 1.22 2000/06/07 07:43:39 kevin
** *** empty log message ***
**
extern "C" {
#endif /* __cplusplus */
-#ifdef MPI_CT
-#define MPI_MAX_PROCESS 128
+#ifdef HAVE_MPI
+#define CT_MPI_MAX_PROCESS 128
struct mpi_ct_st
{
int my_rank;
int nproc;
int base_local_work_units;
int remainder_work_units;
- int local_work_units[MPI_MAX_PROCESS];
- int start_work_unit[MPI_MAX_PROCESS];
- MPI_Comm comm;
+ int local_work_units [CT_MPI_MAX_PROCESS];
+ int start_work_unit [CT_MPI_MAX_PROCESS];
+ MPI::Intracomm comm;
};
extern struct mpi_ct_st mpi_ct;
#endif
-/* bspline.c */
-int bspline(int samples, int zoom_factor, int spline_order, double input[], double output[]);
-
/* convolve.c */
-double convolve(const double f1[], const double f2[], const double dx, const int n, const int np, const FunctionSymmetry func_type);
-double convolve_both(const double f1[], const double f2[], const double dx, const int n, const int np);
+double convolve (const double f1[], const double f2[], const double dx, const int n, const int np, const FunctionSymmetry func_type);
+double convolve_both (const double f1[], const double f2[], const double dx, const int n, const int np);
/* dialogs.c */
-int phm_add_pelm_kb(PHANTOM *phm);
-PHANTOM *phm_select(void);
-int interpolation_select(void);
-int filter_select(double *filter_param);
+int phm_add_pelm_kb (PHANTOM *phm);
+PHANTOM *phm_select (void);
+int interpolation_select (void);
+int filter_select (double *filter_param);
/* filter.c */
-double *filter_generate(const FilterType filt_type, double bw, double xmin, double xmax, int n, double param, const DomainType domain, int numint);
-double filter_spatial_response_calc(int filt_type, double x, double bw, double param, int n);
-double filter_spatial_response_analytic(int filt_type, double x, double bw, double param);
-double filter_frequency_response(int filt_type, double u, double bw, double param);
-double sinc(double x, double mult);
+double *filter_generate (const FilterType filt_type, double bw, double xmin, double xmax, int n, double param, const DomainType domain, int numint);
+double filter_spatial_response_calc (int filt_type, double x, double bw, double param, int n);
+double filter_spatial_response_analytic (int filt_type, double x, double bw, double param);
+double filter_frequency_response (int filt_type, double u, double bw, double param);
+double sinc (double x, double mult);
double integral_abscos(double u, double w);
/* options.c */
void raysum_trace_show_param (const char *label, const char *fmt, int row, int color, ...);
/* scanner.c */
-DETECTOR *detector_create(const PHANTOM *phm, int geometry, int ndet, int nview, int nsample, const double rot_anglen);
+DETECTOR *detector_create(const PHANTOM *phm, const ScannerGeometry geometry, int ndet, int nview, int nsample, const double rot_anglen);
void detector_free(DETECTOR *det);
/* rayio.c */
if USE_LAM
CC_LAM = $(lamdir)/bin/balky
+LAM_EXTRA_SRC = ../libir/mpi_ct.cpp
ctrec-lam: ctrec.cpp
- $(CC_LAM) @DEFS@ $(CFLAGS) $(INCLUDES) -DMPI_CT ctrec.cpp -o ctrec-lam $(LDFLAGS) @ctlamlibs@
+ $(CC_LAM) @DEFS@ $(CFLAGS) $(INCLUDES) -DHAVE_MPI ctrec.cpp -o ctrec-lam $(LDFLAGS) $(LAM_EXTRA_SRC) @ctlibs@
phm2rs-lam: phm2rs.cpp
- $(CC_LAM) @DEFS@ $(CFLAGS) $(INCLUDES) -DMPI_CT phm2rs.cpp -o phm2rs-lam $(LDFLAGS) @ctlamlibs@
+ $(CC_LAM) @DEFS@ $(CFLAGS) $(INCLUDES) -DHAVE_MPI phm2rs.cpp -o phm2rs-lam $(LDFLAGS) $(LAM_EXTRA_SRC) @ctlibs@
phm2if-lam: phm2if.cpp
- $(CC_LAM) @DEFS@ $(CFLAGS) $(INCLUDES) -DMPI_CT phm2if.cpp -o phm2if-lam $(LDFLAGS) @ctlamlibs@
+ $(CC_LAM) @DEFS@ $(CFLAGS) $(INCLUDES) -DHAVE_MPI phm2if.cpp -o phm2if-lam $(LDFLAGS) $(LAM_EXTRA_SRC) @ctlibs@
endif
-# Makefile for libk\r
-\r
-!include <ntwin32.mak>\r
-\r
-CC=cl\r
-LD=link\r
-CFLAGS=-O -nologo -I..\include -I..\getopt -DHAVE_GETOPT_H\r
-LDFLAGS=..\getopt\getopt.lib ..\libkmath\libkmath.lib ..\libcio\libcio.lib ..\libgraph\libgraph.lib ..\libezplot\libezplot.lib ..\libir\libir.lib ..\libk\libk.lib \r
-O=.obj\r
-\r
-# variables\r
-OBJ1 = ctrec$(O) phm2rs$(O) phm2sdf$(O) rs2sdf$(O) sdf-1$(O) sdf-2$(O) sdf2img$(O) sdfinfo$(O)\r
-\r
-all: ctrec.exe phm2rs.exe phm2sdf.exe rs2sdf.exe sdf-1.exe sdf-2.exe sdf2img.exe sdfinfo.exe\r
-\r
-.obj: .c\r
- $(CC) -c $(cvarsdll) $(CFLAGS) $*.c\r
-\r
-\r
-.obj: .cpp\r
- $(CC) -c $(cvarsdll) $(CFLAGS) $*.cpp\r
-\r
-\r
-ctrec.exe: ctrec.obj\r
- link ctrec.obj $(LDFLAGS)\r
-\r
-phm2rs.exe: phm2rs.obj\r
- link phm2rs.obj $(LDFLAGS)\r
-\r
-phm2sdf.exe: phm2sdf.obj\r
- link phm2sdf.obj $(LDFLAGS)\r
-\r
-rs2sdf.exe: rs2sdf.obj\r
- link rs2sdf.obj $(LDFLAGS)\r
-\r
-sdf-1.exe: sdf-1.obj\r
- link sdf-1.obj $(LDFLAGS)\r
-\r
-sdf-2.exe: sdf-2.obj\r
- link sdf-2.obj $(LDFLAGS)\r
-\r
-sdfinfo.exe: sdfinfo.obj\r
- link sdfinfo.obj $(LDFLAGS)\r
-\r
-sdf2img.exe: sdf2img.obj\r
- link sdf2img.obj $(LDFLAGS)\r
-\r
-clean:\r
- echo dummy > a.obj\r
- echo dummy > a.exe\r
- echo dummy > a.lib\r
- del *.obj\r
- del *.exe\r
- del *.lib\r
+# Makefile for libk
+
+!include <ntwin32.mak>
+
+CC=cl
+LD=link
+CFLAGS=-O -nologo -I..\include -I..\getopt -DHAVE_GETOPT_H
+LDFLAGS=..\getopt\getopt.lib ..\libkmath\libkmath.lib ..\libcio\libcio.lib ..\libgraph\libgraph.lib ..\libezplot\libezplot.lib ..\libir\libir.lib ..\libk\libk.lib
+O=.obj
+
+# variables
+OBJ1 = ctrec$(O) phm2rs$(O) phm2if$(O) rs2if$(O) if-1$(O) if-2$(O) if2img$(O) ifinfo$(O)
+
+all: ctrec.exe phm2rs.exe phm2if.exe rs2if.exe if-1.exe if-2.exe if2img.exe ifinfo.exe
+
+.obj: .c
+ $(CC) -c $(cvarsdll) $(CFLAGS) $*.c
+
+.obj: .cpp
+ $(CC) -c $(cvarsdll) $(CFLAGS) $*.cpp
+
+
+ctrec.exe: ctrec.obj
+ link ctrec.obj $(LDFLAGS)
+
+phm2rs.exe: phm2rs.obj
+ link phm2rs.obj $(LDFLAGS)
+
+phm2if.exe: phm2if.obj
+ link phm2if.obj $(LDFLAGS)
+
+rs2if.exe: rs2if.obj
+ link rs2if.obj $(LDFLAGS)
+
+if-1.exe: if-1.obj
+ link if-1.obj $(LDFLAGS)
+
+if-2.exe: if-2.obj
+ link if-2.obj $(LDFLAGS)
+
+ifinfo.exe: ifinfo.obj
+ link ifinfo.obj $(LDFLAGS)
+
+if2img.exe: if2img.obj
+ link if2img.obj $(LDFLAGS)
+
+clean:
+ echo dummy > a.obj
+ echo dummy > a.exe
+ echo dummy > a.lib
+ del *.obj
+ del *.exe
+ del *.lib
** 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);
}
}
** This is part of the CTSim program
** Copyright (C) 1983-2000 Kevin Rosenberg
**
-** $Id: phm2if.cpp,v 1.3 2000/06/07 07:43:19 kevin Exp $
+** $Id: phm2if.cpp,v 1.4 2000/06/07 10:12:05 kevin Exp $
** $Log: phm2if.cpp,v $
+** Revision 1.4 2000/06/07 10:12:05 kevin
+** Upgraded from MPI to MPI++
+**
** Revision 1.3 2000/06/07 07:43:19 kevin
** Converted to IF data files and C++
**
fprintf(stdout," --help Print this help message\n");
}
-#ifdef MPI_CT
+#ifdef HAVE_MPI
void mpi_gather_image (ImageFile& im_global, ImageFile& im_local, const int opt_debug);
#endif
int opt_trace = TRACE_NONE;
int opt_verbose = 0;
double time_start=0, time_end=0;
-#ifdef MPI_CT
+#ifdef HAVE_MPI
ImageFile* im_local = NULL;
int mpi_argc = argc;
char **mpi_argv = (char **) argv;
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);
}
#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
case O_PHMFILE:
strncpy(opt_phmfilename, optarg, sizeof(opt_phmfilename));
phm = phm_create_from_file(opt_phmfilename);
-#ifdef MPI_CT
+#ifdef HAVE_MPI
if (mpi_ct.my_rank == 0)
fprintf(stderr, "Can't use phantom from file in MPI mode\n");
return (1);
if (opt_verbose)
printf("Rasterize Phantom to Image\n\n");
-#ifdef MPI_CT
+#ifdef HAVE_MPI
}
#endif
-#ifdef MPI_CT
- 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_nx, 1, MPI_INT, 0, mpi_ct.comm);
- MPI_Bcast(&opt_ny, 1, MPI_INT, 0, mpi_ct.comm);
- MPI_Bcast(&opt_nsample, 1, MPI_INT, 0, mpi_ct.comm);
- MPI_Bcast(&opt_phmnum, 1, MPI_INT, 0, mpi_ct.comm);
- MPI_Bcast(&opt_filter, 1, MPI_INT, 0, mpi_ct.comm);
- MPI_Bcast(&opt_filter_domain, 1, MPI_INT, 0, mpi_ct.comm);
- MPI_Bcast(&opt_filter_param, 1, MPI_DOUBLE, 0, mpi_ct.comm);
- MPI_Bcast(&opt_filter_bw, 1, MPI_DOUBLE, 0, mpi_ct.comm);
+#ifdef HAVE_MPI
+ 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_nx, 1, MPI::INT, 0);
+ mpi_ct.comm.Bcast (&opt_ny, 1, MPI::INT, 0);
+ mpi_ct.comm.Bcast (&opt_nsample, 1, MPI::INT, 0);
+ mpi_ct.comm.Bcast (&opt_phmnum, 1, MPI::INT, 0);
+ mpi_ct.comm.Bcast (&opt_filter, 1, MPI::INT, 0);
+ mpi_ct.comm.Bcast (&opt_filter_domain, 1, MPI::INT, 0);
+ mpi_ct.comm.Bcast (&opt_filter_param, 1, MPI::DOUBLE, 0);
+ mpi_ct.comm.Bcast (&opt_filter_bw, 1, MPI::DOUBLE, 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);
}
if (opt_phmnum >= 0)
phm = phm_create (opt_phmnum);
-#ifdef MPI_CT
+#ifdef HAVE_MPI
else {
if (mpi_ct.my_rank == 0)
fprintf(stderr, "phmnum < 0\n");
ImageFileArray v = im_global->getArray ();
double calctime = 0;
-#ifdef MPI_CT
+#ifdef HAVE_MPI
if (phm->type == P_UNIT_PULSE) {
if (mpi_ct.my_rank == 0) {
v[opt_nx/2][opt_ny/2] = 1.;
}
} else {
if (opt_verbose)
- mpi_t1 = MPI_Wtime();
+ mpi_t1 = MPI::Wtime();
phm_to_imagefile (phm, *im_local, mpi_ct.start_work_unit[mpi_ct.my_rank], mpi_ct.local_work_units[mpi_ct.my_rank], opt_nsample, opt_trace);
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 compile phm = %f secs, Max time = %f\n", mpi_t, mpi_t_g);
}
}
#endif
-#ifdef MPI_CT
- time_end = MPI_Wtime();
+#ifdef HAVE_MPI
+ time_end = MPI::Wtime();
#else
time_end = td_current_sec();
#endif
-#ifdef MPI_CT
+#ifdef HAVE_MPI
if (mpi_ct.my_rank == 0)
#endif
{
-#ifdef MPI_CT
+#ifdef HAVE_MPI
void mpi_gather_image (ImageFile& im_global, ImageFile& im_local, const int opt_debug)
{
ImageFileArray vLocal = im_local.getArray();
int end_work_unit = mpi_ct.local_work_units[mpi_ct.my_rank] - 1;
for (int iw = 0; iw <= end_work_unit; iw++) {
- MPI_Send(vLocal[iw], nyLocal, im_local.getMPIDataType(), 0, 0, mpi_ct.comm);
+ mpi_ct.comm.Send(vLocal[iw], nyLocal, im_local.getMPIDataType(), 0, 0);
}
if (mpi_ct.my_rank == 0) {
}
for (int iw = mpi_ct.start_work_unit[iproc]; iw <= end_work_unit; iw++) {
- MPI_Status status;
- MPI_Recv(vGlobal[iw], nyGlobal, MPI_FLOAT, iproc, 0, mpi_ct.comm, &status);
+ MPI::Status status;
+ mpi_ct.comm.Recv(vGlobal[iw], nyGlobal, MPI::FLOAT, iproc, 0, status);
}
}
}
** 1984 -- Final DOS version
** 1999 -- First UNIX version
**
-** $Id: phm2rs.cpp,v 1.1 2000/06/07 02:29:05 kevin Exp $
+** $Id: phm2rs.cpp,v 1.2 2000/06/07 10:12:05 kevin Exp $
** $Log: phm2rs.cpp,v $
+** Revision 1.2 2000/06/07 10:12:05 kevin
+** Upgraded from MPI to MPI++
+**
** Revision 1.1 2000/06/07 02:29:05 kevin
** Initial C++ versions
**
void
phm2rs_usage (const char *program)
{
-#ifdef MPI_CT
+#ifdef HAVE_MPI
if (mpi_ct.my_rank == 0)
{
#endif
fprintf(stdout," --debug Debug mode\n");
fprintf(stdout," --version Print version\n");
fprintf(stdout," --help Print this help message\n");
-#ifdef MPI_CT
+#ifdef HAVE_MPI
}
- MPI_Abort(mpi_ct.comm, 1);
+ mpi_ct.comm.Abort(1);
#endif
}
-#ifdef MPI_CT
+#ifdef HAVE_MPI
void mpi_gather_rs (RAYSUM *rs_global, RAYSUM *rs_local, const int opt_debug);
#endif
double opt_rotangle = 1;
double time_start = 0, time_end = 0;
-#ifndef MPI_CT
+#ifndef HAVE_MPI
time_start = td_current_sec();
#else
RAYSUM *rs_local;
char **mpi_argv = (char **) argv;
double mpi_t1 = 0, mpi_t2 = 0, 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) {
- sys_error(ERR_FATAL, "Number of mpi processes (%d) exceeds max processes (%d)", mpi_ct.nproc, MPI_MAX_PROCESS);
- exit(1);
+ if (mpi_ct.nproc > CT_MPI_MAX_PROCESS) {
+ sys_error(ERR_FATAL, "Number of mpi processes (%d) exceeds max processes (%d)",
+ mpi_ct.nproc, CT_MPI_MAX_PROCESS);
}
- time_start = MPI_Wtime();
+
+ time_start = MPI::Wtime();
#endif
-#ifdef MPI_CT
+#ifdef HAVE_MPI
if (mpi_ct.my_rank == 0) {
#endif
strcpy(opt_desc, "");
phm = phm_create (opt_phmnum);
break;
case O_PHMFILE:
-#ifdef MPI_CT
+#ifdef HAVE_MPI
if (mpi_ct.my_rank == 0)
fprintf(stderr, "Can not read phantom from file in MPI mode\n");
return (1);
strncat(str, opt_desc, sizeof(str));
}
strncpy(opt_desc, str, sizeof(opt_desc));
-#ifdef MPI_CT
+#ifdef HAVE_MPI
}
#endif
-#ifdef MPI_CT
- MPI_Barrier(mpi_ct.comm);
- MPI_Bcast(&opt_rotangle, 1, MPI_DOUBLE, 0, mpi_ct.comm);
- MPI_Bcast(&opt_nview, 1, MPI_INT, 0, mpi_ct.comm);
- MPI_Bcast(&opt_ndet, 1, MPI_INT, 0, mpi_ct.comm);
- MPI_Bcast(&opt_nray, 1, MPI_INT, 0, mpi_ct.comm);
- MPI_Bcast(&opt_phmnum, 1, MPI_INT, 0, mpi_ct.comm);
- 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);
+#ifdef HAVE_MPI
+ mpi_ct.comm.Barrier ();
+ mpi_ct.comm.Bcast (&opt_rotangle, 1, MPI::DOUBLE, 0);
+ mpi_ct.comm.Bcast (&opt_nview, 1, MPI::INT, 0);
+ mpi_ct.comm.Bcast (&opt_ndet, 1, MPI::INT, 0);
+ mpi_ct.comm.Bcast (&opt_nray, 1, MPI::INT, 0);
+ mpi_ct.comm.Bcast (&opt_phmnum, 1, MPI::INT, 0);
+ 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);
if (mpi_ct.my_rank > 0 && opt_phmnum >= 0)
phm = phm_create (opt_phmnum);
opt_rotangle *= PI;
det = detector_create (phm, DETECTOR_PARALLEL, opt_ndet, opt_nview, opt_nray, opt_rotangle);
-#ifdef MPI_CT
+#ifdef HAVE_MPI
mpi_ct_calc_work_units(opt_nview);
if (mpi_ct.my_rank == 0) {
rs_global = raysum_create_from_det (opt_outfile, det);
printf("rs_local->nview = %d (process %d)\n", rs_local->nview, mpi_ct.my_rank);
if (opt_verbose)
- mpi_t1 = MPI_Wtime();
+ mpi_t1 = MPI::Wtime();
raysum_collect (rs_local, det, phm, mpi_ct.start_work_unit[mpi_ct.my_rank], opt_trace, FALSE);
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 collect rs = %f secs, Max = %f secs\n", mpi_t, mpi_t_g);
}
if (opt_verbose)
- mpi_t1 = MPI_Wtime();
+ mpi_t1 = MPI::Wtime();
mpi_gather_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 gather rs = %f secs, Max = %f secs\n", mpi_t, mpi_t_g);
}
raysum_collect (rs_global, det, phm, 0, opt_trace, FALSE);
#endif
-#ifndef MPI_CT
+#ifndef HAVE_MPI
time_end = td_current_sec();
#else
- time_end = MPI_Wtime();
+ time_end = MPI::Wtime();
if (mpi_ct.my_rank == 0)
#endif
{
}
}
-#ifdef MPI_CT
+#ifdef HAVE_MPI
if (mpi_ct.my_rank == 0)
#endif
{
* Gather's raysums from all processes in rs_local in rs_global in process 0
*/
-#ifdef MPI_CT
+#ifdef HAVE_MPI
void mpi_gather_rs (RAYSUM *rs_global, RAYSUM *rs_local, const int opt_debug)
{
int iproc;
end_work_unit = mpi_ct.local_work_units[mpi_ct.my_rank] - 1;
for (iw = 0; iw <= end_work_unit; iw++) {
- MPI_Send(&rs_local->view[iw]->view_angle, 1, MPI_DOUBLE, 0, 0, mpi_ct.comm);
- MPI_Send(&rs_local->view[iw]->ndet, 1, MPI_INT, 0, 0, mpi_ct.comm);
- MPI_Send(rs_local->view[iw]->detval, rs_local->ndet, MPI_FLOAT, 0, 0, mpi_ct.comm);
+ mpi_ct.comm.Send(&rs_local->view[iw]->view_angle, 1, MPI::DOUBLE, 0, 0);
+ mpi_ct.comm.Send(&rs_local->view[iw]->ndet, 1, MPI::INT, 0, 0);
+ mpi_ct.comm.Send(rs_local->view[iw]->detval, rs_local->ndet, MPI::FLOAT, 0, 0);
}
if (mpi_ct.my_rank == 0) {
fprintf(stdout, "Recv rs data from process %d\n", iproc);
for (iw = mpi_ct.start_work_unit[iproc]; iw <= end_work_unit; iw++) {
- MPI_Status status;
+ MPI::Status status;
- MPI_Recv(&rs_global->view[iw]->view_angle, 1, MPI_DOUBLE, iproc, 0, mpi_ct.comm, &status);
- MPI_Recv(&rs_global->view[iw]->ndet, 1, MPI_INT, iproc, 0, mpi_ct.comm, &status);
- MPI_Recv(rs_global->view[iw]->detval, rs_global->ndet, MPI_FLOAT, iproc, 0, mpi_ct.comm, &status);
+ mpi_ct.comm.Recv(&rs_global->view[iw]->view_angle, 1, MPI::DOUBLE, iproc, 0, status);
+ mpi_ct.comm.Recv(&rs_global->view[iw]->ndet, 1, MPI::INT, iproc, 0, status);
+ mpi_ct.comm.Recv(rs_global->view[iw]->detval, rs_global->ndet, MPI::FLOAT, iproc, 0, status);
}
}
}