forked from rikigigi/analisi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mp.h
55 lines (40 loc) · 1.04 KB
/
mp.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
/**
*
* (c) Riccardo Bertossa, 2019
*
* Use at your own risk.
*
* If you modified the code, I could be happy if you contribute on github!
*
**/
#ifndef MPI_H
#define MPI_H
#include "config.h"
#ifdef USE_MPI
#include <string>
#include <mpi.h>
template <class T,class TFLOAT> class OperazioniSuLista;
class Mp
{
public:
static Mp & mpi(int *argc=0, char ***argv=0);
int me();
int size();
bool ionode();
std::string outname(std::string s);
template <class T,class T2> void send_to_root(OperazioniSuLista<T,T2> * l) {
MPI_Send( l->accesso_lista(),l->lunghezza(),MPI_DOUBLE,0,0,MPI_COMM_WORLD);
}
template <class T,class T2> void recv_root(OperazioniSuLista<T,T2> * l,int source){
MPI_Recv(l->accesso_lista(),l->lunghezza(),MPI_DOUBLE,source,0,MPI_COMM_WORLD,MPI_STATUS_IGNORE);
}
~Mp();
private:
Mp(Mp const &) = delete;
void operator=(Mp const&) = delete;
Mp(int *argc, char ***argv);
static bool initialized;
int world_rank,world_size;
};
#endif
#endif // MPI_H