From: Berk Hess Date: Mon, 15 Jun 2015 15:33:54 +0000 (+0200) Subject: Reduce the use of nbnxn_consts.h X-Git-Url: http://biod.pnpi.spb.ru/gitweb/?a=commitdiff_plain;h=737737c0ae2a56ff4dad9eafbe65379af6db6bca;p=alexxy%2Fgromacs.git Reduce the use of nbnxn_consts.h Removed reference to "half-width SIMD" (got reworked a long time ago) Change-Id: Ifcf4f8ae7d18ac14dae7c843ffe1b5787a3dbff3 --- diff --git a/src/gromacs/mdlib/calc_verletbuf.c b/src/gromacs/mdlib/calc_verletbuf.c index 774a0b138e..50415436f0 100644 --- a/src/gromacs/mdlib/calc_verletbuf.c +++ b/src/gromacs/mdlib/calc_verletbuf.c @@ -47,22 +47,12 @@ #include "gromacs/math/calculate-ewald-splitting-coefficient.h" #include "gromacs/math/units.h" #include "gromacs/math/vec.h" -#include "gromacs/mdlib/nbnxn_consts.h" +#include "gromacs/mdlib/nb_verlet.h" +#include "gromacs/mdlib/nbnxn_search.h" #include "gromacs/mdlib/nbnxn_simd.h" #include "gromacs/utility/fatalerror.h" #include "gromacs/utility/smalloc.h" -#ifdef GMX_NBNXN_SIMD -/* The include below sets the SIMD instruction type (precision+width) - * for all nbnxn SIMD search and non-bonded kernel code. - */ -#ifdef GMX_NBNXN_HALF_WIDTH_SIMD -#define GMX_USE_HALF_WIDTH_SIMD_HERE -#endif -#include "gromacs/simd/simd.h" -#endif - - /* The code in this file estimates a pairlist buffer length * given a target energy drift per atom per picosecond. * This is done by estimating the drift given a buffer length. @@ -123,25 +113,40 @@ void verletbuf_get_list_setup(gmx_bool gmx_unused bSIMD, gmx_bool bGPU, verletbuf_list_setup_t *list_setup) { + /* When calling this function we often don't know which kernel type we + * are going to use. W choose the kernel type with the smallest possible + * i- and j-cluster sizes, so we potentially overestimate, but never + * underestimate, the buffer drift. + * Note that the current buffer estimation code only handles clusters + * of size 1, 2 or 4, so for 4x8 or 8x8 we use the estimate for 4x4. + */ + if (bGPU) { - list_setup->cluster_size_i = NBNXN_GPU_CLUSTER_SIZE; - list_setup->cluster_size_j = NBNXN_GPU_CLUSTER_SIZE; + /* The CUDA kernels split the j-clusters in two halves */ + list_setup->cluster_size_i = nbnxn_kernel_to_ci_size(nbnxnk8x8x8_GPU); + list_setup->cluster_size_j = nbnxn_kernel_to_cj_size(nbnxnk8x8x8_GPU)/2; } else { - list_setup->cluster_size_i = NBNXN_CPU_CLUSTER_I_SIZE; - list_setup->cluster_size_j = NBNXN_CPU_CLUSTER_I_SIZE; + int kernel_type; + + kernel_type = nbnxnk4x4_PlainC; + #ifdef GMX_NBNXN_SIMD if (bSIMD) { - list_setup->cluster_size_j = GMX_SIMD_REAL_WIDTH; #ifdef GMX_NBNXN_SIMD_2XNN - /* We assume the smallest cluster size to be on the safe side */ - list_setup->cluster_size_j /= 2; + /* We use the smallest cluster size to be on the safe side */ + kernel_type = nbnxnk4xN_SIMD_2xNN; +#else + kernel_type = nbnxnk4xN_SIMD_4xN; #endif } #endif + + list_setup->cluster_size_i = nbnxn_kernel_to_ci_size(kernel_type); + list_setup->cluster_size_j = nbnxn_kernel_to_cj_size(kernel_type); } } diff --git a/src/gromacs/mdlib/forcerec.cpp b/src/gromacs/mdlib/forcerec.cpp index 8edb8d5879..738fce07e4 100644 --- a/src/gromacs/mdlib/forcerec.cpp +++ b/src/gromacs/mdlib/forcerec.cpp @@ -73,7 +73,6 @@ #include "gromacs/mdlib/forcerec-threading.h" #include "gromacs/mdlib/nb_verlet.h" #include "gromacs/mdlib/nbnxn_atomdata.h" -#include "gromacs/mdlib/nbnxn_consts.h" #include "gromacs/mdlib/nbnxn_gpu_data_mgmt.h" #include "gromacs/mdlib/nbnxn_search.h" #include "gromacs/mdlib/nbnxn_simd.h" @@ -1742,7 +1741,7 @@ static void pick_nbnxn_kernel(FILE *fp, { fprintf(fp, "\nUsing %s %dx%d non-bonded kernels\n\n", lookup_nbnxn_kernel_name(*kernel_type), - nbnxn_kernel_pairlist_simple(*kernel_type) ? NBNXN_CPU_CLUSTER_I_SIZE : NBNXN_GPU_CLUSTER_SIZE, + nbnxn_kernel_to_ci_size(*kernel_type), nbnxn_kernel_to_cj_size(*kernel_type)); if (nbnxnk4x4_PlainC == *kernel_type || diff --git a/src/gromacs/mdlib/nbnxn_search.c b/src/gromacs/mdlib/nbnxn_search.c index 1d48c50c92..e28c0c0e2d 100644 --- a/src/gromacs/mdlib/nbnxn_search.c +++ b/src/gromacs/mdlib/nbnxn_search.c @@ -230,7 +230,7 @@ static int get_2log(int n) return log2; } -static int nbnxn_kernel_to_ci_size(int nb_kernel_type) +int nbnxn_kernel_to_ci_size(int nb_kernel_type) { switch (nb_kernel_type) { diff --git a/src/gromacs/mdlib/nbnxn_search.h b/src/gromacs/mdlib/nbnxn_search.h index 8e644bf21a..ef57e6416d 100644 --- a/src/gromacs/mdlib/nbnxn_search.h +++ b/src/gromacs/mdlib/nbnxn_search.h @@ -1,7 +1,7 @@ /* * This file is part of the GROMACS molecular simulation package. * - * Copyright (c) 2012,2013,2014, by the GROMACS development team, led by + * Copyright (c) 2012,2013,2014,2015, 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. @@ -43,6 +43,9 @@ extern "C" { #endif +/* Returns the i-cluster size for kernel of type nb_kernel_type */ +int nbnxn_kernel_to_ci_size(int nb_kernel_type); + /* Returns the j-cluster size for kernel of type nb_kernel_type */ int nbnxn_kernel_to_cj_size(int nb_kernel_type); diff --git a/src/programs/mdrun/runner.cpp b/src/programs/mdrun/runner.cpp index 500a74d4d4..c5784a2449 100644 --- a/src/programs/mdrun/runner.cpp +++ b/src/programs/mdrun/runner.cpp @@ -76,7 +76,6 @@ #include "gromacs/math/calculate-ewald-splitting-coefficient.h" #include "gromacs/math/vec.h" #include "gromacs/mdlib/calc_verletbuf.h" -#include "gromacs/mdlib/nbnxn_consts.h" #include "gromacs/mdlib/nbnxn_search.h" #include "gromacs/pbcutil/pbc.h" #include "gromacs/pulling/pull.h"