Move gmx_sort.* to src/gromacs/utility/
authorTeemu Murtola <teemu.murtola@gmail.com>
Thu, 2 Jan 2014 15:48:53 +0000 (17:48 +0200)
committerGerrit Code Review <gerrit@gerrit.gromacs.org>
Wed, 8 Jan 2014 23:11:30 +0000 (00:11 +0100)
This particular header doesn't need to be installed, since it is only an
implementation detail.

One more header away from legacyheaders/ and from installed headers.

Change-Id: I8a1b511859c370be72fd3da86c613e2f222fe50d

src/gromacs/gmxana/gmx_trjconv.c
src/gromacs/legacyheaders/inputrec.h
src/gromacs/mdlib/domdec.c
src/gromacs/mdlib/pull_rotation.c
src/gromacs/utility.h
src/gromacs/utility/qsort_threadsafe.c [moved from src/gromacs/gmxlib/gmx_sort.c with 97% similarity]
src/gromacs/utility/qsort_threadsafe.h [moved from src/gromacs/legacyheaders/gmx_sort.h with 76% similarity]

index 778cb90e98f829271cde51caa9641ac3d23deae4..1f6a961cb2f1d42ce07e47f58e8acca663794b90 100644 (file)
@@ -3,7 +3,7 @@
  *
  * 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.
@@ -65,7 +65,6 @@
 #include "viewit.h"
 #include "xvgr.h"
 #include "gmx_ana.h"
-#include "gmx_sort.h"
 
 #ifdef HAVE_UNISTD_H
 #include <unistd.h>
index a62dd1da9c0f0502ca69e4ed2e264f9be24c6e9a..f3d0e33874fadecfc3d2b9ed3f8737d53a0d85ba 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * 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"
 
@@ -74,4 +62,4 @@ int ir_optimal_nstpcouple(const t_inputrec *ir);
 #endif
 
 
-#endif /* _GMX_INPUTREC_H_ */
+#endif
index 640376ba7e1e46d1faf5e633976591c5d67ae094..da45b8f573fff3b2230921e3d39ab641801ee20c 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * 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.
@@ -64,7 +64,6 @@
 #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"
@@ -76,6 +75,7 @@
 #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)
@@ -8896,7 +8896,7 @@ static void ordered_sort(int nsort2, gmx_cgsort_t *sort2,
     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;
@@ -9009,7 +9009,7 @@ static int dd_sort_order(gmx_domdec_t *dd, t_forcerec *fr, int ncg_home_old)
             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;
index 9973cfeb93b0126443a386b34ee8036bc98862f2..aaef3d70fcbc02ab0f9b0f2078b0176fd3a7f972 100644 (file)
@@ -3,7 +3,7 @@
  *
  * 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.
@@ -56,7 +56,6 @@
 #include "xvgr.h"
 #include "groupcoord.h"
 #include "pull_rotation.h"
-#include "gmx_sort.h"
 #include "copyrite.h"
 #include "macros.h"
 
@@ -65,6 +64,7 @@
 #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:"};
 
index 78044cb3f62f8cdc7c9d7b0ac8284c563bf0752c..1d0f84b6366ef58cc290456fe43e9b9675dda0dc 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * 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>
similarity index 97%
rename from src/gromacs/gmxlib/gmx_sort.c
rename to src/gromacs/utility/qsort_threadsafe.c
index 5e94c36a2fd4e1fafbed6f4b9c170b415ebb0123..347080bfe7a5741905217c8959f6cebea251b7d5 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * 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,
similarity index 76%
rename from src/gromacs/legacyheaders/gmx_sort.h
rename to src/gromacs/utility/qsort_threadsafe.h
index c03637ae87c69f5069cbd2b1a0c2c07685813220..b842bb12c08d457b6ba2b5f7c1c997e1d2cff6f8 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * 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"
 {
@@ -58,8 +64,12 @@ 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
@@ -71,27 +81,29 @@ extern "C"
  *                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