--- trunk/OOPSE/libmdtools/mpiSimulation_module.F90 2003/03/27 23:33:40 432 +++ trunk/OOPSE/libmdtools/mpiSimulation_module.F90 2003/08/13 21:20:20 694 @@ -1,5 +1,5 @@ -#ifdef IS_MPI + !! MPI support for long range forces using force decomposition !! on a square grid of processors. !! Corresponds to mpiSimunation.cpp for C++ @@ -7,10 +7,11 @@ !! !! @author Charles F. Vardeman II !! @author Matthew Meineke -!! @version $Id: mpiSimulation_module.F90,v 1.3 2003-03-27 23:33:40 chuckv Exp $, $Date: 2003-03-27 23:33:40 $, $Name: not supported by cvs2svn $, $Revision: 1.3 $ +!! @version $Id: mpiSimulation_module.F90,v 1.6 2003-08-13 21:20:20 chuckv Exp $, $Date: 2003-08-13 21:20:20 $, $Name: not supported by cvs2svn $, $Revision: 1.6 $ module mpiSimulation use definitions +#ifdef IS_MPI use mpi implicit none PRIVATE @@ -47,6 +48,8 @@ module mpiSimulation public :: mpi_status_size public :: mpi_any_source + + !! Safety logical to prevent access to ComponetPlan until !! set by C++. logical :: ComponentPlanSet = .false. @@ -55,8 +58,13 @@ module mpiSimulation !! generic mpi error declaration. integer,public :: mpi_err - +#ifdef PROFILE + public :: printCommTime + real(kind = dp ) :: commTime = 0.0_dp + real(kind = dp ) :: commTimeInitial,commTimeFinal +#endif + !! Include mpiComponentPlan type. mpiComponentPlan is a !! dual header file for both c and fortran. #define __FORTRAN90 @@ -136,8 +144,11 @@ contains integer :: localStatus !! Global reference tag for local particles integer, dimension(ntags),intent(inout) :: tags + + write(*,*) 'mpiSim_mod thinks node', thisComponentPlan%myNode, ' has tags(1) = ', tags(1) + status = 0 if (componentPlanSet) then return @@ -500,10 +511,16 @@ contains if (present(status)) status = 0 noffset = this_plan%displs(this_plan%myPlanRank) - +#ifdef PROFILE + commTimeInitial = mpi_wtime() +#endif call mpi_allgatherv(sbuffer,this_plan%gsPlanSize, mpi_double_precision, & rbuffer,this_plan%counts,this_plan%displs,mpi_double_precision, & this_plan%myPlanComm, mpi_err) +#ifdef PROFILE + commTimeFinal = mpi_wtime() + commTime = commTime + commTimeFinal - commTimeInitial +#endif if (mpi_err /= 0) then if (present(status)) status = -1 @@ -524,11 +541,19 @@ contains if (present(status)) status = 0 ! noffset = this_plan%displs(this_plan%me) - +#ifdef PROFILE + commTimeInitial = mpi_wtime() +#endif + call mpi_allgatherv(sbuffer,this_plan%gsPlanSize, mpi_double_precision, & rbuffer,this_plan%counts,this_plan%displs,mpi_double_precision, & this_plan%myPlanComm, mpi_err) +#ifdef PROFILE + commTimeFinal = mpi_wtime() + commTime = commTime + commTimeFinal - commTimeInitial +#endif + if (mpi_err /= 0) then if (present(status)) status = -1 endif @@ -545,8 +570,15 @@ contains if (present(status)) status = 0 +#ifdef PROFILE + commTimeInitial = mpi_wtime() +#endif call mpi_reduce_scatter(sbuffer,rbuffer, this_plan%counts, & mpi_double_precision, MPI_SUM, this_plan%myPlanComm, mpi_err) +#ifdef PROFILE + commTimeFinal = mpi_wtime() + commTime = commTime + commTimeFinal - commTimeInitial +#endif if (mpi_err /= 0) then if (present(status)) status = -1 @@ -563,8 +595,16 @@ contains external mpi_reduce_scatter if (present(status)) status = 0 +#ifdef PROFILE + commTimeInitial = mpi_wtime() +#endif + call mpi_reduce_scatter(sbuffer,rbuffer, this_plan%counts, & mpi_double_precision, MPI_SUM, this_plan%myPlanComm, mpi_err) +#ifdef PROFILE + commTimeFinal = mpi_wtime() + commTime = commTime + commTimeFinal - commTimeInitial +#endif if (mpi_err /= 0) then if (present(status)) status = -1 @@ -685,7 +725,15 @@ contains myNode = mpiSim%myNode end function getMyNode +#ifdef PROFILE + subroutine printCommTime() -end module mpiSimulation + write(*,*) "MPI communication time is: ", commTime + end subroutine printCommTime +#endif + #endif // is_mpi +end module mpiSimulation + +