Merge release-4-6 into master
[alexxy/gromacs.git] / src / gromacs / mdlib / nbnxn_consts.h
1 /* -*- mode: c; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; c-file-style: "stroustrup"; -*-
2  *
3  *
4  *                This source code is part of
5  *
6  *                 G   R   O   M   A   C   S
7  *
8  *          GROningen MAchine for Chemical Simulations
9  *
10  * Written by David van der Spoel, Erik Lindahl, Berk Hess, and others.
11  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
12  * Copyright (c) 2001-2012, The GROMACS development team,
13  * check out http://www.gromacs.org for more information.
14  *
15  * This program is free software; you can redistribute it and/or
16  * modify it under the terms of the GNU General Public License
17  * as published by the Free Software Foundation; either version 2
18  * of the License, or (at your option) any later version.
19  *
20  * If you want to redistribute modifications, please consider that
21  * scientific software is very special. Version control is crucial -
22  * bugs must be traceable. We will be happy to consider code for
23  * inclusion in the official distribution, but derived work must not
24  * be called official GROMACS. Details are found in the README & COPYING
25  * files - if they are missing, get the official version at www.gromacs.org.
26  *
27  * To help us fund GROMACS development, we humbly ask that you cite
28  * the papers on the package - you can find them in the top README file.
29  *
30  * For more info, check our website at http://www.gromacs.org
31  *
32  * And Hey:
33  * Gallium Rubidium Oxygen Manganese Argon Carbon Silicon
34  */
35
36 #ifndef _nbnxn_consts_h
37 #define _nbnxn_consts_h
38
39 #ifdef __cplusplus
40 extern "C" {
41 #endif
42
43
44 /* The number of pair-search sub-cells per super-cell, used for GPU */
45 #define GPU_NSUBCELL_Z 2
46 #define GPU_NSUBCELL_Y 2
47 #define GPU_NSUBCELL_X 2
48 #define GPU_NSUBCELL   (GPU_NSUBCELL_Z*GPU_NSUBCELL_Y*GPU_NSUBCELL_X)
49 /* In the non-bonded GPU kernel we operate on cluster-pairs, not cells.
50  * The number of cluster in a super-cluster matches the number of sub-cells
51  * in a pair-search cell, so we introduce a new name for the same value.
52  */
53 #define NBNXN_GPU_NCLUSTER_PER_SUPERCLUSTER  GPU_NSUBCELL
54
55 /* With CPU kernels the i-cluster size is always 4 atoms.
56  * With x86 SIMD the j-cluster size can be 2, 4 or 8, otherwise 4.
57  */
58 #define NBNXN_CPU_CLUSTER_I_SIZE       4
59
60 #define NBNXN_CPU_CLUSTER_I_SIZE_2LOG  2
61
62 /* With GPU kernels the cluster size is 8 atoms */
63 #define NBNXN_GPU_CLUSTER_SIZE         8
64
65 /* With GPU kernels we group cluster pairs in 4 to optimize memory usage.
66  * To change this, also change nbnxn_cj4_t in include/types/nbnxn_pairlist.h.
67  */
68 #define NBNXN_GPU_JGROUP_SIZE       4
69 #define NBNXN_GPU_JGROUP_SIZE_2LOG  2
70
71 /* To avoid NaN when excluded atoms are at zero distance, we add a small
72  * number to r^2. NBNXN_AVOID_SING_R2_INC^-3 should fit in real.
73  */
74 #ifndef GMX_DOUBLE
75 #define NBNXN_AVOID_SING_R2_INC  1.0e-12f
76 #else
77 /* The double prec. x86 SIMD kernels use a single prec. invsqrt, so > 1e-38 */
78 #define NBNXN_AVOID_SING_R2_INC  1.0e-36
79 #endif
80
81 /* Coulomb force table size chosen such that it fits along the non-bonded
82    parameters in the texture cache. */
83 #define GPU_EWALD_COULOMB_FORCE_TABLE_SIZE 1536
84
85
86 /* Strides for x/f with xyz and xyzq coordinate (and charge) storage */
87 #define STRIDE_XYZ   3
88 #define STRIDE_XYZQ  4
89 /* Size of packs of x, y or z with SSE/AVX packed coords/forces */
90 #define PACK_X4      4
91 #define PACK_X8      8
92 /* Strides for a pack of 4 and 8 coordinates/forces */
93 #define STRIDE_P4    (DIM*PACK_X4)
94 #define STRIDE_P8    (DIM*PACK_X8)
95
96 /* Index of atom a into the SSE/AVX coordinate/force array */
97 #define X4_IND_A(a)  (STRIDE_P4*((a) >> 2) + ((a) & (PACK_X4 - 1)))
98 #define X8_IND_A(a)  (STRIDE_P8*((a) >> 3) + ((a) & (PACK_X8 - 1)))
99
100
101 #ifdef __cplusplus
102 }
103 #endif
104
105 #endif