-
Notifications
You must be signed in to change notification settings - Fork 1
/
halo.h
141 lines (116 loc) · 5.29 KB
/
halo.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
/* $Id$
*
* This file is part of the ESPResSo distribution (http://www.espresso.mpg.de).
* It is therefore subject to the ESPResSo license agreement which you accepted upon receiving the distribution
* and by which you are legally bound while utilizing this file in any form or way.
* There is NO WARRANTY, not even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* You should have received a copy of that license along with this program;
* if not, refer to http://www.espresso.mpg.de/license.html where its current version can be found, or
* write to Max-Planck-Institute for Polymer Research, Theory Group, PO Box 3148, 55021 Mainz, Germany.
* Copyright (c) 2002-2009; all rights reserved unless otherwise stated.
*/
/** \file halo.h
*
* Halo scheme for parallelization of lattice algorithms.
* Header file for \ref halo.c.
*
*/
#ifndef HALO_H
#define HALO_H
#include <mpi.h>
#include "utils.h"
#include "lattice.h"
#ifdef LATTICE
/** \name Types of halo communications
* <br>
* <ul>
* <li>HALO_LOCL local exchange of halo regions on the same processor</li>
* <li>HALO_SENDRECV halo exchange between different processors</li>
* </ul>
*/
/*@{*/
#define HALO_LOCL 0 /**< Tag for local exchange of halo regions on the same processor */
#define HALO_SENDRECV 1 /**< Tag for halo exchange between different processors */
#define HALO_SEND 2 /**< Tag for halo send only */
#define HALO_RECV 3 /**< Tag for halo receive only */
#define HALO_OPEN 4 /**< Tag for halo open boundary */
/*@}*/
/** \name Tags for halo communications
* <br>
* <ul>
* <li>REQ_HALO_SPREAD exchange of all halo regions</li>
* <li>REQ_HALO_CHECK additional check for consistency of halo regions</li>
* </ul>
*/
/*@{*/
#define REQ_HALO_SPREAD 501 /**< Tag for halo update */
#define REQ_HALO_CHECK 599 /**< Tag for consistency check of halo regions */
/*@}*/
/** This struct describes the layout of the lattice data. The description
* is similar to MPI datatypes but a bit more compact. See \ref
* halo_create_fieldtype, \ref halo_create_field_vector and \ref
* halo_dtcopy to understand how it works. */
typedef struct _Fieldtype {
int count; /**< number of subtypes in fieldtype */
int *disps; /**< displacements of the subtypes */
int *lengths; /**< lengths of the subtypes */
int extent; /**< extent of the complete fieldtype including gaps */
int vblocks; /**< number of blocks in field vectors */
int vstride; /**< size of strides in field vectors */
int vskip; /**< displacement between strides in field vectors */
} *Fieldtype;
/** Structure describing a Halo region */
typedef struct {
int type; /**< type of halo communication */
int source_node; /**< index of processor which sends halo data */
int dest_node; /**< index of processor receiving halo data */
void *send_buffer; /**< pointer to data being sent */
void *recv_buffer; /**< pointer to data being received */
Fieldtype fieldtype; /**< type layout of the data beeing exchanged */
MPI_Datatype datatype; /**< MPI datatype of data beeing communicated */
} HaloInfo ;
/** Structure holding a set of \ref HaloInfo which comprise a certain
* parallelization scheme */
typedef struct {
int num; /**< number of halo communications in the scheme */
HaloInfo *halo_info; /**< set of halo communications */
} HaloCommunicator;
/** Creates a fieldtype describing the data layout
* @param count number of subtypes (Input)
* @param lens array of lenghts of the subtytpes (Input)
* @param disps array of displacements the subtypes (Input)
* @param extent extent of the whole new fieldtype (Input)
* @param newtype newly created fieldtype (Input/Output)
*/
void halo_create_fieldtype(int count, int *lens, int *disps, int extent, Fieldtype *newtype);
/** Creates a field vector layout
* @param vblocks number of vector blocks(Input)
* @param vstride size of strides in field vector (Input)
* @param vskip displacements of strides in field vector (Input)
* @param oldtype fieldtype the vector is composed of (Input)
* @param newtype newly created fieldtype (Input/Output)
*/
void halo_create_field_vector(int vblocks, int vstride, int vskip, Fieldtype oldtype, Fieldtype *newtype);
/** Frees a fieldtype
* @param ftype pointer to the type to be freed (Input)
*/
void halo_free_fieldtype(Fieldtype *ftype);
/** Preparation of a certain halo parallelizations scheme. Sets up the
* necessary datastructures for \ref halo_communication
* @param hc halo communicator beeing created (Input/Output)
* @param lattice lattice the communcation is created for (Input)
* @param fieldtype field layout of the lattice data (Input)
* @param datatype MPI datatype for the lattice data (Input)
*/
void prepare_halo_communication(HaloCommunicator *hc, Lattice *lattice, Fieldtype fieldtype, MPI_Datatype datatype);
/** Frees datastrutures associated with a halo communicator
* @param hc halo communicator to be released
*/
void release_halo_communication(HaloCommunicator *hc);
/** Perform communication according to the parallelization scheme
* described by the halo communicator
* @param hc halo communicator describing the parallelization scheme
*/
void halo_communication(HaloCommunicator *hc);
#endif /* LATTICE */
#endif /* HALO_H */