utils_parall.h 4.09 KB
Newer Older
Camille Coti's avatar
Camille Coti committed
1
2
3
4
5
6
7
8
9
10
11
12
#ifndef _UTILS_PARALL_H_
#define _UTILS_PARALL_H_

#include <ginac/ginac.h>
namespace gi = GiNaC;

/*******************************************************************************
 *                              Datatypes                                      *
 *******************************************************************************/

class parameters_t{
public:
13
14
    unsigned int a4, a2, a1;
    parameters_t( unsigned int, unsigned int, unsigned int );
Camille Coti's avatar
Camille Coti committed
15
16
17
    parameters_t( void ){};
};

18
19
20
21
22
23
24
class parameters_s_t{
public:
    unsigned int a4;
    parameters_s_t( unsigned int );
    parameters_s_t( void ){};
};

25
class parameters_2_1_t{
Camille Coti's avatar
Camille Coti committed
26
public:
27
28
29
    unsigned int a4, a2;
    parameters_2_1_t( unsigned int, unsigned int );
    parameters_2_1_t( void ){};
Camille Coti's avatar
Camille Coti committed
30
31
32
    void setA4( unsigned int _a4 ) { this->a4 = _a4; }
    void setA2( unsigned int _a2 ) { this->a2 = _a2; }
    void setParams( unsigned int _a4, unsigned int _a2 ) { this->a4 = _a4; this->a2 = _a2; } ;
Camille Coti's avatar
Camille Coti committed
33
};
Camille Coti's avatar
Camille Coti committed
34

35
36
class parameters_2_2_t{
public:
Camille Coti's avatar
Camille Coti committed
37
38
    unsigned int a4, a2, a6, a1;
    parameters_2_2_t( unsigned int, unsigned int, unsigned int, unsigned int );
39
40
41
    parameters_2_2_t( void ){};
};

Camille Coti's avatar
Camille Coti committed
42
43
44
45
46
47
48
49
50

/*******************************************************************************
 *                             Prototypes                                      *
 *******************************************************************************/

std::string linearize_expression( gi::ex );
gi::ex de_linearize_expression( std::string, gi::lst );

void send_work( std::vector<parameters_t>& input, int peer, MPI_Comm comm = MPI_COMM_WORLD );
51
void send_work( std::vector<parameters_2_2_t>& input, int peer, MPI_Comm comm = MPI_COMM_WORLD );
Camille Coti's avatar
Camille Coti committed
52
void send_work( std::vector<parameters_2_1_t>& input, int peer, MPI_Comm comm = MPI_COMM_WORLD );
53
void send_work( std::vector<parameters_s_t>& input, int peer, MPI_Comm comm = MPI_COMM_WORLD );
Camille Coti's avatar
Camille Coti committed
54
55

void send_expressions_to_add( std::vector<std::string>&, int );
Camille Coti's avatar
Camille Coti committed
56
57
void send_expressions_to_add( std::vector<std::string>&, int, parameters_2_1_t );
void send_expressions_to_add( std::vector<std::string>&, int, parameters_s_t );
Camille Coti's avatar
Camille Coti committed
58
void send_add_or_end_addslave(  std::vector<std::string>&, int, int* );
59
void send_add_or_end_addslave(  std::vector<std::string>&, int, int*, parameters_s_t );
Camille Coti's avatar
Camille Coti committed
60
void send_add_or_end_addslave(  std::vector<std::string>&, int, int*, parameters_2_1_t );
Camille Coti's avatar
Camille Coti committed
61
void send_work_addslave(  std::vector<parameters_t>&, std::vector<std::string>&, int ) ;
62
void send_work_addslave(  std::vector<parameters_s_t>&, std::vector<std::string>&, int ) ;
Camille Coti's avatar
Camille Coti committed
63
void send_work_addslave(  std::vector<parameters_2_1_t>&, std::vector<std::string>&, int );
Camille Coti's avatar
Camille Coti committed
64
65
void send_result( gi::ex T, MPI_Comm comm = MPI_COMM_WORLD );
void send_end( int peer, MPI_Comm comm = MPI_COMM_WORLD );
Camille Coti's avatar
Camille Coti committed
66
void send_end( int peer, parameters_2_1_t p, MPI_Comm comm = MPI_COMM_WORLD );
Camille Coti's avatar
Camille Coti committed
67
void send_end( int peer, parameters_2_2_t p, MPI_Comm comm = MPI_COMM_WORLD );
68
void send_end( int peer, parameters_s_t p, MPI_Comm comm = MPI_COMM_WORLD );
Camille Coti's avatar
Camille Coti committed
69
void send_end_batch( int peer, MPI_Comm comm = MPI_COMM_WORLD );
Camille Coti's avatar
Camille Coti committed
70
void send_end_batch( int peer, parameters_2_1_t p, MPI_Comm comm = MPI_COMM_WORLD );
Camille Coti's avatar
Camille Coti committed
71

72
73
74
75
void create_parameters_datatype( void );
void create_parameters_datatype_s( void );
void create_parameters_datatype_2_1( void );
void create_parameters_datatype_2_2( void );
Camille Coti's avatar
Camille Coti committed
76
void free_parameters_dt( void );
77
78
void free_parameters_2_1_dt( void );
void free_parameters_2_2_dt( void );
79
void free_parameters_s_dt( void );
Camille Coti's avatar
Camille Coti committed
80
81
82

gi::ex add_expressions( std::vector<std::string>, gi::lst );

Camille Coti's avatar
Camille Coti committed
83
84
void create_communicators_hierarch( MPI_Comm&, MPI_Comm& );

Camille Coti's avatar
Camille Coti committed
85
86
87
88
89
/*******************************************************************************
 *                            Global variables                                 *
 *******************************************************************************/

extern MPI_Datatype DT_PARAMETERS;
90
91
extern MPI_Datatype DT_PARAMETERS_2_1;
extern MPI_Datatype DT_PARAMETERS_2_2;
92
extern MPI_Datatype DT_PARAMETERS_S;
Camille Coti's avatar
Camille Coti committed
93

Camille Coti's avatar
Camille Coti committed
94
95
extern unsigned int nbforemen;     /* Number of foremen to use with the hierarchical M/W */
extern unsigned int maxresult;     /* Maximum results in the result queue, addslave version */
Camille Coti's avatar
Camille Coti committed
96
97

#endif // _UTILS_PARALL_H_