--- trunk/OOPSE/libmdtools/mdProfile.cpp 2003/12/19 17:25:00 887 +++ trunk/OOPSE/libmdtools/mdProfile.cpp 2004/05/27 00:48:12 1198 @@ -10,6 +10,7 @@ #include "mpiSimulation.hpp" #endif //is_mpi +#include "config.h" #include "simError.h" #include "mdProfile.hpp" @@ -30,10 +31,17 @@ namespace mdProfileSpace { #ifdef IS_MPI double globalTime[N_PROFILES]; #endif //is_mpi + } +extern "C"{ + + void F90_FUNC(gettimes, GETTIMES)(double* forceTime, + double* commTime); +} + using namespace mdProfileSpace; @@ -50,14 +58,14 @@ void initProfile( void ){ #endif //is_mpi } - strncpy( theNames[pro1].myName, "unamed1", MAX_PROFILE_NAMELENGTH ); - strncpy( theNames[pro2].myName, "unamed2", MAX_PROFILE_NAMELENGTH ); - strncpy( theNames[pro3].myName, "unamed3", MAX_PROFILE_NAMELENGTH ); - strncpy( theNames[pro4].myName, "unamed4", MAX_PROFILE_NAMELENGTH ); - strncpy( theNames[pro5].myName, "unamed5", MAX_PROFILE_NAMELENGTH ); - strncpy( theNames[pro6].myName, "unamed6", MAX_PROFILE_NAMELENGTH ); - strncpy( theNames[pro7].myName, "unamed7", MAX_PROFILE_NAMELENGTH ); - strncpy( theNames[pro8].myName, "unamed8", MAX_PROFILE_NAMELENGTH ); + strncpy( theNames[pro1].myName, "Integrator->integrateStep()", MAX_PROFILE_NAMELENGTH ); + strncpy( theNames[pro2].myName, "Integrator->writes and stats", MAX_PROFILE_NAMELENGTH ); + strncpy( theNames[pro3].myName, "Integrator->preMove", MAX_PROFILE_NAMELENGTH ); + strncpy( theNames[pro4].myName, "Integrator->moveA", MAX_PROFILE_NAMELENGTH ); + strncpy( theNames[pro5].myName, "Integrator->CalcForce", MAX_PROFILE_NAMELENGTH ); + strncpy( theNames[pro6].myName, "Integrator->moveB", MAX_PROFILE_NAMELENGTH ); + strncpy( theNames[pro7].myName, "shortRange force calc", MAX_PROFILE_NAMELENGTH ); + strncpy( theNames[pro8].myName, "fortran force calc", MAX_PROFILE_NAMELENGTH ); } @@ -91,16 +99,18 @@ void writeProfiles( void ){ int days, hours, minutes, secs, msecs; double donkey; + double forceTime, commTime; + #ifdef IS_MPI int j; MPI_Status istatus; - double nodeTime; + double nodeTime, nodeForceTime, nodeCommTime; double nodeAccum[N_PROFILES]; double nodePercent[N_PROFILES]; - double globalTime; + double globalTime, globalForceTime, globalCommTime; double globalAccum[N_PROFILES]; double globalPercent[N_PROFILES]; #endif // is_mpi @@ -140,22 +150,28 @@ void writeProfiles( void ){ secs = (int)donkey; msecs = (int)( (donkey - secs) * 1000 ); + F90_FUNC(gettimes, GETTIMES)(&forceTime, &commTime); + fprintf( stdout, "----------------------------------------------------------------------------\n" - " Total Time = %03d:%02d:%02d:%02d.%03d ( %G sec )\n", + " Total Time = %03d:%02d:%02d:%02d.%03d ( %G sec )\n" + "\n" + " From Fortran: forceTime = %G secs; communicationTime = %G secs.\n", days, hours, minutes, secs, msecs, - totalTime ); + totalTime, + forceTime, + commTime); #else // the parrallel version if( worldRank == 0 ){ - double *nodeTots = new double[mpiSim->getNumberProcessors()]; - double *nodePercentTots = new double[mpiSim->getNumberProcessors()]; + double *nodeTots = new double[mpiSim->getNprocessors()]; + double *nodePercentTots = new double[mpiSim->getNprocessors()]; totalTime = 0.0; for(i=0;igetNumberProcessors();j++){ + for(j=1;jgetNprocessors();j++){ nodeTime = 0.0; MPI_Recv(nodeAccum, N_PROFILES, MPI_DOUBLE, j, 1, MPI_COMM_WORLD, &istatus ); + MPI_Recv(&nodeForceTime, 1, MPI_DOUBLE, j, + 1, MPI_COMM_WORLD, &istatus ); + MPI_Recv(&nodeCommTime, 1, MPI_DOUBLE, j, + 1, MPI_COMM_WORLD, &istatus ); + for(i=0;igetNumberProcessors();j++) + for(j=0;jgetNprocessors();j++) nodePercentTots[j] = nodeTots[j] / globalTime; for(i=0;igetNumberProcessors();j++){ + for(j=0;jgetNprocessors();j++){ fprintf(stdout, " %12G %14G node %d\n", @@ -324,22 +359,30 @@ void writeProfiles( void ){ fprintf( stdout, "----------------------------------------------------------------------------\n" - " Total Time = %03d:%02d:%02d:%02d.%03d ( %G sec )\n", + " Total Time = %03d:%02d:%02d:%02d.%03d ( %G sec )\n" + "\n" + " From Fortran: forceTime = %G secs; communicationTime = %G secs.\n", days, hours, minutes, secs, msecs, - globalTime ); + globalTime, + globalForceTime, + globalCommTime); } else{ - for(j=1;jgetNumberProcessors();j++){ + for(j=1;jgetNprocessors();j++){ if( worldRank == j ){ + F90_FUNC(gettimes, GETTIMES)(&forceTime, &commTime); + MPI_Send( accumTime, N_PROFILES, MPI_DOUBLE, 0, 1, MPI_COMM_WORLD ); + MPI_Send( &forceTime, 1, MPI_DOUBLE, 0, 1, MPI_COMM_WORLD ); + MPI_Send( &commTime, 1, MPI_DOUBLE, 0, 1, MPI_COMM_WORLD ); } } }