| 1 |
+ |
/* |
| 2 |
+ |
* Copyright (c) 2005 The University of Notre Dame. All Rights Reserved. |
| 3 |
+ |
* |
| 4 |
+ |
* The University of Notre Dame grants you ("Licensee") a |
| 5 |
+ |
* non-exclusive, royalty free, license to use, modify and |
| 6 |
+ |
* redistribute this software in source and binary code form, provided |
| 7 |
+ |
* that the following conditions are met: |
| 8 |
+ |
* |
| 9 |
+ |
* 1. Redistributions of source code must retain the above copyright |
| 10 |
+ |
* notice, this list of conditions and the following disclaimer. |
| 11 |
+ |
* |
| 12 |
+ |
* 2. Redistributions in binary form must reproduce the above copyright |
| 13 |
+ |
* notice, this list of conditions and the following disclaimer in the |
| 14 |
+ |
* documentation and/or other materials provided with the |
| 15 |
+ |
* distribution. |
| 16 |
+ |
* |
| 17 |
+ |
* This software is provided "AS IS," without a warranty of any |
| 18 |
+ |
* kind. All express or implied conditions, representations and |
| 19 |
+ |
* warranties, including any implied warranty of merchantability, |
| 20 |
+ |
* fitness for a particular purpose or non-infringement, are hereby |
| 21 |
+ |
* excluded. The University of Notre Dame and its licensors shall not |
| 22 |
+ |
* be liable for any damages suffered by licensee as a result of |
| 23 |
+ |
* using, modifying or distributing the software or its |
| 24 |
+ |
* derivatives. In no event will the University of Notre Dame or its |
| 25 |
+ |
* licensors be liable for any lost revenue, profit or data, or for |
| 26 |
+ |
* direct, indirect, special, consequential, incidental or punitive |
| 27 |
+ |
* damages, however caused and regardless of the theory of liability, |
| 28 |
+ |
* arising out of the use of or inability to use software, even if the |
| 29 |
+ |
* University of Notre Dame has been advised of the possibility of |
| 30 |
+ |
* such damages. |
| 31 |
+ |
* |
| 32 |
+ |
* SUPPORT OPEN SCIENCE! If you use OpenMD or its source code in your |
| 33 |
+ |
* research, please cite the appropriate papers when you publish your |
| 34 |
+ |
* work. Good starting points are: |
| 35 |
+ |
* |
| 36 |
+ |
* [1] Meineke, et al., J. Comp. Chem. 26, 252-271 (2005). |
| 37 |
+ |
* [2] Fennell & Gezelter, J. Chem. Phys. 124, 234104 (2006). |
| 38 |
+ |
* [3] Sun, Lin & Gezelter, J. Chem. Phys. 128, 24107 (2008). |
| 39 |
+ |
* [4] Vardeman & Gezelter, in progress (2009). |
| 40 |
+ |
*/ |
| 41 |
+ |
|
| 42 |
|
#include <sys/time.h> |
| 43 |
|
#include <string.h> |
| 44 |
|
#include <stdio.h> |
| 67 |
|
struct timeval startTime[N_PROFILES]; |
| 68 |
|
struct timeval endTime[N_PROFILES]; |
| 69 |
|
|
| 70 |
< |
double accumTime[N_PROFILES]; |
| 70 |
> |
RealType accumTime[N_PROFILES]; |
| 71 |
|
|
| 72 |
|
#ifdef IS_MPI |
| 73 |
< |
double globalTime[N_PROFILES]; |
| 73 |
> |
RealType globalTime[N_PROFILES]; |
| 74 |
|
#endif //is_mpi |
| 75 |
|
|
| 76 |
|
|
| 78 |
|
|
| 79 |
|
extern "C"{ |
| 80 |
|
|
| 81 |
< |
void F90_FUNC(gettimes, GETTIMES)(double* forceTime, |
| 82 |
< |
double* commTime); |
| 81 |
> |
void FC_FUNC(gettimes, GETTIMES)(RealType* forceTime, |
| 82 |
> |
RealType* commTime); |
| 83 |
|
} |
| 84 |
|
|
| 85 |
|
|
| 118 |
|
|
| 119 |
|
void endProfile( proNames theProfile ){ |
| 120 |
|
struct timezone tz; |
| 121 |
< |
double startVal, endVal; |
| 121 |
> |
RealType startVal, endVal; |
| 122 |
|
|
| 123 |
|
gettimeofday( &endTime[theProfile], &tz ); |
| 124 |
|
|
| 125 |
< |
startVal = (double)startTime[theProfile].tv_sec |
| 126 |
< |
+ (double)startTime[theProfile].tv_usec / 1000000.0; |
| 125 |
> |
startVal = (RealType)startTime[theProfile].tv_sec |
| 126 |
> |
+ (RealType)startTime[theProfile].tv_usec / 1000000.0; |
| 127 |
|
|
| 128 |
< |
endVal = (double)endTime[theProfile].tv_sec |
| 129 |
< |
+ (double)endTime[theProfile].tv_usec / 1000000.0; |
| 128 |
> |
endVal = (RealType)endTime[theProfile].tv_sec |
| 129 |
> |
+ (RealType)endTime[theProfile].tv_usec / 1000000.0; |
| 130 |
|
|
| 131 |
|
accumTime[theProfile] += endVal - startVal; |
| 132 |
|
} |
| 135 |
|
void writeProfiles( void ){ |
| 136 |
|
|
| 137 |
|
int i; |
| 138 |
< |
double totalTime; |
| 139 |
< |
double percentTime[N_PROFILES]; |
| 138 |
> |
RealType totalTime; |
| 139 |
> |
RealType percentTime[N_PROFILES]; |
| 140 |
|
int days, hours, minutes, secs, msecs; |
| 141 |
< |
double donkey; |
| 141 |
> |
RealType donkey; |
| 142 |
|
|
| 143 |
< |
double forceTime, commTime; |
| 143 |
> |
RealType forceTime, commTime; |
| 144 |
|
|
| 145 |
|
#ifdef IS_MPI |
| 146 |
|
int j; |
| 147 |
|
|
| 148 |
|
MPI_Status istatus; |
| 149 |
|
|
| 150 |
< |
double nodeTime, nodeForceTime, nodeCommTime; |
| 151 |
< |
double nodeAccum[N_PROFILES]; |
| 152 |
< |
double nodePercent[N_PROFILES]; |
| 150 |
> |
RealType nodeTime, nodeForceTime, nodeCommTime; |
| 151 |
> |
RealType nodeAccum[N_PROFILES]; |
| 152 |
> |
RealType nodePercent[N_PROFILES]; |
| 153 |
|
|
| 154 |
< |
double globalTime, globalForceTime, globalCommTime; |
| 155 |
< |
double globalAccum[N_PROFILES]; |
| 156 |
< |
double globalPercent[N_PROFILES]; |
| 154 |
> |
RealType globalTime, globalForceTime, globalCommTime; |
| 155 |
> |
RealType globalAccum[N_PROFILES]; |
| 156 |
> |
RealType globalPercent[N_PROFILES]; |
| 157 |
|
#endif // is_mpi |
| 158 |
|
|
| 159 |
|
|
| 191 |
|
secs = (int)donkey; |
| 192 |
|
msecs = (int)( (donkey - secs) * 1000 ); |
| 193 |
|
|
| 194 |
< |
F90_FUNC(gettimes, GETTIMES)(&forceTime, &commTime); |
| 194 |
> |
FC_FUNC(gettimes, GETTIMES)(&forceTime, &commTime); |
| 195 |
|
|
| 196 |
|
fprintf( stdout, |
| 197 |
|
"----------------------------------------------------------------------------\n" |
| 211 |
|
|
| 212 |
|
if( worldRank == 0 ){ |
| 213 |
|
|
| 214 |
< |
double *nodeTots = new double[mpiSim->getNProcessors()]; |
| 215 |
< |
double *nodePercentTots = new double[mpiSim->getNProcessors()]; |
| 214 |
> |
RealType *nodeTots = new RealType[mpiSim->getNProcessors()]; |
| 215 |
> |
RealType *nodePercentTots = new RealType[mpiSim->getNProcessors()]; |
| 216 |
|
|
| 217 |
|
totalTime = 0.0; |
| 218 |
|
for(i=0;i<N_PROFILES;i++) |
| 250 |
|
secs = (int)donkey; |
| 251 |
|
msecs = (int)( (donkey - secs) * 1000 ); |
| 252 |
|
|
| 253 |
< |
F90_FUNC(gettimes, GETTIMES)(&forceTime, &commTime); |
| 253 |
> |
FC_FUNC(gettimes, GETTIMES)(&forceTime, &commTime); |
| 254 |
|
|
| 255 |
|
fprintf( stdout, |
| 256 |
|
"----------------------------------------------------------------------------\n" |
| 281 |
|
|
| 282 |
|
nodeTime = 0.0; |
| 283 |
|
|
| 284 |
< |
MPI_Recv(nodeAccum, N_PROFILES, MPI_DOUBLE, j, |
| 284 |
> |
MPI_Recv(nodeAccum, N_PROFILES, MPI_REALTYPE, j, |
| 285 |
|
1, MPI_COMM_WORLD, &istatus ); |
| 286 |
|
|
| 287 |
< |
MPI_Recv(&nodeForceTime, 1, MPI_DOUBLE, j, |
| 287 |
> |
MPI_Recv(&nodeForceTime, 1, MPI_REALTYPE, j, |
| 288 |
|
1, MPI_COMM_WORLD, &istatus ); |
| 289 |
< |
MPI_Recv(&nodeCommTime, 1, MPI_DOUBLE, j, |
| 289 |
> |
MPI_Recv(&nodeCommTime, 1, MPI_REALTYPE, j, |
| 290 |
|
1, MPI_COMM_WORLD, &istatus ); |
| 291 |
|
|
| 292 |
|
for(i=0;i<N_PROFILES;i++){ |
| 419 |
|
|
| 420 |
|
if( worldRank == j ){ |
| 421 |
|
|
| 422 |
< |
F90_FUNC(gettimes, GETTIMES)(&forceTime, &commTime); |
| 422 |
> |
FC_FUNC(gettimes, GETTIMES)(&forceTime, &commTime); |
| 423 |
|
|
| 424 |
< |
MPI_Send( accumTime, N_PROFILES, MPI_DOUBLE, 0, 1, MPI_COMM_WORLD ); |
| 425 |
< |
MPI_Send( &forceTime, 1, MPI_DOUBLE, 0, 1, MPI_COMM_WORLD ); |
| 426 |
< |
MPI_Send( &commTime, 1, MPI_DOUBLE, 0, 1, MPI_COMM_WORLD ); |
| 424 |
> |
MPI_Send( accumTime, N_PROFILES, MPI_REALTYPE, 0, 1, MPI_COMM_WORLD ); |
| 425 |
> |
MPI_Send( &forceTime, 1, MPI_REALTYPE, 0, 1, MPI_COMM_WORLD ); |
| 426 |
> |
MPI_Send( &commTime, 1, MPI_REALTYPE, 0, 1, MPI_COMM_WORLD ); |
| 427 |
|
} |
| 428 |
|
} |
| 429 |
|
} |