--- trunk/OOPSE/libmdtools/mdProfile.cpp 2003/12/18 21:47:51 884 +++ trunk/OOPSE/libmdtools/mdProfile.cpp 2003/12/19 17:25:00 887 @@ -1,10 +1,22 @@ #include +#include +#include +#include +#include +#ifdef IS_MPI +#include + +#include "mpiSimulation.hpp" +#endif //is_mpi + +#include "simError.h" #include "mdProfile.hpp" namespace mdProfileSpace { class ProfileString{ + public: char myName[MAX_PROFILE_NAMELENGTH]; }; @@ -62,10 +74,10 @@ void endProfile( proNames theProfile ){ gettimeofday( &endTime[theProfile], &tz ); startVal = (double)startTime[theProfile].tv_sec - + (double)startTime[theProfile].tv_usec / 1000.0; + + (double)startTime[theProfile].tv_usec / 1000000.0; endVal = (double)endTime[theProfile].tv_sec - + (double)endTime[theProfile].tv_usec / 1000.0; + + (double)endTime[theProfile].tv_usec / 1000000.0; accumTime[theProfile] += endVal - startVal; } @@ -74,16 +86,31 @@ void writeProfiles( void ){ void writeProfiles( void ){ int i; - double totTime; + double totalTime; double percentTime[N_PROFILES]; - int days, hours, minutes, secs, usecs; + int days, hours, minutes, secs, msecs; double donkey; +#ifdef IS_MPI + int j; + + MPI_Status istatus; + + double nodeTime; + double nodeAccum[N_PROFILES]; + double nodePercent[N_PROFILES]; + + double globalTime; + double globalAccum[N_PROFILES]; + double globalPercent[N_PROFILES]; +#endif // is_mpi + + #ifndef IS_MPI // single processor version - totTime = 0.0; + totalTime = 0.0; for(i=0;igetNumberProcessors()]; + double *nodePercentTots = new double[mpiSim->getNumberProcessors()]; + + totalTime = 0.0; + for(i=0;igetNumberProcessors();j++){ + + nodeTime = 0.0; + + MPI_Recv(nodeAccum, N_PROFILES, MPI_DOUBLE, j, + 1, MPI_COMM_WORLD, &istatus ); + + for(i=0;igetNumberProcessors();j++) + nodePercentTots[j] = nodeTots[j] / globalTime; + + for(i=0;igetNumberProcessors();j++){ + + fprintf(stdout, + " %12G %14G node %d\n", + nodeTots[j], + nodePercentTots[j], + j ); + } + + days = (int)floor( globalTime / 86400 ); + donkey = nodeTime - 86400 * days; + + + hours = (int)floor( donkey / 3600 ); + donkey -= hours * 3600; + + minutes = (int)floor( donkey / 60 ); + donkey -= minutes * 60; + + secs = (int)donkey; + msecs = (int)( (donkey - secs) * 1000 ); + + fprintf( stdout, + "----------------------------------------------------------------------------\n" + " Total Time = %03d:%02d:%02d:%02d.%03d ( %G sec )\n", + days, + hours, + minutes, + secs, + msecs, + globalTime ); + } + + else{ + + for(j=1;jgetNumberProcessors();j++){ + + if( worldRank == j ){ + + MPI_Send( accumTime, N_PROFILES, MPI_DOUBLE, 0, 1, MPI_COMM_WORLD ); + } + } + } + #endif // is_mpi