*
* Copyright (c) 1991-2000, University of Groningen, The Netherlands.
* Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2013, by the GROMACS development team, led by
+ * Copyright (c) 2013,2014, 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 "viewit.h"
#include "xvgr.h"
#include "gmx_ana.h"
-#include "gmx_sort.h"
#ifdef HAVE_UNISTD_H
#include <unistd.h>
/*
* This file is part of the GROMACS molecular simulation package.
*
- * Copyright (c) 2010, by the GROMACS development team, led by
+ * Copyright (c) 2010,2014, 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.
*/
-#ifndef _GMX_INPUTREC_H_
-#define _GMX_INPUTREC_H_
-
-/** @file gmx_sort.h
- *
- * @brief Portable implementation of thread-safe sort routines.
- *
- *
- * This module provides a Gromacs version of the qsort() routine defined.
- * It is not highly optimized, but it is thread safe, i.e. multiple threads
- * can simultaneously call gmx_qsort with different data.
- */
-
-#include <stdlib.h>
+#ifndef GMX_INPUTREC_H
+#define GMX_INPUTREC_H
#include "types/inputrec.h"
#endif
-#endif /* _GMX_INPUTREC_H_ */
+#endif
/*
* This file is part of the GROMACS molecular simulation package.
*
- * Copyright (c) 2005,2006,2007,2008,2009,2010,2011,2012,2013, by the GROMACS development team, led by
+ * Copyright (c) 2005,2006,2007,2008,2009,2010,2011,2012,2013,2014, 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 "shellfc.h"
#include "mtop_util.h"
#include "gmx_ga2la.h"
-#include "gmx_sort.h"
#include "macros.h"
#include "nbnxn_search.h"
#include "bondf.h"
#include "gromacs/fileio/pdbio.h"
#include "gromacs/timing/wallcycle.h"
#include "gromacs/utility/gmxmpi.h"
+#include "gromacs/utility/qsort_threadsafe.h"
#define DDRANK(dd, rank) (rank)
#define DDMASTERRANK(dd) (dd->masterrank)
int i1, i2, i_new;
/* The new indices are not very ordered, so we qsort them */
- qsort_threadsafe(sort_new, nsort_new, sizeof(sort_new[0]), comp_cgsort);
+ gmx_qsort_threadsafe(sort_new, nsort_new, sizeof(sort_new[0]), comp_cgsort);
/* sort2 is already ordered, so now we can merge the two arrays */
i1 = 0;
fprintf(debug, "qsort cgs: %d new home %d\n", dd->ncg_home, ncg_new);
}
/* Determine the order of the charge groups using qsort */
- qsort_threadsafe(cgsort, dd->ncg_home, sizeof(cgsort[0]), comp_cgsort);
+ gmx_qsort_threadsafe(cgsort, dd->ncg_home, sizeof(cgsort[0]), comp_cgsort);
}
return ncg_new;
*
* Copyright (c) 1991-2000, University of Groningen, The Netherlands.
* Copyright (c) 2001-2008, The GROMACS development team.
- * Copyright (c) 2013, by the GROMACS development team, led by
+ * Copyright (c) 2013,2014, 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 "xvgr.h"
#include "groupcoord.h"
#include "pull_rotation.h"
-#include "gmx_sort.h"
#include "copyrite.h"
#include "macros.h"
#include "gromacs/fileio/trnio.h"
#include "gromacs/timing/cyclecounter.h"
#include "gromacs/timing/wallcycle.h"
+#include "gromacs/utility/qsort_threadsafe.h"
static char *RotStr = {"Enforced rotation:"};
/*
* This file is part of the GROMACS molecular simulation package.
*
- * Copyright (c) 2010,2011,2012,2013, by the GROMACS development team, led by
+ * Copyright (c) 2010,2011,2012,2013,2014, 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.
* name and path of the executable. This information is used, e.g., by the
* error handling code in formatting standard error messages.
*
+ * The header qsort_threadsafe.h provides a guaranteed threadsafe
+ * implementation for qsort().
+ *
* \endif
*
* \author Teemu Murtola <teemu.murtola@gmail.com>
/*
* This file is part of the GROMACS molecular simulation package.
*
- * Copyright (c) 2010,2012, by the GROMACS development team, led by
+ * Copyright (c) 2010,2012,2014, 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.
*/
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "qsort_threadsafe.h"
#include <stdlib.h>
-#include "gmx_sort.h"
-
static void
qsort_swapfunc(void * a,
/*
* This file is part of the GROMACS molecular simulation package.
*
- * Copyright (c) 2010,2012, by the GROMACS development team, led by
+ * Copyright (c) 2010,2012,2014, 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.
*/
-/*! \internal \file
+/*! \libinternal \file
* \brief
- * Portable implementation of thread-safe sort routines.
+ * Portable implementation of threadsafe quicksort.
*
- * This module provides a Gromacs version of the qsort() routine defined.
- * It is not highly optimized, but it is thread safe, i.e. multiple threads
+ * This module provides a \Gromacs version of the qsort() routine defined.
+ * It is not highly optimized, but it is threadsafe, i.e. multiple threads
* can simultaneously call gmx_qsort() with different data.
*
* The rational is that some implementations of qsort() are not threadsafe.
- * For instance qsort in glibc contains a bug which makes it non-threadsafe:
+ * For instance qsort() in glibc contains a bug which makes it not threadsafe:
* http://sources.redhat.com/bugzilla/show_bug.cgi?id=11655
- * On the other hand, system qsort might be faster than our own.
+ * On the other hand, system qsort() might be faster than our own.
+ *
+ * \inlibraryapi
+ * \ingroup module_utility
*/
-#ifndef GMX_SORT_H
-#define GMX_SORT_H
+#ifndef GMX_UTILITY_QSORT_THREADSAFE_H
+#define GMX_UTILITY_QSORT_THREADSAFE_H
#include <stdlib.h>
+/* For GMX_THREAD_MPI */
+#include "config.h"
+
#ifdef __cplusplus
extern "C"
{
} /* fixes auto-indentation problems */
#endif
+/*! \addtogroup module_utility
+ * \{
+ */
+
/*! \brief
- * Portable thread-safe sort routine.
+ * Portable threadsafe sort routine.
*
* \param base Pointer to first element in list to sort
* \param nmemb Number of elements in list
* equal to, or greater than the second.
*/
void
-gmx_qsort(void * base,
+gmx_qsort(void *base,
size_t nmemb,
size_t size,
int (*compar)(const void *, const void *));
-/*! \def qsort_threadsafe
+/*! \def gmx_qsort_threadsafe
* \brief
- * Thread-safe qsort.
+ * Threadsafe qsort().
*
* Expands to gmx_qsort() if Gromacs is built with threading, or system qsort()
* otherwise.
*/
#ifdef GMX_THREAD_MPI
-#define qsort_threadsafe gmx_qsort
+#define gmx_qsort_threadsafe gmx_qsort
#else
-#define qsort_threadsafe qsort
+#define gmx_qsort_threadsafe qsort
#endif
+/*! \} */
+
#ifdef __cplusplus
}
#endif
-#endif /* GMX_SORT_H */
+#endif