GCC Code Coverage Report
Directory: . Exec Total Coverage
File: frame/base/hmlp_mpi.cpp Lines: 10 74 13.5 %
Date: 2019-01-14 Branches: 0 2 0.0 %

Line Exec Source
1
#include <hmlp_mpi.hpp>
2
3
namespace hmlp
4
{
5
namespace mpi
6
{
7
8
/**
9
 *  MPI 1.0 functionality
10
 */
11
12
13
int Init( int *argc, char ***argv )
14
{
15
#ifdef HMLP_USE_MPI
16
  return MPI_Init( argc, argv );
17
#else
18
  return 0;
19
#endif
20
};
21
22
1
int Initialized( int *flag )
23
{
24
#ifdef HMLP_USE_MPI
25
  return MPI_Initialized( flag );
26
#else
27
1
  return 0;
28
#endif
29
};
30
31
int Finalize( void )
32
{
33
#ifdef HMLP_USE_MPI
34
  return MPI_Finalize();
35
#else
36
  return 0;
37
#endif
38
};
39
40
int Finalized( int* flag )
41
{
42
#ifdef HMLP_USE_MPI
43
  return MPI_Finalized( flag );
44
#else
45
  return 0;
46
#endif
47
};
48
49
int Send( const void *buf, int count, Datatype datatype, int dest, int tag, Comm comm )
50
{
51
#ifdef HMLP_USE_MPI
52
  return MPI_Send( buf, count, datatype, dest, tag, comm );
53
#else
54
  return 0;
55
#endif
56
};
57
58
int Isend( const void *buf, int count, Datatype datatype, int dest, int tag, Comm comm, Request *request )
59
{
60
#ifdef HMLP_USE_MPI
61
  return MPI_Isend( buf, count, datatype, dest, tag, comm, request );
62
#else
63
	return 0;
64
#endif
65
};
66
67
68
int Recv( void *buf, int count, Datatype datatype,
69
    int source, int tag, Comm comm, Status *status )
70
{
71
#ifdef HMLP_USE_MPI
72
  return MPI_Recv( buf, count, datatype, source, tag, comm, status );
73
#else
74
  return 0;
75
#endif
76
};
77
78
79
int Irecv( void *buf, int count, Datatype datatype,
80
		int source, int tag, Comm comm, Request *request )
81
{
82
#ifdef HMLP_USE_MPI
83
  return Irecv( buf, count, datatype, source, tag, comm, request );
84
#else
85
	return 0;
86
#endif
87
};
88
89
90
int Sendrecv(
91
    void *sendbuf, int sendcount, Datatype sendtype, int   dest, int sendtag,
92
    void *recvbuf, int recvcount, Datatype recvtype, int source, int recvtag,
93
    Comm comm, Status *status )
94
{
95
#ifdef HMLP_USE_MPI
96
  return MPI_Sendrecv(
97
      sendbuf, sendcount, sendtype,   dest, sendtag,
98
      recvbuf, recvcount, recvtype, source, recvtag,
99
      comm, status );
100
#else
101
  return 0;
102
#endif
103
};
104
105
106
int Get_count( Status *status, Datatype datatype, int *count )
107
{
108
#ifdef HMLP_USE_MPI
109
  return MPI_Get_count( status, datatype, count );
110
#else
111
  return 0;
112
#endif
113
};
114
115
116
117
1
int Comm_size( Comm comm, int *size )
118
{
119
#ifdef HMLP_USE_MPI
120
  return MPI_Comm_size( comm, size );
121
#else
122
  /** only one process with rank 0 */
123
1
  *size = 1;
124
1
  return 0;
125
#endif
126
};
127
128
1
int Comm_rank( Comm comm, int *rank )
129
{
130
#ifdef HMLP_USE_MPI
131
  return MPI_Comm_rank( comm, rank );
132
#else
133
  /** only one process with rank 0 */
134
1
  *rank = 0;
135
1
  return 0;
136
#endif
137
};
138
139
1
int Comm_dup( Comm comm, Comm *newcomm )
140
{
141
#ifdef HMLP_USE_MPI
142
  return MPI_Comm_dup( comm, newcomm );
143
#else
144
1
  return 0;
145
#endif
146
};
147
148
int Comm_split( Comm comm, int color, int key, Comm *newcomm )
149
{
150
#ifdef HMLP_USE_MPI
151
  return MPI_Comm_split( comm, color, key, newcomm );
152
#else
153
  return 0;
154
#endif
155
};
156
157
158
159
int Type_contiguous( int count, Datatype oldtype, Datatype *newtype )
160
{
161
#ifdef HMLP_USE_MPI
162
  return MPI_Type_contiguous( count, oldtype, newtype );
163
#else
164
  return 0;
165
#endif
166
};
167
168
int Type_commit( Datatype *datatype )
169
{
170
#ifdef HMLP_USE_MPI
171
  return MPI_Type_commit( datatype );
172
#else
173
  return 0;
174
#endif
175
};
176
177
178
179
180
int Test( Request *request, int *flag, Status *status )
181
{
182
#ifdef HMLP_USE_MPI
183
	return MPI_Test( request, flag, status );
184
#else
185
  /** Set *flag = 1 to prevent blocking. */
186
  *flag = 1;
187
	return 0;
188
#endif
189
};
190
191
192
193
int Bcast( void *buffer, int count, Datatype datatype,
194
    int root, Comm comm )
195
{
196
#ifdef HMLP_USE_MPI
197
  return MPI_Bcast( buffer, count, datatype, root, comm );
198
#else
199
  return 0;
200
#endif
201
};
202
203
int Barrier( Comm comm )
204
{
205
#ifdef HMLP_USE_MPI
206
  return MPI_Barrier( comm );
207
#else
208
  return 0;
209
#endif
210
};
211
212
213
int Ibarrier( Comm comm, Request *request )
214
{
215
#ifdef HMLP_USE_MPI
216
	return MPI_Ibarrier( comm, request );
217
#else
218
	return 0;
219
#endif
220
};
221
222
223
224
225
int Reduce( void *sendbuf, void *recvbuf, int count,
226
    Datatype datatype, Op op, int root, Comm comm )
227
{
228
#ifdef HMLP_USE_MPI
229
  return MPI_Reduce( sendbuf, recvbuf, count,
230
      datatype, op, root, comm );
231
#else
232
  return 0;
233
#endif
234
};
235
236
237
238
int Gather( const void *sendbuf, int sendcount, Datatype sendtype,
239
    void *recvbuf, int recvcount, Datatype recvtype,
240
    int root, Comm comm )
241
{
242
#ifdef HMLP_USE_MPI
243
  return MPI_Gather( sendbuf, sendcount, sendtype,
244
      recvbuf, recvcount, recvtype, root, comm );
245
#else
246
  return 0;
247
#endif
248
};
249
250
251
252
int Gatherv( void *sendbuf, int sendcount, Datatype sendtype,
253
             void *recvbuf, const int *recvcounts, const int *displs,
254
             Datatype recvtype, int root, Comm comm )
255
{
256
#ifdef HMLP_USE_MPI
257
  return MPI_Gatherv( sendbuf, sendcount, sendtype,
258
      recvbuf, recvcounts, displs, recvtype, root, comm );
259
#else
260
  return 0;
261
#endif
262
};
263
264
265
266
267
268
269
int Scan( void *sendbuf, void *recvbuf, int count,
270
    Datatype datatype, Op op, Comm comm )
271
{
272
#ifdef HMLP_USE_MPI
273
  return MPI_Scan( sendbuf, recvbuf, count,
274
      datatype, op, comm );
275
#else
276
  return 0;
277
#endif
278
};
279
280
281
int Allreduce( void *sendbuf, void *recvbuf, int count,
282
    Datatype datatype, Op op, Comm comm )
283
{
284
#ifdef HMLP_USE_MPI
285
  return MPI_Allreduce( sendbuf, recvbuf, count,
286
      datatype, op, comm );
287
#else
288
  return 0;
289
#endif
290
};
291
292
293
int Allgather(
294
    void *sendbuf, int sendcount, Datatype sendtype,
295
    void *recvbuf, int recvcount, Datatype recvtype, Comm comm )
296
{
297
#ifdef HMLP_USE_MPI
298
  return MPI_Allgather(
299
      sendbuf, sendcount, sendtype,
300
      recvbuf, recvcount, recvtype, comm );
301
#else
302
  return 0;
303
#endif
304
};
305
306
int Allgatherv(
307
    void *sendbuf, int sendcount, Datatype sendtype,
308
    void *recvbuf, int *recvcounts, int *displs, Datatype recvtype, Comm comm )
309
{
310
#ifdef HMLP_USE_MPI
311
  return MPI_Allgatherv(
312
      sendbuf, sendcount, sendtype,
313
      recvbuf, recvcounts, displs, recvtype, comm );
314
#else
315
  return 0;
316
#endif
317
};
318
319
320
321
322
323
324
325
int Alltoall( void *sendbuf, int sendcount, Datatype sendtype,
326
    void *recvbuf, int recvcount, Datatype recvtype, Comm comm )
327
{
328
#ifdef HMLP_USE_MPI
329
  return MPI_Alltoall( sendbuf, sendcount, sendtype,
330
      recvbuf, recvcount, recvtype, comm );
331
#else
332
  return 0;
333
#endif
334
};
335
336
337
int Alltoallv( void *sendbuf, int *sendcounts, int *sdispls, Datatype sendtype,
338
    void *recvbuf, int *recvcounts, int *rdispls, Datatype recvtype, Comm comm )
339
{
340
#ifdef HMLP_USE_MPI
341
  return MPI_Alltoallv( sendbuf, sendcounts, sdispls, sendtype,
342
      recvbuf, recvcounts, rdispls, recvtype, comm );
343
#else
344
  return 0;
345
#endif
346
};
347
348
349
/** MPI 2.0 and 3.0 functionality. */
350
351
int Init_thread( int *argc, char ***argv, int required, int *provided )
352
{
353
#ifdef HMLP_USE_MPI
354
	return MPI_Init_thread( argc, argv, required, provided );
355
#else
356
  /** Set *provided to required. */
357
  *provided = required;
358
  /** Return without any error. */
359
	return 0;
360
#endif
361
};
362
363
364
int Probe( int source, int tag, Comm comm, Status *status )
365
{
366
#ifdef HMLP_USE_MPI
367
  return MPI_Probe( source, tag, comm, status );
368
#else
369
  return 0;
370
#endif
371
}; /** end Probe() */
372
373
int Iprobe( int source, int tag, Comm comm, int *flag, Status *status )
374
{
375
#ifdef HMLP_USE_MPI
376
  return MPI_Iprobe( source, tag, comm, flag, status );
377
#else
378
  return 0;
379
#endif
380
}; /** end Iprobe() */
381
382
383
/** HMLP MPI extension */
384
void PrintProgress( const char *s, mpi::Comm comm )
385
{
386
  int rank; mpi::Comm_rank( comm, &rank );
387
  if ( !rank )
388
  {
389
    printf( "%s\n", s ); fflush( stdout );
390
  }
391
  mpi::Barrier( comm );
392
};
393
394
395
396
397
}; /** end namespace mpi */
398
}; /** end namespace hmlp */
399
400