Move gmx_omp.* into src/gromacs/utility/
authorTeemu Murtola <teemu.murtola@gmail.com>
Fri, 22 Nov 2013 18:54:00 +0000 (20:54 +0200)
committerGerrit Code Review <gerrit@gerrit.gromacs.org>
Thu, 28 Nov 2013 18:23:57 +0000 (19:23 +0100)
Changes:
 - Rename the file to gmxomp.*, analogous to other headers in the
   directory.
 - Replace the copyright headers with the new format, and put years
   there when the files have been in existence.
 - Fix Doxygen documentation to produce something reasonable.  Some
   brief descriptions are still very long...
 - Add extern "C" guards.
 - Don't install the header, as it is only an internal implementation
   detail.

Change-Id: I22d876b333534b783ef0638202939a89ce62e9d9

16 files changed:
src/gromacs/gmxana/geminate.c
src/gromacs/gmxana/gmx_hbond.c
src/gromacs/gmxana/gmx_sans.c
src/gromacs/gmxana/nsfactor.c
src/gromacs/gmxlib/gmx_omp_nthreads.c
src/gromacs/gmxlib/gmx_thread_affinity.c
src/gromacs/legacyheaders/gmx_omp.h [deleted file]
src/gromacs/mdlib/clincs.c
src/gromacs/mdlib/pme.c
src/gromacs/mdlib/update.c
src/gromacs/mdlib/vsite.c
src/gromacs/utility.h
src/gromacs/utility/CMakeLists.txt
src/gromacs/utility/gmxomp.c [moved from src/gromacs/gmxlib/gmx_omp.c with 77% similarity]
src/gromacs/utility/gmxomp.h [new file with mode: 0644]
src/programs/mdrun/runner.c

index 7f852c3b32f8d0fb760eeb0b5d402dd030e5978c..10428e0f98834866702e89ea30b6e33907e168da 100644 (file)
@@ -52,8 +52,8 @@
 #include "smalloc.h"
 #include "vec.h"
 #include "geminate.h"
-#include "gmx_omp.h"
 
+#include "gromacs/utility/gmxomp.h"
 
 /* The first few sections of this file contain functions that were adopted,
  * and to some extent modified, by Erik Marklund (erikm[aT]xray.bmc.uu.se,
index 15336ee971fb23b083084a504c6401840d1a48f2..d240dd357b13285b65273d45ae402639fdf06cc0 100644 (file)
 
 /*#define HAVE_NN_LOOPS*/
 
-#include "gmx_omp.h"
-
 #include "statutil.h"
 #include "copyrite.h"
 #include "sysstuff.h"
 #include "txtdump.h"
-#include "gromacs/fileio/futil.h"
-#include "gromacs/fileio/tpxio.h"
-#include "gromacs/fileio/trxio.h"
 #include "physics.h"
 #include "macros.h"
 #include "gmx_fatal.h"
 #include "vec.h"
 #include "xvgr.h"
 #include "gstat.h"
-#include "gromacs/fileio/matio.h"
 #include "string2.h"
 #include "pbc.h"
 #include "correl.h"
 #include "gmx_ana.h"
 #include "geminate.h"
 
+#include "gromacs/fileio/futil.h"
+#include "gromacs/fileio/matio.h"
+#include "gromacs/fileio/tpxio.h"
+#include "gromacs/fileio/trxio.h"
+#include "gromacs/utility/gmxomp.h"
+
 typedef short int t_E;
 typedef int t_EEst;
 #define max_hx 7
index 46c6ec774b916a4dbec4f0ec30b524c16822548e..3141478b7ca1bf821c31c76b7aeb5d34a92512d0 100644 (file)
 #include "pbc.h"
 #include "xvgr.h"
 #include "copyrite.h"
-#include "gromacs/fileio/futil.h"
 #include "statutil.h"
-#include "gromacs/fileio/tpxio.h"
-#include "gromacs/fileio/trxio.h"
 #include "index.h"
 #include "gstat.h"
