Fix malformed CUDA version macro check
[alexxy/gromacs.git] / include / split.h
1 /*
2  * This file is part of the GROMACS molecular simulation package.
3  *
4  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
5  * Copyright (c) 2001-2004, The GROMACS development team,
6  * check out http://www.gromacs.org for more information.
7  * Copyright (c) 2012,2013, by the GROMACS development team, led by
8  * David van der Spoel, Berk Hess, Erik Lindahl, and including many
9  * others, as listed in the AUTHORS file in the top-level source
10  * directory and at http://www.gromacs.org.
11  *
12  * GROMACS is free software; you can redistribute it and/or
13  * modify it under the terms of the GNU Lesser General Public License
14  * as published by the Free Software Foundation; either version 2.1
15  * of the License, or (at your option) any later version.
16  *
17  * GROMACS is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
20  * Lesser General Public License for more details.
21  *
22  * You should have received a copy of the GNU Lesser General Public
23  * License along with GROMACS; if not, see
24  * http://www.gnu.org/licenses, or write to the Free Software Foundation,
25  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA.
26  *
27  * If you want to redistribute modifications to GROMACS, please
28  * consider that scientific software is very special. Version
29  * control is crucial - bugs must be traceable. We will be happy to
30  * consider code for inclusion in the official distribution, but
31  * derived work must not be called official GROMACS. Details are found
32  * in the README & COPYING files - if they are missing, get the
33  * official version at http://www.gromacs.org.
34  *
35  * To help us fund GROMACS development, we humbly ask that you cite
36  * the research papers on the package. Check out http://www.gromacs.org.
37  */
38
39 #ifndef _split_h
40 #define _split_h
41
42 /*
43  * Determine on which node a particle should reside and on which
44  * node is also should be available. The distribution algorithm
45  * should account for the actual ring architecture and how nodes
46  * are numbered. The typedef t_splitd has two separate structures that
47  * describe the distribution:
48  *
49  * The nodeinfo part describes which node containst which particles,
50  * while the nodeids part describes on which node(s) a particle can be
51  * found and what local particle number is assigned to it.
52  *
53  */
54
55 #include <stdio.h>
56 #include "typedefs.h"
57
58 #ifdef __cplusplus
59 extern "C" {
60 #endif
61
62 typedef enum {
63     SPLIT_NONE, SPLIT_SORTX, SPLIT_REDUCE, SPLIT_NR
64 } t_splitalg;
65
66 typedef struct
67 {
68     int      hid;
69     atom_id *nodeid;
70 } t_nodeids;
71
72 typedef struct
73 {
74     int  nr;    /* Length of the long list.                         */
75     int *lst;   /* The actual list.                                 */
76 } t_nlist;
77
78 typedef struct
79 {
80     t_nlist home;   /* List of home particles.                          */
81 } t_nodeinfo;
82
83 typedef struct
84 {
85     int         nnodes;   /* Number of nodes this splitinfo is for.      */
86     t_nodeinfo *nodeinfo; /* Home and available particles for each node. */
87     int         nnodeids; /* Number of particles this splitinfo is for.       */
88     t_nodeids  *nodeids;  /* List of node id's for every particle,       */
89     /* entry[nodeid] gives the local atom id (NO_ATID if*/
90     /* not available). Entry[MAXNODES] contains home    */
91     /* node's id.                                  */
92 } t_splitd;
93
94 void init_splitd(t_splitd *splitd, int nnodes, int nnodeids);
95 /*
96  * Initialises the splitd data structure for the specified number of
97  * nodes (nnodes) and number of atoms (nnodeids).
98  */
99
100 void make_splitd(t_splitalg algorithm, int nnodes, t_topology *top,
101                  rvec *x, t_splitd *splitd, char *loadfile);
102 /*
103  * Initialises the splitd data structure for the specified number of
104  * nodes (nnodes) and number of atoms (top) and fills it using
105  * the specified algorithm (algorithm):
106  *
107  *    SPLIT_NONE   : Generate partial systems by dividing it into nnodes
108  *                   consecutive, equal, parts without any intelligence.
109  *    SPLIT_SORTX  : Like SPLIT_NONE but sort the coordinates before
110  *                   dividing the system into nnodes consecutive, equal,
111  *                   parts.
112  *    SPLIT_REDUCE : Like SPLIT_NONE but minimise the bond lengths, i.e
113  *                   invoke the reduce algorithm before dividing the
114  *                   system into nnodes consecutive, equal, parts.
115  *
116  * The topology (top) and the coordinates (x) are not modified. The
117  * calculations of bonded forces are assigned to the node with
118  * the highest id that has one of the needed particles as home particle.
119  */
120
121 long wr_split(FILE *fp, t_splitd *splitd);
122 /*
123  * Writes the split descriptor (splitd) to the file specified by fp.
124  */
125
126 long rd_split(FILE *fp, t_splitd *splitd);
127 /*
128  * Reads the split descriptor (splitd) from the file specified by fp.
129  */
130
131 void rm_splitd(t_splitd *splitd);
132 /*
133  * Frees all allocated space for the splitd data structure.
134  */
135
136 void pr_splitd(FILE *fp, int indent, char *title, t_splitd *splitd);
137 /*
138  * This routine prints out a (human) readable representation of
139  * the split descriptor to the file fp. Ident specifies the
140  * number of spaces the text should be indented. Title is used
141  * to print a header text.
142  */
143
144 void split_topology(t_splitalg algorithm, int nnodes, t_topology *top,
145                     rvec x[], char *loadfile);
146 /*
147  * Distributes the non-bonded forces defined in top over nnodes nodes
148  * using the algoritm specified by algorithm. The distribution is made
149  * by creating a split descriptor and then putting a bonded force on the
150  * highest home node number of the paricles involved.
151  */
152
153 #ifdef __cplusplus
154 }
155 #endif
156
157 #endif  /* _split_h */