* 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 "gmxpre.h"
+
+#include "gromacs/legacyheaders/nonbonded.h"
-#include "gromacs/legacyheaders/thread_mpi/threads.h"
+#include "config.h"
#include <stdio.h>
#include <stdlib.h>
-#include "typedefs.h"
-#include "txtdump.h"
-#include "smalloc.h"
-#include "ns.h"
-#include "vec.h"
+
+#include "thread_mpi/threads.h"
+
+#include "gromacs/bonded/bonded.h"
+#include "gromacs/gmxlib/nonbonded/nb_free_energy.h"
+#include "gromacs/gmxlib/nonbonded/nb_generic.h"
+#include "gromacs/gmxlib/nonbonded/nb_generic_adress.h"
+#include "gromacs/gmxlib/nonbonded/nb_generic_cg.h"
+#include "gromacs/gmxlib/nonbonded/nb_kernel.h"
+#include "gromacs/legacyheaders/force.h"
+#include "gromacs/legacyheaders/macros.h"
+#include "gromacs/legacyheaders/names.h"
+#include "gromacs/legacyheaders/nrnb.h"
+#include "gromacs/legacyheaders/ns.h"
+#include "gromacs/legacyheaders/txtdump.h"
+#include "gromacs/legacyheaders/typedefs.h"
#include "gromacs/math/utilities.h"
-#include "macros.h"
-#include "string2.h"
-#include "force.h"
-#include "names.h"
-#include "main.h"
-#include "xvgr.h"
-#include "gmx_fatal.h"
-#include "physics.h"
-#include "force.h"
-#include "bondf.h"
-#include "nrnb.h"
-#include "smalloc.h"
-#include "nonbonded.h"
-
-#include "nb_kernel.h"
-#include "nb_free_energy.h"
-#include "nb_generic.h"
-#include "nb_generic_cg.h"
-#include "nb_generic_adress.h"
-
-/* Different default (c) and accelerated interaction-specific kernels */
-#include "nb_kernel_c/nb_kernel_c.h"
+#include "gromacs/math/vec.h"
+#include "gromacs/pbcutil/ishift.h"
+#include "gromacs/pbcutil/mshift.h"
+#include "gromacs/pbcutil/pbc.h"
+#include "gromacs/simd/simd.h"
+#include "gromacs/utility/cstringutil.h"
+#include "gromacs/utility/fatalerror.h"
+#include "gromacs/utility/smalloc.h"
+
+/* Different default (c) and SIMD instructions interaction-specific kernels */
+#include "gromacs/gmxlib/nonbonded/nb_kernel_c/nb_kernel_c.h"
#if (defined GMX_SIMD_X86_SSE2) && !(defined GMX_DOUBLE)
-# include "nb_kernel_sse2_single/nb_kernel_sse2_single.h"
+# include "gromacs/gmxlib/nonbonded/nb_kernel_sse2_single/nb_kernel_sse2_single.h"
#endif
#if (defined GMX_SIMD_X86_SSE4_1) && !(defined GMX_DOUBLE)
-# include "nb_kernel_sse4_1_single/nb_kernel_sse4_1_single.h"
+# include "gromacs/gmxlib/nonbonded/nb_kernel_sse4_1_single/nb_kernel_sse4_1_single.h"
#endif
#if (defined GMX_SIMD_X86_AVX_128_FMA) && !(defined GMX_DOUBLE)
-# include "nb_kernel_avx_128_fma_single/nb_kernel_avx_128_fma_single.h"
+# include "gromacs/gmxlib/nonbonded/nb_kernel_avx_128_fma_single/nb_kernel_avx_128_fma_single.h"
#endif
-#if (defined GMX_SIMD_X86_AVX_256) && !(defined GMX_DOUBLE)
-# include "nb_kernel_avx_256_single/nb_kernel_avx_256_single.h"
+#if (defined GMX_SIMD_X86_AVX_256_OR_HIGHER) && !(defined GMX_DOUBLE)
+# include "gromacs/gmxlib/nonbonded/nb_kernel_avx_256_single/nb_kernel_avx_256_single.h"
#endif
#if (defined GMX_SIMD_X86_SSE2 && defined GMX_DOUBLE)
-# include "nb_kernel_sse2_double/nb_kernel_sse2_double.h"
+# include "gromacs/gmxlib/nonbonded/nb_kernel_sse2_double/nb_kernel_sse2_double.h"
#endif
#if (defined GMX_SIMD_X86_SSE4_1 && defined GMX_DOUBLE)
-# include "nb_kernel_sse4_1_double/nb_kernel_sse4_1_double.h"
+# include "gromacs/gmxlib/nonbonded/nb_kernel_sse4_1_double/nb_kernel_sse4_1_double.h"
#endif
#if (defined GMX_SIMD_X86_AVX_128_FMA && defined GMX_DOUBLE)
-# include "nb_kernel_avx_128_fma_double/nb_kernel_avx_128_fma_double.h"
+# include "gromacs/gmxlib/nonbonded/nb_kernel_avx_128_fma_double/nb_kernel_avx_128_fma_double.h"
#endif
-#if (defined GMX_SIMD_X86_AVX_256 && defined GMX_DOUBLE)
-# include "nb_kernel_avx_256_double/nb_kernel_avx_256_double.h"
+#if (defined GMX_SIMD_X86_AVX_256_OR_HIGHER && defined GMX_DOUBLE)
+# include "gromacs/gmxlib/nonbonded/nb_kernel_avx_256_double/nb_kernel_avx_256_double.h"
#endif
#if (defined GMX_SIMD_SPARC64_HPC_ACE && defined GMX_DOUBLE)
-# include "nb_kernel_sparc64_hpc_ace_double/nb_kernel_sparc64_hpc_ace_double.h"
+# include "gromacs/gmxlib/nonbonded/nb_kernel_sparc64_hpc_ace_double/nb_kernel_sparc64_hpc_ace_double.h"
#endif
#if (defined GMX_SIMD_X86_AVX_128_FMA) && !(defined GMX_DOUBLE)
nb_kernel_list_add_kernels(kernellist_avx_128_fma_single, kernellist_avx_128_fma_single_size);
#endif
-#if (defined GMX_SIMD_X86_AVX_256) && !(defined GMX_DOUBLE)
+#if (defined GMX_SIMD_X86_AVX_256_OR_HIGHER) && !(defined GMX_DOUBLE)
nb_kernel_list_add_kernels(kernellist_avx_256_single, kernellist_avx_256_single_size);
#endif
/* Double precision */
#if (defined GMX_SIMD_X86_AVX_128_FMA && defined GMX_DOUBLE)
nb_kernel_list_add_kernels(kernellist_avx_128_fma_double, kernellist_avx_128_fma_double_size);
#endif
-#if (defined GMX_SIMD_X86_AVX_256 && defined GMX_DOUBLE)
+#if (defined GMX_SIMD_X86_AVX_256_OR_HIGHER && defined GMX_DOUBLE)
nb_kernel_list_add_kernels(kernellist_avx_256_double, kernellist_avx_256_double_size);
#endif
#if (defined GMX_SIMD_SPARC64_HPC_ACE && defined GMX_DOUBLE)
void
-gmx_nonbonded_set_kernel_pointers(FILE *log, t_nblist *nl)
+gmx_nonbonded_set_kernel_pointers(FILE *log, t_nblist *nl, gmx_bool bElecAndVdwSwitchDiffers)
{
const char * elec;
const char * elec_mod;
arch_and_padding[] =
{
/* Single precision */
-#if (defined GMX_SIMD_X86_AVX_256) && !(defined GMX_DOUBLE)
+#if (defined GMX_SIMD_X86_AVX_256_OR_HIGHER) && !(defined GMX_DOUBLE)
{ "avx_256_single", 8 },
#endif
#if (defined GMX_SIMD_X86_AVX_128_FMA) && !(defined GMX_DOUBLE)
{ "sse2_single", 4 },
#endif
/* Double precision */
-#if (defined GMX_SIMD_X86_AVX_256 && defined GMX_DOUBLE)
+#if (defined GMX_SIMD_X86_AVX_256_OR_HIGHER && defined GMX_DOUBLE)
{ "avx_256_double", 4 },
#endif
#if (defined GMX_SIMD_X86_AVX_128_FMA && defined GMX_DOUBLE)
}
}
- /* Give up, pick a generic one instead */
- if (nl->kernelptr_vf == NULL)
+ /* For now, the accelerated kernels cannot handle the combination of switch functions for both
+ * electrostatics and VdW that use different switch radius or switch cutoff distances
+ * (both of them enter in the switch function calculation). This would require
+ * us to evaluate two completely separate switch functions for every interaction.
+ * Instead, we disable such kernels by setting the pointer to NULL.
+ * This will cause the generic kernel (which can handle it) to be called instead.
+ *
+ * Note that we typically already enable tabulated coulomb interactions for this case,
+ * so this is mostly a safe-guard to make sure we call the generic kernel if the
+ * tables are disabled.
+ */
+ if ((nl->ielec != GMX_NBKERNEL_ELEC_NONE) && (nl->ielecmod == eintmodPOTSWITCH) &&
+ (nl->ivdw != GMX_NBKERNEL_VDW_NONE) && (nl->ivdwmod == eintmodPOTSWITCH) &&
+ bElecAndVdwSwitchDiffers)
+ {
+ nl->kernelptr_vf = NULL;
+ nl->kernelptr_f = NULL;
+ }
+
+ /* Give up, pick a generic one instead.
+ * We only do this for particle-particle kernels; by leaving the water-optimized kernel
+ * pointers to NULL, the water optimization will automatically be disabled for this interaction.
+ */
+ if (nl->kernelptr_vf == NULL && !gmx_strcasecmp_min(geom, "Particle-Particle"))
{
nl->kernelptr_vf = (void *) gmx_nb_generic_kernel;
nl->kernelptr_f = (void *) gmx_nb_generic_kernel;
fprintf(debug,
"WARNING - Slow generic NB kernel used for neighborlist with\n"
" Elec: '%s', Modifier: '%s'\n"
- " Vdw: '%s', Modifier: '%s'\n"
- " Geom: '%s', Other: '%s'\n\n",
- elec, elec_mod, vdw, vdw_mod, geom, other);
+ " Vdw: '%s', Modifier: '%s'\n",
+ elec, elec_mod, vdw, vdw_mod);
}
}
}
-
return;
}
nlist = nblists->nlist_sr;
f = f_shortrange;
}
- else if (range == 1)
+ else
{
/* Long-range */
if (!(flags & GMX_NONBONDED_DO_LR))
/* We don't need the non-perturbed interactions */
continue;
}
- (*kernelptr)(&(nlist[i]), x, f, fr, mdatoms, &kernel_data, nrnb);
+ /* Neighborlists whose kernelptr==NULL will always be empty */
+ if (kernelptr != NULL)
+ {
+ (*kernelptr)(&(nlist[i]), x, f, fr, mdatoms, &kernel_data, nrnb);
+ }
+ else
+ {
+ gmx_fatal(FARGS, "Non-empty neighborlist does not have any kernel pointer assigned.");
+ }
}
}
}
if (r2 >= fr->tab14.r*fr->tab14.r)
{
+ /* This check isn't race free. But it doesn't matter because if a race occurs the only
+ * disadvantage is that the warning is printed twice */
if (warned_rlimit == FALSE)
{
nb_listed_warning_rlimit(x, ai, aj, global_atom_index, sqrt(r2), fr->tab14.r);