--- trunk/OOPSE/libmdtools/mpiSimulation_module.F90 2003/07/17 19:25:51 631 +++ trunk/OOPSE/libmdtools/mpiSimulation_module.F90 2003/10/28 20:09:45 834 @@ -7,7 +7,7 @@ !! !! @author Charles F. Vardeman II !! @author Matthew Meineke -!! @version $Id: mpiSimulation_module.F90,v 1.5 2003-07-17 19:25:51 chuckv Exp $, $Date: 2003-07-17 19:25:51 $, $Name: not supported by cvs2svn $, $Revision: 1.5 $ +!! @version $Id: mpiSimulation_module.F90,v 1.8 2003-10-28 20:09:38 gezelter Exp $, $Date: 2003-10-28 20:09:38 $, $Name: not supported by cvs2svn $, $Revision: 1.8 $ module mpiSimulation use definitions @@ -48,16 +48,23 @@ module mpiSimulation public :: mpi_status_size public :: mpi_any_source + + !! Safety logical to prevent access to ComponetPlan until !! set by C++. - logical :: ComponentPlanSet = .false. + logical, save :: ComponentPlanSet = .false. !! generic mpi error declaration. - integer,public :: mpi_err + integer, public :: mpi_err - +#ifdef PROFILE + public :: printCommTime + real(kind = dp ), save :: 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 @@ -71,10 +78,10 @@ module mpiSimulation integer, public, allocatable, dimension(:) :: tagColumn !! Logical set true if mpiSimulation has been initialized - logical :: isSimSet = .false. + logical, save :: isSimSet = .false. - type (mpiComponentPlan) :: mpiSim + type (mpiComponentPlan), save :: mpiSim !! gs_plan contains plans for gather and scatter routines type, public :: gs_plan @@ -90,12 +97,12 @@ module mpiSimulation end type gs_plan ! plans for different decompositions - type (gs_plan), public :: plan_row - type (gs_plan), public :: plan_row3d - type (gs_plan), public :: plan_col - type (gs_plan), public :: plan_col3d - type(gs_plan), public :: plan_row_Rotation - type(gs_plan), public :: plan_col_Rotation + type (gs_plan), public, save :: plan_row + type (gs_plan), public, save :: plan_row3d + type (gs_plan), public, save :: plan_col + type (gs_plan), public, save :: plan_col3d + type (gs_plan), public, save :: plan_row_Rotation + type (gs_plan), public, save :: plan_col_Rotation type (mpiComponentPlan), pointer :: simComponentPlan @@ -504,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 @@ -528,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 @@ -549,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 @@ -567,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 @@ -627,13 +663,15 @@ contains end subroutine setTags - pure function getNcol(thisplan) result(ncol) +! pure function getNcol(thisplan) result(ncol) + function getNcol(thisplan) result(ncol) type (gs_plan), intent(in) :: thisplan integer :: ncol ncol = thisplan%gsComponentPlan%nComponentsColumn end function getNcol - pure function getNrow(thisplan) result(nrow) +! pure function getNrow(thisplan) result(nrow) + function getNrow(thisplan) result(nrow) type (gs_plan), intent(in) :: thisplan integer :: nrow nrow = thisplan%gsComponentPlan%nComponentsRow @@ -689,6 +727,14 @@ contains myNode = mpiSim%myNode end function getMyNode +#ifdef PROFILE + subroutine printCommTime() + + write(*,*) "MPI communication time is: ", commTime + + end subroutine printCommTime +#endif + #endif // is_mpi end module mpiSimulation