Merge release-5-0 into master
[alexxy/gromacs.git] / src / gromacs / ewald / pme.c
similarity index 99%
rename from src/gromacs/mdlib/pme.c
rename to src/gromacs/ewald/pme.c
index 82b597d5f0c3eeea5fc1a180b9ed4497480f833c..3a5c710a957c3eb69330a6c192234c5371fc59d8 100644 (file)
  * /Erik 001109
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "gmxpre.h"
 
-#include <stdio.h>
-#include <string.h>
-#include <math.h>
-#include <assert.h>
-#include "typedefs.h"
-#include "txtdump.h"
-#include "vec.h"
-#include "gromacs/utility/smalloc.h"
-#include "coulomb.h"
-#include "gmx_fatal.h"
 #include "pme.h"
-#include "network.h"
-#include "physics.h"
-#include "nrnb.h"
-#include "macros.h"
 
+#include "config.h"
+
+#include <assert.h>
+#include <math.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "gromacs/ewald/pme-internal.h"
+#include "gromacs/fft/fft.h"
 #include "gromacs/fft/parallel_3dfft.h"
-#include "gromacs/fileio/futil.h"
-#include "gromacs/fileio/pdbio.h"
+#include "gromacs/legacyheaders/macros.h"
+#include "gromacs/legacyheaders/nrnb.h"
+#include "gromacs/legacyheaders/types/commrec.h"
+#include "gromacs/legacyheaders/types/enums.h"
+#include "gromacs/legacyheaders/types/forcerec.h"
+#include "gromacs/legacyheaders/types/inputrec.h"
+#include "gromacs/legacyheaders/types/nrnb.h"
 #include "gromacs/math/gmxcomplex.h"
+#include "gromacs/math/units.h"
+#include "gromacs/math/vec.h"
+#include "gromacs/math/vectypes.h"
+/* Include the SIMD macro file and then check for support */
+#include "gromacs/simd/simd.h"
+#include "gromacs/simd/simd_math.h"
 #include "gromacs/timing/cyclecounter.h"
 #include "gromacs/timing/wallcycle.h"
+#include "gromacs/timing/walltime_accounting.h"
+#include "gromacs/utility/basedefinitions.h"
+#include "gromacs/utility/fatalerror.h"
 #include "gromacs/utility/gmxmpi.h"
 #include "gromacs/utility/gmxomp.h"
+#include "gromacs/utility/real.h"
+#include "gromacs/utility/smalloc.h"
+
+#ifdef DEBUG_PME
+#include "gromacs/fileio/pdbio.h"
+#include "gromacs/utility/cstringutil.h"
+#include "gromacs/utility/futil.h"
+#endif
 
-/* Include the SIMD macro file and then check for support */
-#include "gromacs/simd/simd.h"
-#include "gromacs/simd/simd_math.h"
 #ifdef GMX_SIMD_HAVE_REAL
 /* Turn on arbitrary width SIMD intrinsics for PME solve */
 #    define PME_SIMD_SOLVE
@@ -165,6 +177,8 @@ typedef struct {
     int recv_size;   /* Receive buffer width, used with OpenMP */
 } pme_grid_comm_t;
 
+typedef real *splinevec[DIM];
+
 typedef struct {
 #ifdef GMX_MPI
     MPI_Comm         mpi_comm;
@@ -1433,7 +1447,7 @@ static void spread_coefficients_bsplines_thread(pmegrid_t                    *pm
 #define PME_SPREAD_SIMD4_ALIGNED
 #define PME_ORDER 4
 #endif
-#include "pme_simd4.h"
+#include "gromacs/ewald/pme-simd4.h" /* IWYU pragma: keep */
 #else
                     DO_BSPLINE(4);
 #endif
@@ -1442,7 +1456,7 @@ static void spread_coefficients_bsplines_thread(pmegrid_t                    *pm
 #ifdef PME_SIMD4_SPREAD_GATHER
 #define PME_SPREAD_SIMD4_ALIGNED
 #define PME_ORDER 5
-#include "pme_simd4.h"
+#include "gromacs/ewald/pme-simd4.h" /* IWYU pragma: keep */
 #else
                     DO_BSPLINE(5);
 #endif
@@ -1742,7 +1756,7 @@ static void pmegrids_destroy(pmegrids_t *grids)
 
 static void realloc_work(pme_work_t *work, int nkx)
 {
-    int simd_width;
+    int simd_width, i;
 
     if (nkx > work->nalloc)
     {
@@ -1769,6 +1783,12 @@ static void realloc_work(pme_work_t *work, int nkx)
         snew_aligned(work->tmp2,  work->nalloc+simd_width, simd_width*sizeof(real));
         snew_aligned(work->eterm, work->nalloc+simd_width, simd_width*sizeof(real));
         srenew(work->m2inv, work->nalloc);
+#ifndef NDEBUG
+        for (i = 0; i < work->nalloc+simd_width; i++)
+        {
+            work->denom[i] = 1; /* init to 1 to avoid 1/0 exceptions of simd padded elements */
+        }
+#endif
     }
 }
 
@@ -2596,7 +2616,7 @@ static void gather_f_bsplines(gmx_pme_t pme, real *grid,
 #define PME_GATHER_F_SIMD4_ALIGNED
 #define PME_ORDER 4
 #endif
-#include "pme_simd4.h"
+#include "gromacs/ewald/pme-simd4.h" /* IWYU pragma: keep */
 #else
                     DO_FSPLINE(4);
 #endif
@@ -2605,7 +2625,7 @@ static void gather_f_bsplines(gmx_pme_t pme, real *grid,
 #ifdef PME_SIMD4_SPREAD_GATHER
 #define PME_GATHER_F_SIMD4_ALIGNED
 #define PME_ORDER 5
-#include "pme_simd4.h"
+#include "gromacs/ewald/pme-simd4.h" /* IWYU pragma: keep */
 #else
                     DO_FSPLINE(5);
 #endif