** This is part of the CTSim program
** Copyright (C) 1983-2000 Kevin Rosenberg
**
-** $Id: ctrec.c,v 1.3 2000/04/30 04:06:13 kevin Exp $
+** $Id: ctrec.c,v 1.6 2000/05/02 15:31:47 kevin Exp $
** $Log: ctrec.c,v $
+** Revision 1.6 2000/05/02 15:31:47 kevin
+** code cleaning
+**
+** Revision 1.5 2000/04/30 11:41:06 kevin
+** Cleaned up debugging code
+**
+** Revision 1.4 2000/04/30 10:13:27 kevin
+** Fixed MPI bugs
+**
** Revision 1.3 2000/04/30 04:06:13 kevin
** Update Raysum i/o routines
** Fix MPI bug in ctrec (scatter_raysum) that referenced rs_global
if (opt_filter == W_G_HAMMING || opt_filter == W_AG_HAMMING)
sprintf (filt_name, "%s: alpha = %.2f",
- filter_name_of (opt_filter), opt_filter_param);
+ name_of_filter (opt_filter), opt_filter_param);
else
- sprintf (filt_name, "%s", filter_name_of (opt_filter));
+ sprintf (filt_name, "%s", name_of_filter (opt_filter));
sprintf (remark,
"Reconstruct: %dx%d, %s, %s, %s",
- nx, ny, filt_name, interp_name_of (opt_interp), name_of_backproj(opt_backproj));
+ nx, ny, filt_name, name_of_interpolation (opt_interp), name_of_backproj(opt_backproj));
if (opt_verbose)
fprintf (stdout, "%s\n", remark);
if (mpi_ct.my_rank == 0) {
rs_global = raysum_open (rs_name);
raysum_read (rs_global);
- print_raysum_info(rs_global);
- if (opt_verbose) {
- printf ("Number of detectors: %d\n", rs_global->ndet);
- printf (" Number of views: %d\n", rs_global->nview);
- printf (" Remark: %s\n", rs_global->remark);
- }
-
+ if (opt_verbose)
+ print_raysum_info(rs_global);
+
mpi_ndet = rs_global->ndet;
mpi_nview = rs_global->nview;
mpi_detinc = rs_global->det_inc;
mpi_ct_calc_work_units(mpi_nview);
- if (opt_debug) {
- fprintf(stdout, "Calc'd local work units process %d: nviews=%d, local_work_units=%d, start_work_units=%d\n",
- mpi_ct.my_rank, mpi_nview, mpi_ct.local_work_units[mpi_ct.my_rank], mpi_ct.start_work_unit[mpi_ct.my_rank]);
- MPI_Barrier(mpi_ct.comm);
- }
-
rs_local = raysum_create (NULL, mpi_ct.local_work_units[mpi_ct.my_rank], mpi_ndet);
- if (opt_debug) {
- fprintf(stdout, "Created rs_local %lx for process %d: local views=%4d, local dets=%4d\n", (unsigned long int) rs_local, mpi_ct.my_rank, mpi_ct.local_work_units[mpi_ct.my_rank], mpi_ndet);
- MPI_Barrier(mpi_ct.comm);
- }
rs_local->ndet = mpi_ndet;
rs_local->nview = mpi_nview;
#else
rs_global = raysum_open (rs_name);
raysum_read (rs_global);
- if (opt_debug)
+ if (opt_verbose)
print_raysum_info(rs_global);
im_global = image_create (im_filename, nx, ny);
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);
- if (mpi_ct.my_rank == 0) {
+ if (mpi_ct.my_rank == 0 && opt_verbose)
printf("Time to reconstruct = %f, Max time = %f\n", mpi_t, mpi_t_g);
- }
#else
image_reconst (im_global, rs_global, opt_filter, opt_filter_param,
opt_interp, opt_interp_param, opt_backproj, opt_trace);
if (opt_verbose)
mpi_t1 = MPI_Wtime();
+
for (ix = 0; ix < im_local->nx; ix++) {
- MPI_Reduce(im_local->v[ix], im_global->v[ix],
- im_local->ny, MPI_FLOAT, MPI_SUM, 0, mpi_ct.comm);
+ void *recvbuf = NULL;
+ if (mpi_ct.my_rank == 0)
+ recvbuf = im_global->v[ix];
+
+ MPI_Reduce(im_local->v[ix], recvbuf, im_local->ny, MPI_FLOAT, MPI_SUM, 0, mpi_ct.comm);
}
+
if (opt_verbose) {
mpi_t2 = MPI_Wtime();
mpi_t = mpi_t2 - mpi_t1;
}
if (mpi_ct.my_rank == 0) {
strncpy (im_global->remark, remark, MAXREMARK);
- image_save (im_global);
time_end = MPI_Wtime();
im_global->calctime = time_end - time_start;
+ image_save (im_global);
if (opt_verbose)
fprintf (stdout, "Time active = %.2f\n", im_global->calctime);
}
#else
raysum_close (rs_global);
strncpy (im_global->remark, remark, MAXREMARK);
- image_save (im_global);
-
time_end = td_current_sec();
im_global->calctime = time_end - time_start;
+ image_save (im_global);
if (opt_verbose)
fprintf (stdout, "Time active = %.2f secs\n", im_global->calctime);
#endif
if (mpi_ct.my_rank == 0) {
for (iproc = 0; iproc < mpi_ct.nproc; iproc++) {
- end_work_unit = mpi_ct.start_work_unit[iproc]
- + mpi_ct.local_work_units[iproc]
- - 1;
-
- if (opt_debug)
- fprintf(stdout, "Sending rs data to process %d\n", 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++) {
- if (opt_debug)
- fprintf(stdout, "Sending from process %2d to process %2d: view_angle=%8f, ndet=%5d\n", mpi_ct.my_rank, iproc, rs_global->view[iw]->view_angle, rs_global->view[iw]->ndet);
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);
}
}
- if (opt_debug) {
+ if (opt_debug)
fprintf(stdout, "Receiving rs data in process %d\n", mpi_ct.my_rank);
- MPI_Barrier(mpi_ct.comm);
- }
end_work_unit = mpi_ct.local_work_units[mpi_ct.my_rank] - 1;
for (iw = 0; iw <= end_work_unit; iw++) {
MPI_Status status;
- if (opt_debug) {
- fprintf(stdout,"Receiving into rs_local from mpi_scatter_rs, process %2d: rs_local=%lx, ", mpi_ct.my_rank, (unsigned long int) rs_local);
- fprintf(stdout,"iw=%4d, nrot=%4d, ndet=%4d, view=%lx, detval=%lx\n", iw, rs_local->nview, rs_local->ndet, (unsigned long int) rs_local->view[iw], (unsigned long int) rs_local->view[iw]->detval);
- }
-
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);
-
- if (opt_debug) {
- fprintf(stdout, "Received view_angle=%8f, ndet=%5d\n", rs_local->view[iw]->view_angle, rs_local->view[iw]->ndet);
- }
}
rs_local->nview = mpi_ct.local_work_units[mpi_ct.my_rank];
if (opt_debug) {
MPI_Barrier(MPI_COMM_WORLD);
fprintf(stdout, "Done with mpi_scatter_rs in process %2d\n", mpi_ct.my_rank);
- exit(0);
}
}
printf ("Number of detectors: %d\n", rs->ndet);
printf (" Number of views: %d\n", rs->nview);
printf (" Remark: %s\n", rs->remark);
- printf ("Piclen: %f\n", rs->piclen);
- printf ("det_start: %f\n", rs->det_start);
- printf ("det_inc: %f\n", rs->det_inc);
- printf ("rot_start: %f\n", rs->rot_start);
- printf ("rot_inc: %f\n", rs->rot_inc);
+ printf (" Piclen: %f\n", rs->piclen);
+ printf (" det_start: %f\n", rs->det_start);
+ printf (" det_inc: %f\n", rs->det_inc);
+ printf (" rot_start: %f\n", rs->rot_start);
+ printf (" rot_inc: %f\n", rs->rot_inc);
}