-
Notifications
You must be signed in to change notification settings - Fork 3
/
com.h
128 lines (104 loc) · 4.63 KB
/
com.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
/*
* com.h
* Copyright (C) 2009, Tomasz Koziara (t.koziara AT gmail.com)
* ---------------------------------------------------------------
* parallel communication
*/
/* This file is part of Solfec.
* Solfec is free software: you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation, either version 3 of the License, or (at your
* option) any later version.
*
* Solfec is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with Solfec. If not, see <http://www.gnu.org/licenses/>. */
#include <stdint.h>
#include <mpi.h>
#ifndef __com__
#define __com__
typedef struct comdata COMDATA; /* ints and doubles */
typedef struct comobj COMOBJ; /* objects */
typedef void (*OBJ_Pack) (void *obj, int *dsize, double **d, int *doubles, int *isize, int **i, int *ints); /* pack an object */
typedef void* (*OBJ_Unpack) (void *data, int *dpos, double *d, int doubles, int *ipos, int *i, int ints); /* unpack an object */
struct comdata
{
int rank, /* send or receive rank */
ints, /* integers count */
doubles; /* doubles count */
int *i; /* integers */
double *d; /* doubles */
};
struct comobj
{
int rank; /* send or receive rank */
void *o; /* object */
};
/* communicate integers and doubles using point to point communication */
uint64_t COM (MPI_Comm comm, int tag,
COMDATA *send, int nsend,
COMDATA **recv, int *nrecv); /* recv is contiguous => free (*recv) releases all memory */
/* communicate integers and doubles using all to all communication */
uint64_t COMALL (MPI_Comm comm,
COMDATA *send, int nsend,
COMDATA **recv, int *nrecv); /* recv is contiguous => free (*recv) releases all memory */
/* alternative approach to communicating integers and doubles using all to all communication;
more appropriate for sending large data volumes */
uint64_t COMALL2 (MPI_Comm comm,
COMDATA *send, int nsend,
COMDATA **recv, int *nrecv); /* recv is contiguous => free (*recv) releases all memory */
/* communicate one set of integers and doubles to all other processors */
uint64_t COMONEALL (MPI_Comm comm, COMDATA send,
COMDATA **recv, int *nrecv); /* recv is contiguous => free (*recv) releases all memory */
/* communicate objects using point to point communication */
uint64_t COMOBJS (MPI_Comm comm, int tag,
OBJ_Pack pack,
void *data,
OBJ_Unpack unpack,
COMOBJ *send, int nsend,
COMOBJ **recv, int *nrecv); /* recv is contiguous => free (*recv) releases all memory */
/* communicate objects using all to all communication */
uint64_t COMOBJSALL (MPI_Comm comm,
OBJ_Pack pack,
void *data,
OBJ_Unpack unpack,
COMOBJ *send, int nsend,
COMOBJ **recv, int *nrecv); /* recv is contiguous => free (*recv) releases all memory */
/* communicate an object to all other processors */
uint64_t COMOBJALL (MPI_Comm comm,
OBJ_Pack pack,
void *data,
OBJ_Unpack unpack,
void *object,
COMOBJ **recv, int *nrecv); /* recv is contiguous => free (*recv) releases all memory */
/* create a repetitive point to point communication pattern;
* ranks and sizes must not change during the communication;
* pointers to send and receive buffers data must not change */
void* COM_Pattern (MPI_Comm comm, int tag,
COMDATA *send, int nsend,
COMDATA **recv, int *nrecv); /* recv is contiguous => free (*recv) releases all memory */
/* communicate integers and doubles accodring
* to the pattern computed by COM_Pattern */
uint64_t COM_Repeat (void *pattern);
/* non-blocking send */
uint64_t COM_Send (void *pattern);
/* blocking receive */
void COM_Recv (void *pattern);
/* free point to point communication pattern */
void COM_Free (void *pattern);
/* create a repetitive all to all communication pattern;
* ranks and sizes must not change during the communication;
* pointers to send and receive buffers data must not change */
void* COMALL_Pattern (MPI_Comm comm,
COMDATA *send, int nsend,
COMDATA **recv, int *nrecv); /* recv is contiguous => free (*recv) releases all memory */
/* communicate integers and doubles accodring
* to the pattern computed by COMALL_Pattern */
uint64_t COMALL_Repeat (void *pattern);
/* free all to all communication pattern */
void COMALL_Free (void *pattern);
#endif