1 /* Support for MPI parallelization.
2  */
3 #ifndef eslMPI_INCLUDED
4 #define eslMPI_INCLUDED
5 #include "esl_config.h"
6 #if defined(HAVE_MPI)
7 #include <mpi.h>
8 
9 #include "esl_alphabet.h"
10 #include "esl_msa.h"
11 #include "esl_sq.h"
12 #include "esl_stopwatch.h"
13 
14 /* Many MPI implementations are not MPI2.2 compliant, and do not
15  * support new MPI2.2 datatypes; work around that absence. [J10/152]
16  * This configuration is better here than esl_config.h.in, because
17  * we need to #include <mpi.h> first to see if the system MPI does
18  * the right thing, and esl_config.h.in is intended to be included
19  * BEFORE any system includes.
20  */
21 #if MPI_VERSION < 2 || MPI_SUBVERSION < 2
22 #ifndef MPI_INT64_T
23 #define MPI_INT64_T  MPI_LONG_LONG_INT
24 #endif
25 #ifndef MPI_UINT64_T
26 #define MPI_UINT64_T MPI_UNSIGNED_LONG_LONG
27 #endif
28 #ifndef MPI_UINT32_T
29 #define MPI_UINT32_T MPI_UNSIGNED
30 #endif
31 #ifndef MPI_INT16_T
32 #define MPI_INT16_T  MPI_SHORT
33 #endif
34 #ifndef MPI_UINT8_T
35 #define MPI_UINT8_T  MPI_UNSIGNED_CHAR
36 #endif
37 #endif /*MPI_VERSION,MPI_SUBVERSION*/
38 
39 /* 1. Communicating optional arrays */
40 extern int esl_mpi_PackOpt(void *inbuf, int incount, MPI_Datatype type, void *pack_buf,
41 			   int pack_buf_size, int *position, MPI_Comm comm);
42 extern int esl_mpi_PackOptSize(void *inbuf, int incount, MPI_Datatype type, MPI_Comm comm, int *ret_n);
43 extern int esl_mpi_UnpackOpt(void *pack_buf, int pack_buf_size, int *pos, void **outbuf,
44 			     int *opt_n, MPI_Datatype type, MPI_Comm comm);
45 
46 /* 2. Communicating ESL_SQ (single sequences) */
47 extern int esl_sq_MPISend(ESL_SQ *sq, int dest, int tag, MPI_Comm comm, char **buf, int *nalloc);
48 extern int esl_sq_MPIPackSize(ESL_SQ *sq, MPI_Comm comm, int *ret_n);
49 extern int esl_sq_MPIPack(ESL_SQ *sq, char *buf, int n, int *pos, MPI_Comm comm);
50 extern int esl_sq_MPIUnpack(const ESL_ALPHABET *abc, char *buf, int n, int *pos, MPI_Comm comm, ESL_SQ **ret_sq);
51 extern int esl_sq_MPIRecv(int source, int tag, MPI_Comm comm, const ESL_ALPHABET *abc,
52 			  char **buf, int *nalloc, ESL_SQ **ret_sq);
53 
54 /* 3. Communicating ESL_MSA (multiple sequence alignments) */
55 extern int esl_msa_MPISend(const ESL_MSA *msa, int dest, int tag, MPI_Comm comm, char **buf, int *nalloc);
56 extern int esl_msa_MPIPackSize(const ESL_MSA *msa, MPI_Comm comm, int *ret_n);
57 extern int esl_msa_MPIPack(const ESL_MSA *msa, char *buf, int n, int *position, MPI_Comm comm);
58 extern int esl_msa_MPIUnpack(const ESL_ALPHABET *abc, char *buf, int n, int *pos, MPI_Comm comm, ESL_MSA **ret_msa);
59 extern int esl_msa_MPIRecv(int source, int tag, MPI_Comm comm, const ESL_ALPHABET *abc, char **buf, int *nalloc, ESL_MSA **ret_msa);
60 
61 /* 4. Communicating ESL_STOPWATCH (process timing) */
62 extern int esl_stopwatch_MPIReduce(ESL_STOPWATCH *w, int root, MPI_Comm comm);
63 
64 
65 #endif /*HAVE_MPI*/
66 #endif /*eslMPI_INCLUDED*/
67