CoMD
A Mini-app for Co-Design of Classical Molecular Dynamics.
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
parallel.h
Go to the documentation of this file.
1 /// \file
2 /// Wrappers for MPI functions.
3 
4 #ifndef _PARALLEL_H_
5 #define _PARALLEL_H_
6 
7 #include "mytype.h"
8 
9 /// Structure for use with MPI_MINLOC and MPI_MAXLOC operations.
10 typedef struct RankReduceDataSt
11 {
12  double val;
13  int rank;
15 
16 /// Return total number of processors.
17 int getNRanks(void);
18 
19 /// Return local rank.
20 int getMyRank(void);
21 
22 /// Return non-zero if printing occurs from this rank.
23 int printRank(void);
24 
25 /// Print a timestamp and message when all tasks arrive.
26 void timestampBarrier(const char* msg);
27 
28 /// Wrapper for MPI_Init.
29 void initParallel(int *argc, char ***argv);
30 
31 /// Wrapper for MPI_Finalize.
32 void destroyParallel(void);
33 
34 /// Wrapper for MPI_Barrier(MPI_COMM_WORLD).
35 void barrierParallel(void);
36 
37 /// Wrapper for MPI_Sendrecv.
38 int sendReceiveParallel(void* sendBuf, int sendLen, int dest,
39  void* recvBuf, int recvLen, int source);
40 
41 /// Wrapper for MPI_Allreduce integer sum.
42 void addIntParallel(int* sendBuf, int* recvBuf, int count);
43 
44 /// Wrapper for MPI_Allreduce real sum.
45 void addRealParallel(real_t* sendBuf, real_t* recvBuf, int count);
46 
47 /// Wrapper for MPI_Allreduce double sum.
48 void addDoubleParallel(double* sendBuf, double* recvBuf, int count);
49 
50 /// Wrapper for MPI_Allreduce integer max.
51 void maxIntParallel(int* sendBuf, int* recvBuf, int count);
52 
53 /// Wrapper for MPI_Allreduce double min with rank.
54 void minRankDoubleParallel(RankReduceData* sendBuf, RankReduceData* recvBuf, int count);
55 
56 /// Wrapper for MPI_Allreduce double max with rank.
57 void maxRankDoubleParallel(RankReduceData* sendBuf, RankReduceData* recvBuf, int count);
58 
59 /// Wrapper for MPI_Bcast
60 void bcastParallel(void* buf, int len, int root);
61 
62 /// Return non-zero if code was built with MPI active.
63 int builtWithMpi(void);
64 
65 #endif
66