-#include "gromacs/fileio/matio.h"
 #include "gmx_ana.h"
 #include "nsfactor.h"
-#include "gmx_omp.h"
+
+#include "gromacs/fileio/futil.h"
+#include "gromacs/fileio/matio.h"
+#include "gromacs/fileio/tpxio.h"
+#include "gromacs/fileio/trxio.h"
+#include "gromacs/utility/gmxomp.h"
 
 int gmx_sans(int argc, char *argv[])
 {
index b4dc3f2166034e944f33efe6edb736661e37c624..4bd810845c0b293b3c4808dd2407bd448b1c40e5 100644 (file)
 
 #include <ctype.h>
 #include <string.h>
-#include "gromacs/fileio/futil.h"
 #include "gmx_random.h"
 #include "smalloc.h"
 #include "sysstuff.h"
 #include "strdb.h"
 #include "vec.h"
 #include "nsfactor.h"
-#include "gmx_omp.h"
+
+#include "gromacs/fileio/futil.h"
+#include "gromacs/utility/gmxomp.h"
 
 void check_binwidth(real binwidth)
 {
index deea1a536ae820fa519a8bd6fb4d2bc001f71a69..a0cf8ecae5660b39e14222471de1eb3c8bb1a73b 100644 (file)
 #include "macros.h"
 #include "network.h"
 #include "statutil.h"
-#include "gmx_omp.h"
 #include "gmx_omp_nthreads.h"
 #include "md_logging.h"
 
+#include "gromacs/utility/gmxomp.h"
+
 /** Structure with the number of threads for each OpenMP multi-threaded
  *  algorithmic module in mdrun. */
 typedef struct
index 96111882bfc8ffa9aee27d2ad3613bcf28239f4c..0f00f0c3d9640b50c94d758e997c81eb7d727c67 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2012, by the GROMACS development team, led by
+ * Copyright (c) 2012,2013, 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 "types/commrec.h"
 #include "types/hw_info.h"
 #include "gmx_cpuid.h"
-#include "gmx_omp.h"
 #include "gmx_omp_nthreads.h"
 #include "md_logging.h"
 #include "statutil.h"
 #include "gmx_thread_affinity.h"
 
 #include "thread_mpi/threads.h"
-
+#include "gromacs/utility/gmxomp.h"
 
 static int
 get_thread_affinity_layout(FILE *fplog,
diff --git a/src/gromacs/legacyheaders/gmx_omp.h b/src/gromacs/legacyheaders/gmx_omp.h
deleted file mode 100644 (file)
index 01e5208..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-/* -*- mode: c; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; c-file-style: "stroustrup"; -*-
- *
- *
- *                This source code is part of
- *
- *                 G   R   O   M   A   C   S
- *
- *          GROningen MAchine for Chemical Simulations
- *
- * Written by the Gromacs development team under coordination of
- * David van der Spoel, Berk Hess, and Erik Lindahl.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * To help us fund GROMACS development, we humbly ask that you cite
- * the research papers on the package. Check out http://www.gromacs.org
- *
- * And Hey:
- * GROup of MAchos and Cynical Suckers
- */
-
-#ifndef GMX_OMP_H
-#define GMX_OMP_H
-
-#include "types/commrec.h"
-#include "mdrun.h"
-
-/* This module defines wrappers for OpenMP API functions and enables compiling
- * code even when OpenMP is turned off in the build system.
- * Therefore, OpenMP API functions should always be used through these wrappers
- * and omp.h should never be directly included. Instead, this header should be
- * used whenever OpenMP API functions are needed.
- */
-
-/*! Returns an integer equal to or greater than the number of threads
- *  that would be available if a parallel region without num_threads were
- *  defined at that point in the code. Acts as a wrapper for omp_set_num_threads(void). */
-int  gmx_omp_get_max_threads(void);
-
-/*! Returns the number of processors available when the function is called.
- *  Acts as a wrapper around omp_get_num_procs() */
-int gmx_omp_get_num_procs(void);
-
-/*! Returns the thread number of the thread executing within its thread team.
- *  Acts as a wrapper for omp_get_thread_num(void). */
-int  gmx_omp_get_thread_num(void);
-
-/*! Sets the number of threads in subsequent parallel regions, unless overridden
- *  by a num_threads clause. Acts as a wrapper for omp_get_max_threads(void). */
-void gmx_omp_set_num_threads(int num_threads);
-
-/*! Check for externally set thread affinity to avoid conflicts with GROMACS internal setting. */
-void gmx_omp_check_thread_affinity(FILE *fplog, const t_commrec *cr,
-                                   gmx_hw_opt_t *hw_opt);
-
-#endif /* GMX_OMP_H */
index fd6041c7e4c5403c27251bc2a874447f5d296c72..b2f48afca262fce736c8544396b264a9a876c896 100644 (file)
 #include "domdec.h"
 #include "partdec.h"
 #include "mtop_util.h"
-#include "gromacs/fileio/gmxfio.h"
 #include "gmx_omp_nthreads.h"
-#include "gmx_omp.h"
+
+#include "gromacs/fileio/gmxfio.h"
+#include "gromacs/utility/gmxomp.h"
 
 typedef struct {
     int    b0;         /* first constraint for this thread */
index 2b901043491d9575cdfbba4dea8cd016d621c6c8..bc2f8580b5e6759759bfd40bc2456164b720ea22 100644 (file)
@@ -75,7 +75,6 @@
 #include "network.h"
 #include "physics.h"
 #include "nrnb.h"
-#include "gmx_omp.h"
 #include "macros.h"
 
 #include "gromacs/fft/parallel_3dfft.h"
@@ -84,6 +83,7 @@
 #include "gromacs/timing/cyclecounter.h"
 #include "gromacs/timing/wallcycle.h"
 #include "gromacs/utility/gmxmpi.h"
+#include "gromacs/utility/gmxomp.h"
 
 /* Include the SIMD macro file and then check for support */
 #include "gmx_simd_macros.h"
@@ -247,7 +247,7 @@ typedef struct {
     /* Masks for 4-wide SIMD aligned spreading and gathering */
     gmx_simd4_pb mask_S0[6], mask_S1[6];
 #else
-    int    dummy; /* C89 requires that struct has at least one member */
+    int          dummy; /* C89 requires that struct has at least one member */
 #endif
 } pme_spline_work_t;
 
index d1da13c2db39f946a919436bce741a059f358fa4..c28bcfe2d6ac3923878fe9514322f9a973b88c17 100644 (file)
 #include "disre.h"
 #include "orires.h"
 #include "gmx_omp_nthreads.h"
-#include "gmx_omp.h"
 
 #include "gromacs/fileio/confio.h"
 #include "gromacs/fileio/futil.h"
 #include "gromacs/timing/wallcycle.h"
+#include "gromacs/utility/gmxomp.h"
 
 /*For debugging, start at v(-dt/2) for velolcity verlet -- uncomment next line */
 /*#define STARTFROMDT2*/
@@ -758,9 +758,9 @@ static void check_sd2_work_data_allocation(gmx_stochd_t *sd, int nrend)
 }
 
 static void do_update_sd2_Tconsts(gmx_stochd_t *sd,
-                                  int ngtc,
-                                  const real tau_t[],
-                                  const real ref_t[])
+                                  int           ngtc,
+                                  const real    tau_t[],
+                                  const real    ref_t[])
 {
     /* This is separated from the update below, because it is single threaded */
     gmx_sd_const_t *sdc;
index 3ac9b179271bd5523872d526b49c5d68f9fee65c..049d3d7ac7b425b601a35ee51aa798f336953548 100644 (file)
@@ -52,7 +52,8 @@
 #include "partdec.h"
 #include "mtop_util.h"
 #include "gmx_omp_nthreads.h"
-#include "gmx_omp.h"
+
+#include "gromacs/utility/gmxomp.h"
 
 /* Routines to send/recieve coordinates and force
  * of constructing atoms.
index 44a493fdb690ffd935b19e392f18b7bb93166675..78044cb3f62f8cdc7c9d7b0ac8284c563bf0752c 100644 (file)
  *
  * \if libapi
  *
- * The header gmxmpi.h abstract away the mechanism of including either MPI or
+ * The header gmxmpi.h abstracts away the mechanism of including either MPI or
  * thread-MPI headers depending on compilation options.
+ * Similarly, gmxomp.h removes the need to use conditional compilation for code
+ * that needs to include omp.h for OpenMP functions.
  *
  * The header gmxregex.h declares gmx::Regex and regexMatch() for basic regular
  * expression matching using an interface similar to C++11.
index 3fe0b73feb3c64f407341cb2b14aa484dc4b1498..1054ed5863e14a8258621116e119c8c37ab8f0ca 100644 (file)
@@ -32,7 +32,7 @@
 # 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 UTILITY_SOURCES *.cpp)
+file(GLOB UTILITY_SOURCES *.c *.cpp)
 set(LIBGROMACS_SOURCES ${LIBGROMACS_SOURCES} ${UTILITY_SOURCES} PARENT_SCOPE)
 
 set(GENERATED_HEADER_CONFIG ${CMAKE_CURRENT_BINARY_DIR}/gmx_header_config_gen.h)
similarity index 77%
rename from src/gromacs/gmxlib/gmx_omp.c
rename to src/gromacs/utility/gmxomp.c
index 9dea548dc72f70aba40e4fe3b33f7dae29e8572d..8f12bb8985df8cd3fb36887d6d0e2906a5459b01 100644 (file)
@@ -1,30 +1,46 @@
-/* -*- mode: c; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; c-file-style: "stroustrup"; -*-
+/*
+ * This file is part of the GROMACS molecular simulation package.
  *
+ * Copyright (c) 2012,2013, 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.
  *
- *                This source code is part of
+ * GROMACS is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * as published by the Free Software Foundation; either version 2.1
+ * of the License, or (at your option) any later version.
  *
- *                 G   R   O   M   A   C   S
+ * GROMACS is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
  *
- *          GROningen MAchine for Chemical Simulations
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with GROMACS; if not, see
+ * http://www.gnu.org/licenses, or write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA.
  *
- * Written by the Gromacs development team under coordination of
- * David van der Spoel, Berk Hess, and Erik Lindahl.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * If you want to redistribute modifications to GROMACS, please
+ * consider that scientific software is very special. Version
+ * control is crucial - bugs must be traceable. We will be happy to
+ * consider code for inclusion in the official distribution, but
+ * derived work must not be called official GROMACS. Details are found
+ * in the README & COPYING files - if they are missing, get the
+ * official version 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
+ * the research papers on the package. Check out http://www.gromacs.org.
+ */
+/*! \internal \file
+ * \brief
+ * Implements functions from gmxomp.h.
  *
- * And Hey:
- * Gnomes, ROck Monsters And Chili Sauce
+ * \ingroup module_utility
  */
+#include "gromacs/utility/gmxomp.h"
 
-#ifdef HAVE_CONFIG_H
 #include "config.h"
-#endif
 
 #ifdef GMX_OPENMP
 #include <omp.h>
@@ -36,7 +52,6 @@
 #include "gmx_fatal.h"
 #include "statutil.h"
 #include "string2.h"
-#include "gmx_omp.h"
 
 int gmx_omp_get_max_threads(void)
 {
diff --git a/src/gromacs/utility/gmxomp.h b/src/gromacs/utility/gmxomp.h
new file mode 100644 (file)
index 0000000..d65fa52
--- /dev/null
@@ -0,0 +1,107 @@
+/*
+ * This file is part of the GROMACS molecular simulation package.
+ *
+ * Copyright (c) 2012,2013, 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.
+ *
+ * GROMACS is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * as published by the Free Software Foundation; either version 2.1
+ * of the License, or (at your option) any later version.
+ *
+ * GROMACS is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with GROMACS; if not, see
+ * http://www.gnu.org/licenses, or write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA.
+ *
+ * If you want to redistribute modifications to GROMACS, please
+ * consider that scientific software is very special. Version
+ * control is crucial - bugs must be traceable. We will be happy to
+ * consider code for inclusion in the official distribution, but
+ * derived work must not be called official GROMACS. Details are found
+ * in the README & COPYING files - if they are missing, get the
+ * official version 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.
+ */
+/*! \libinternal \file
+ * \brief
+ * Declares OpenMP wrappers to avoid conditional compilation.
+ *
+ * This module defines wrappers for OpenMP API functions and enables compiling
+ * code without conditional compilation even when OpenMP is turned off in the
+ * build system.
+ * Therefore, OpenMP API functions should always be used through these wrappers
+ * and omp.h should never be directly included.  Instead, this header should be
+ * used whenever OpenMP API functions are needed.
+ *
+ * \ingroup module_utility
+ */
+#ifndef GMX_UTILITY_OMP_H
+#define GMX_UTILITY_OMP_H
+
+#include "types/commrec.h"
+#include "mdrun.h"
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/*! \addtogroup module_utility
+ * \{
+ */
+
+/*! \brief
+ * Returns an integer equal to or greater than the number of threads
+ * that would be available if a parallel region without num_threads were
+ * defined at that point in the code.
+ *
+ * Acts as a wrapper for omp_get_max_threads().
+ */
+int gmx_omp_get_max_threads(void);
+
+/*! \brief
+ * Returns the number of processors available when the function is called.
+ *
+ * Acts as a wrapper around omp_get_num_procs().
+ */
+int gmx_omp_get_num_procs(void);
+
+/*! \brief
+ * Returns the thread number of the thread executing within its thread team.
+ *
+ * Acts as a wrapper for omp_get_thread_num().
+ */
+int gmx_omp_get_thread_num(void);
+
+/*! \brief
+ * Sets the number of threads in subsequent parallel regions, unless overridden
+ * by a num_threads clause.
+ *
+ * Acts as a wrapper for omp_set_num_threads().
+ */
+void gmx_omp_set_num_threads(int num_threads);
+
+/*! \brief
+ * Check for externally set thread affinity to avoid conflicts with \Gromacs
+ * internal setting.
+ */
+void gmx_omp_check_thread_affinity(FILE *fplog, const t_commrec *cr,
+                                   gmx_hw_opt_t *hw_opt);
+
+/*! \} */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
index 13a23763cb656661e7763fb087c9fa143f45fb9d..dd7f78349377e82f3550c58b4a7fd6c6fd2e263e 100644 (file)
@@ -78,7 +78,6 @@
 #include "gmx_fatal_collective.h"
 #include "membed.h"
 #include "macros.h"
-#include "gmx_omp.h"
 #include "gmx_thread_affinity.h"
 
 #include "gromacs/fileio/tpxio.h"
@@ -86,6 +85,7 @@
 #include "gromacs/mdlib/nbnxn_consts.h"
 #include "gromacs/timing/wallcycle.h"
 #include "gromacs/utility/gmxmpi.h"
+#include "gromacs/utility/gmxomp.h"
 
 #ifdef GMX_FAHCORE
 #include "corewrap.h"
@@ -987,7 +987,7 @@ static void free_gpu_resources(FILE             *fplog,
         {
             gmx_barrier(cr);
         }
-#endif /* GMX_THREAD_MPI */
+#endif  /* GMX_THREAD_MPI */
 
         /* uninitialize GPU (by destroying the context) */
         if (!free_gpu(gpu_err_str))