Fix malformed CUDA version macro check
[alexxy/gromacs.git] / include / network.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 _network_h
40 #define _network_h
41
42
43 /*
44  * This module defines the interface of the actual communication routines.
45  */
46
47 #include <stdio.h>
48 #include "visibility.h"
49 #include "types/simple.h"
50 #include "types/commrec.h"
51 #include "typedefs.h"
52 #include "main.h"
53 #include "gmx_fatal.h"
54
55 #ifdef __cplusplus
56 extern "C" {
57 #endif
58
59 int gmx_setup(int *argc, char **argv, int *nnodes);
60 /* Initializes the parallel communication, return the ID of the node */
61
62 int gmx_node_num(void);
63 /* return the number of nodes in the ring */
64
65 int gmx_node_rank(void);
66 /* return the rank of the node */
67
68 GMX_LIBGMX_EXPORT
69 int gmx_physicalnode_id_hash(void);
70 /* Return a non-negative hash that is, hopefully, unique for each physical node.
71  * This hash is useful for determining hardware locality.
72  */
73
74 GMX_LIBGMX_EXPORT
75 int gmx_hostname_num(void);
76 /* Ostensibly, returns a integer characteristic of and unique to each
77    physical node in the MPI system. If the first part of the MPI
78    hostname (up to the first dot) ends with a number, returns this
79    number. If the first part of the MPI hostname does not ends in a
80    number (0-9 characters), returns 0.
81  */
82
83 GMX_LIBGMX_EXPORT
84 void gmx_setup_nodecomm(FILE *fplog, t_commrec *cr);
85 /* Sets up fast global communication for clusters with multi-core nodes */
86
87 GMX_LIBGMX_EXPORT
88 void gmx_init_intranode_counters(t_commrec *cr);
89 /* Initializes intra-physical-node MPI process/thread counts and ID. */
90
91 gmx_bool gmx_mpi_initialized(void);
92 /* return TRUE when MPI_Init has been called.
93  * return FALSE when MPI_Init has not been called OR
94  * when GROMACS was compiled without MPI support.
95  */
96
97 GMX_LIBGMX_EXPORT
98 void gmx_barrier(const t_commrec *cr);
99 /* Wait till all processes in cr->mpi_comm_mygroup have reached the barrier */
100
101 GMX_LIBGMX_EXPORT
102 void gmx_bcast(int nbytes, void *b, const t_commrec *cr);
103 /* Broadcast nbytes bytes from the master to cr->mpi_comm_mygroup */
104
105 GMX_LIBGMX_EXPORT
106 void gmx_bcast_sim(int nbytes, void *b, const t_commrec *cr);
107 /* Broadcast nbytes bytes from the sim master to cr->mpi_comm_mysim */
108
109 GMX_LIBGMX_EXPORT
110 void gmx_sumi(int nr, int r[], const t_commrec *cr);
111 /* Calculate the global sum of an array of ints */
112
113 void gmx_sumli(int nr, gmx_large_int_t r[], const t_commrec *cr);
114 /* Calculate the global sum of an array of large ints */
115
116 GMX_LIBGMX_EXPORT
117 void gmx_sumf(int nr, float r[], const t_commrec *cr);
118 /* Calculate the global sum of an array of floats */
119
120 GMX_LIBGMX_EXPORT
121 void gmx_sumd(int nr, double r[], const t_commrec *cr);
122 /* Calculate the global sum of an array of doubles */
123
124 void gmx_sumf_comm(int nr, float r[], MPI_Comm mpi_comm);
125 /* Calculate the global sum of an array of floats */
126
127 void gmx_sumd_comm(int nr, double r[], MPI_Comm mpi_comm);
128 /* Calculate the global sum of an array of doubles */
129
130 GMX_LIBGMX_EXPORT
131 void gmx_sumi_sim(int nr, int r[], const gmx_multisim_t *ms);
132 /* Calculate the sum over the simulations of an array of ints */
133
134 GMX_LIBGMX_EXPORT
135 void gmx_sumli_sim(int nr, gmx_large_int_t r[], const gmx_multisim_t *ms);
136 /* Calculate the sum over the simulations of an array of large ints */
137
138 GMX_LIBGMX_EXPORT
139 void gmx_sumf_sim(int nr, float r[], const gmx_multisim_t *ms);
140 /* Calculate the sum over the simulations of an array of floats */
141
142 GMX_LIBGMX_EXPORT
143 void gmx_sumd_sim(int nr, double r[], const gmx_multisim_t *ms);
144 /* Calculate the sum over the simulations of an array of doubles */
145
146 void gmx_abort(int nodeid, int nnodes, int errorno);
147 /* Abort the parallel run */
148
149 GMX_LIBGMX_EXPORT
150 void gmx_finalize_par(void);
151 /* Finish the parallel run in an ordered manner */
152
153 #ifdef GMX_DOUBLE
154 #define gmx_sum_comm  gmx_sumd_comm
155 #define gmx_sum       gmx_sumd
156 #define gmx_sum_sim   gmx_sumd_sim
157 #else
158 #define gmx_sum_comm  gmx_sumf_comm
159 #define gmx_sum       gmx_sumf
160 #define gmx_sum_sim   gmx_sumf_sim
161 #endif
162
163 #ifdef DEBUG_GMX
164 #define debug_gmx() do { FILE *fp = debug ? debug : stderr; \
165                          if (bDebugMode()) { fprintf(fp, "NODEID=%d, %s  %d\n", gmx_mpi_initialized() ? gmx_node_rank() : -1, __FILE__, __LINE__); } fflush(fp); } while (0)
166 #else
167 #define debug_gmx()
168 #endif
169
170 #ifdef __cplusplus
171 }
172 #endif
173
174
175 #endif  /* _network_h */