#include <string.h>
-#include "thread_mpi/threads.h"
-
#include "macros.h"
#include "gromacs/math/vec.h"
#include "gromacs/pbcutil/pbc.h"
/* The source code in this file should be thread-safe.
Please keep it that way. */
-
-
-static gmx_bool bOverAllocDD = FALSE;
-static tMPI_Thread_mutex_t over_alloc_mutex = TMPI_THREAD_MUTEX_INITIALIZER;
-
-
-void set_over_alloc_dd(gmx_bool set)
-{
- tMPI_Thread_mutex_lock(&over_alloc_mutex);
- /* we just make sure that we don't set this at the same time.
- We don't worry too much about reading this rarely-set variable */
- bOverAllocDD = set;
- tMPI_Thread_mutex_unlock(&over_alloc_mutex);
-}
-
-int over_alloc_dd(int n)
-{
- if (bOverAllocDD)
- {
- return OVER_ALLOC_FAC*n + 100;
- }
- else
- {
- return n;
- }
-}
-
int gmx_int64_to_int(gmx_int64_t step, const char *warn)
{
int i;
return i;
}
-char *gmx_step_str(gmx_int64_t i, char *buf)
-{
- sprintf(buf, "%"GMX_PRId64, i);
-
- return buf;
-}
-
void init_inputrec(t_inputrec *ir)
{
memset(ir, 0, (size_t)sizeof(*ir));
extern "C" {
#endif
-/*
- * Memory (re)allocation can be VERY slow, especially with some
- * MPI libraries that replace the standard malloc and realloc calls.
- * To avoid slow memory allocation we use over_alloc to set the memory
- * allocation size for large data blocks. Since this scales the size
- * with a factor, we use log(n) realloc calls instead of n.
- * This can reduce allocation times from minutes to seconds.
- */
-/* This factor leads to 4 realloc calls to double the array size */
-#define OVER_ALLOC_FAC 1.19
-
-void set_over_alloc_dd(gmx_bool set);
-/* Turns over allocation for variable size atoms/cg/top arrays on or off,
- * default is off.
- */
-
-int over_alloc_dd(int n);
-/* Returns n when domain decomposition over allocation is off.
- * Returns OVER_ALLOC_FAC*n + 100 when over allocation in on.
- * This is to avoid frequent reallocation
- * during domain decomposition in mdrun.
- */
-
-/* Over allocation for small data types: int, real etc. */
-#define over_alloc_small(n) (int)(OVER_ALLOC_FAC*(n) + 8000)
-
-/* Over allocation for large data types: complex structs */
-#define over_alloc_large(n) (int)(OVER_ALLOC_FAC*(n) + 1000)
-
int gmx_int64_to_int(gmx_int64_t step, const char *warn);
/* Convert a gmx_int64_t value to int.
* If warn!=NULL a warning message will be written
* "WARNING during %s:", where warn is printed in %s.
*/
-#define STEPSTRSIZE 22
-
-char *gmx_step_str(gmx_int64_t i, char *buf);
-/* Prints a gmx_int64_t value in buf and returns the pointer to buf.
- * buf should be large enough to contain i: STEPSTRSIZE (22) chars.
- * When multiple gmx_int64_t values are printed in the same printf call,
- * be sure to call gmx_step_str with different buffers.
- */
-
/* Functions to initiate and delete structures *
* These functions are defined in gmxlib/typedefs.c
*/
#include "typedefs.h"
#include "types/nlistheuristics.h"
-#include "gromacs/utility/fatalerror.h"
+
#include "gromacs/math/vec.h"
+#include "gromacs/utility/cstringutil.h"
+#include "gromacs/utility/fatalerror.h"
void reset_nlistheuristics(gmx_nlheur_t *nlh, gmx_int64_t step)
{
#endif
}
+char *gmx_step_str(gmx_int64_t i, char *buf)
+{
+ sprintf(buf, "%"GMX_PRId64, i);
+ return buf;
+}
+
void parse_digits_from_plain_string(const char *digitstring, int *ndigits, int **digitlist)
{
int i;
*/
gmx_int64_t str_to_int64_t(const char *str, char **endptr);
+/** Minimum size of buffer to pass to gmx_step_str(). */
+#define STEPSTRSIZE 22
+
+/*! \brief
+ * Prints a gmx_int64_t value in buf and returns the pointer to buf.
+ *
+ * buf should be large enough to contain i: STEPSTRSIZE (22) chars.
+ * When multiple gmx_int64_t values are printed in the same printf call,
+ * be sure to call gmx_step_str with different buffers.
+ */
+char *gmx_step_str(gmx_int64_t i, char *buf);
+
#ifdef GMX_NATIVE_WINDOWS
#define snprintf _snprintf
#endif
#include <dmalloc.h>
#endif
+#include "thread_mpi/threads.h"
+
#include "gromacs/utility/fatalerror.h"
#ifdef PRINT_ALLOC_KB
#include "gromacs/utility/gmxmpi.h"
#endif
-#ifdef DEBUG
-#include "thread_mpi/threads.h"
+static gmx_bool g_bOverAllocDD = FALSE;
+static tMPI_Thread_mutex_t g_over_alloc_mutex = TMPI_THREAD_MUTEX_INITIALIZER;
+#ifdef DEBUG
static void log_action(int bMal, const char *what, const char *file, int line,
int nelem, int size, void *ptr)
{
#endif
}
}
+
+void set_over_alloc_dd(gmx_bool set)
+{
+ tMPI_Thread_mutex_lock(&g_over_alloc_mutex);
+ /* we just make sure that we don't set this at the same time.
+ We don't worry too much about reading this rarely-set variable */
+ g_bOverAllocDD = set;
+ tMPI_Thread_mutex_unlock(&g_over_alloc_mutex);
+}
+
+int over_alloc_dd(int n)
+{
+ if (g_bOverAllocDD)
+ {
+ return OVER_ALLOC_FAC*n + 100;
+ }
+ else
+ {
+ return n;
+ }
+}
#include <stddef.h>
+#include "basedefinitions.h"
+
#ifdef __cplusplus
extern "C" {
#endif
*/
#define sfree_aligned(ptr) save_free_aligned(#ptr, __FILE__, __LINE__, (ptr))
+/*! \brief
+ * Over allocation factor for memory allocations.
+ *
+ * Memory (re)allocation can be VERY slow, especially with some
+ * MPI libraries that replace the standard malloc and realloc calls.
+ * To avoid slow memory allocation we use over_alloc to set the memory
+ * allocation size for large data blocks. Since this scales the size
+ * with a factor, we use log(n) realloc calls instead of n.
+ * This can reduce allocation times from minutes to seconds.
+ *
+ * This factor leads to 4 realloc calls to double the array size.
+ */
+#define OVER_ALLOC_FAC 1.19
+
+/*! \brief
+ * Turns over allocation for variable size atoms/cg/top arrays on or off,
+ * default is off.
+ *
+ * \todo
+ * This is mdrun-specific, so it might be better to put this and
+ * over_alloc_dd() much higher up.
+ */
+void set_over_alloc_dd(gmx_bool set);
+
+/*! \brief
+ * Returns new allocation count for domain decomposition allocations.
+ *
+ * Returns n when domain decomposition over allocation is off.
+ * Returns OVER_ALLOC_FAC*n + 100 when over allocation in on.
+ * This is to avoid frequent reallocation during domain decomposition in mdrun.
+ */
+int over_alloc_dd(int n);
+
+/** Over allocation for small data types: int, real etc. */
+#define over_alloc_small(n) (int)(OVER_ALLOC_FAC*(n) + 8000)
+
+/** Over allocation for large data types: complex structs */
+#define over_alloc_large(n) (int)(OVER_ALLOC_FAC*(n) + 1000)
+
#endif