#
# This file is part of the GROMACS molecular simulation package.
#
-# Copyright (c) 2013,2014, by the GROMACS development team, led by
+# Copyright (c) 2013,2014,2015, by the GROMACS development team, led by
# Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
# and including many others, as listed in the AUTHORS file in the
# top-level source directory and at http://www.gromacs.org.
# To help us fund GROMACS development, we humbly ask that you cite
# the research papers on the package. Check out http://www.gromacs.org.
-file(GLOB TIMING_SOURCES *.cpp *.c)
+file(GLOB TIMING_SOURCES *.cpp)
set(LIBGROMACS_SOURCES ${LIBGROMACS_SOURCES} ${TIMING_SOURCES} PARENT_SCOPE)
gmx_install_headers(
* This file is part of the GROMACS molecular simulation package.
*
* Copyright (c) 1991-2006 David van der Spoel, Erik Lindahl, Berk Hess, University of Groningen.
- * Copyright (c) 2013,2014, by the GROMACS development team, led by
+ * Copyright (c) 2013,2014,2015, by the GROMACS development team, led by
* Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
* and including many others, as listed in the AUTHORS file in the
* top-level source directory and at http://www.gromacs.org.
#include "config.h"
-#include <time.h>
+#include <ctime>
#ifdef HAVE_SYS_TIME_H
#include <sys/time.h>
QueryPerformanceFrequency(&i);
- return 1.0/((double) i.QuadPart);
+ return 1.0/static_cast<double>(i.QuadPart);
/* end of MS Windows implementation */
#elif (defined HAVE_GETTIMEOFDAY)
gmx_cycles_t c1, c2;
double timediff, cyclediff;
double d = 0.1; /* Dummy variable so we don't optimize away delay loop */
- int i;
if (!gmx_cycles_have_counter())
{
* that will underflow to zero in most cases. By conditionally adding it
* to a result at the end it cannot be removed. n=10000 is arbitrary...
*/
- for (i = 0; i < 10000; i++)
+ for (int i = 0; i < 10000; i++)
{
- d = d/(1.0+(double)i);
+ d = d/(1.0+static_cast<double>(i));
}
/* Read the time again */
gettimeofday(&t2, NULL);
c2 = gmx_cycles_read();
- timediff = (double)(t2.tv_sec-t1.tv_sec)+
- (double)(t2.tv_usec-t1.tv_usec)*1e-6;
+ timediff = static_cast<double>(t2.tv_sec-t1.tv_sec)+(t2.tv_usec-t1.tv_usec)*1e-6;
}
while (timediff < sampletime);
#include "config.h"
-#include <assert.h>
-#include <stdlib.h>
+#include <cstdlib>
#include "gromacs/legacyheaders/md_logging.h"
#include "gromacs/legacyheaders/types/commrec.h"
#include "gromacs/timing/cyclecounter.h"
#include "gromacs/timing/gpu_timing.h"
#include "gromacs/utility/cstringutil.h"
+#include "gromacs/utility/gmxassert.h"
#include "gromacs/utility/gmxmpi.h"
#include "gromacs/utility/smalloc.h"
#include "gromacs/utility/snprintf.h"
"Enforced rotation", "Add rot. forces", "Coordinate swapping", "IMD", "Test"
};
+#ifdef GMX_CYCLE_SUBCOUNTERS
static const char *wcsn[ewcsNR] =
{
"DD redist.", "DD NS grid + sort", "DD setup comm.",
"NB X buffer ops.",
"NB F buffer ops.",
};
+#endif
gmx_bool wallcycle_have_counter(void)
{
void wallcycle_get(gmx_wallcycle_t wc, int ewc, int *n, double *c)
{
*n = wc->wcc[ewc].n;
- *c = (double)wc->wcc[ewc].c;
+ *c = static_cast<double>(wc->wcc[ewc].c);
}
void wallcycle_reset_all(gmx_wallcycle_t wc)
{
if (wcc[ewc_sub].n > 0)
{
- assert(wcc[ewc_main].c >= wcc[ewc_sub].c);
+ GMX_ASSERT(wcc[ewc_main].c >= wcc[ewc_sub].c, "Subcounter cannot have more ticks than parent");
wcc[ewc_main].c -= wcc[ewc_sub].c;
}
{
wallcc_t *wcc;
double cycles[ewcNR+ewcsNR];
- double cycles_n[ewcNR+ewcsNR], buf[ewcNR+ewcsNR], *cyc_all, *buf_all;
+#ifdef GMX_MPI
+ double cycles_n[ewcNR+ewcsNR];
+ double buf[ewcNR+ewcsNR];
+ double *buf_all, *cyc_all;
+#endif
int i, j;
int nsum;
if (wcc[ewcPMEMESH].n > 0)
{
/* This must be a PME only node, calculate the Wait + Comm. time */
- assert(wcc[ewcRUN].c >= wcc[ewcPMEMESH].c);
+ GMX_ASSERT(wcc[ewcRUN].c >= wcc[ewcPMEMESH].c, "Total run ticks must be greater than PME-only ticks");
wcc[ewcPMEWAITCOMM].c = wcc[ewcRUN].c - wcc[ewcPMEMESH].c;
}
}
/* Store the cycles in a double buffer for summing */
for (i = 0; i < ewcNR; i++)
{
- cycles_n[i] = (double)wcc[i].n;
- cycles[i] = (double)wcc[i].c;
+#ifdef GMX_MPI
+ cycles_n[i] = static_cast<double>(wcc[i].n);
+#endif
+ cycles[i] = static_cast<double>(wcc[i].c);
}
nsum = ewcNR;
#ifdef GMX_CYCLE_SUBCOUNTERS
for (i = 0; i < ewcsNR; i++)
{
wc->wcsc[i].c *= wc->nthreads_pp;
- cycles_n[ewcNR+i] = (double)wc->wcsc[i].n;
- cycles[ewcNR+i] = (double)wc->wcsc[i].c;
+#ifdef GMX_MPI
+ cycles_n[ewcNR+i] = static_cast<double>(wc->wcsc[i].n);
+#endif
+ cycles[ewcNR+i] = static_cast<double>(wc->wcsc[i].c);
}
nsum += ewcsNR;
#endif
cr->mpi_comm_mysim);
for (i = 0; i < ewcNR; i++)
{
- wcc[i].n = (int)(buf[i] + 0.5);
+ wcc[i].n = static_cast<int>(buf[i] + 0.5);
}
#ifdef GMX_CYCLE_SUBCOUNTERS
for (i = 0; i < ewcsNR; i++)
{
- wc->wcsc[i].n = (int)(buf[ewcNR+i] + 0.5);
+ wc->wcsc[i].n = static_cast<int>(buf[ewcNR+i] + 0.5);
}
#endif
cr->mpi_comm_mysim);
for (i = 0; i < ewcNR*ewcNR; i++)
{
- wc->wcc_all[i].c = buf_all[i];
+ wc->wcc_all[i].c = static_cast<gmx_cycles_t>(buf_all[i]);
}
sfree(buf_all);
sfree(cyc_all);
}
nth_pp = wc->nthreads_pp;
- assert(nth_pp > 0);
+ GMX_ASSERT(nth_pp > 0, "Number of particle-particle threads must be >0");
nth_pme = wc->nthreads_pme;
- assert(nth_pme > 0);
+ GMX_ASSERT(nth_pme > 0, "Number of PME threads must be >0");
cyc_sum = wc->cycles_sum;
- assert(nnodes > 0);
- assert(npme >= 0);
+ GMX_ASSERT(nnodes > 0, "Number of nodes must be >0");
+ GMX_ASSERT(npme >= 0, "Number of PME nodes cannot be negative");
npp = nnodes - npme;
/* npme is the number of PME-only ranks used, and we always do PP work */
- assert(npp > 0);
+ GMX_ASSERT(npp > 0, "Number of particle-particle nodes must be >0");
nth_tot = npp*nth_pp + npme*nth_pme;
/* Conversion factor from cycles to seconds */
c2t = realtime/tot;
- c2t_pp = c2t * nth_tot / (double) (npp*nth_pp);
+ c2t_pp = c2t * nth_tot / static_cast<double>(npp*nth_pp);
if (npme > 0)
{
- c2t_pme = c2t * nth_tot / (double) (npme*nth_pme);
+ c2t_pme = c2t * nth_tot / static_cast<double>(npme*nth_pme);
}
else
{
}
}
}
- tot_for_rest = tot * (npp * nth_pp) / (double) nth_tot;
+ tot_for_rest = tot * npp * nth_pp / static_cast<double>(nth_tot);
print_cycles(fplog, c2t_pp, "Rest",
npp, nth_pp,
-1, tot_for_rest - tot_for_pp, tot);
* This file is part of the GROMACS molecular simulation package.
*
* Copyright (c) 2013, The GROMACS development team.
- * Copyright (c) 2013,2014, by the GROMACS development team, led by
+ * Copyright (c) 2013,2014,2015, by the GROMACS development team, led by
* Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
* and including many others, as listed in the AUTHORS file in the
* top-level source directory and at http://www.gromacs.org.
#include "config.h"
-#include <time.h>
+#include <ctime>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
double seconds;
clock_gettime(CLOCK_REALTIME, &t);
- seconds = (double) t.tv_sec + 1e-9*(double)t.tv_nsec;
+ seconds = static_cast<double>(t.tv_sec) + 1e-9*t.tv_nsec;
return seconds;
#elif defined HAVE_GETTIMEOFDAY
double seconds;
gettimeofday(&t, NULL);
- seconds = (double) t.tv_sec + 1e-6*(double)t.tv_usec;
+ seconds = static_cast<double>(t.tv_sec) + 1e-6*t.tv_usec;
return seconds;
#else
double seconds;
clock_gettime(CLOCK_THREAD_CPUTIME_ID, &t);
- seconds = (double) t.tv_sec + 1e-9*(double)t.tv_nsec;
+ seconds = static_cast<double>(t.tv_sec) + 1e-9*t.tv_nsec;
return seconds;
#else