Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
81 lines (65 loc) · 1.81 KB

File metadata and controls

81 lines (65 loc) · 1.81 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#include "parallel_common.h"
#ifdef __MPI
#include <mpi.h>
#endif
#include <cstring>
#ifdef __MPI
void Parallel_Common::bcast_string(std::string& object) // Peize Lin fix bug 2019-03-18
{
int size = object.size();
MPI_Bcast(&size, 1, MPI_INT, 0, MPI_COMM_WORLD);
int my_rank;
MPI_Comm_rank(MPI_COMM_WORLD, &my_rank);
if (0 != my_rank)
{
object.resize(size);
}
MPI_Bcast(&object[0], size, MPI_CHAR, 0, MPI_COMM_WORLD);
return;
}
void Parallel_Common::bcast_string(std::string* object, const int n) // Peize Lin fix bug 2019-03-18
{
for (int i = 0; i < n; i++)
bcast_string(object[i]);
return;
}
void Parallel_Common::bcast_complex_double(std::complex<double>& object)
{
MPI_Bcast(&object, 1, MPI_DOUBLE_COMPLEX, 0, MPI_COMM_WORLD);
}
void Parallel_Common::bcast_complex_double(std::complex<double>* object, const int n)
{
MPI_Bcast(object, n, MPI_DOUBLE_COMPLEX, 0, MPI_COMM_WORLD);
}
void Parallel_Common::bcast_double(double& object)
{
MPI_Bcast(&object, 1, MPI_DOUBLE, 0, MPI_COMM_WORLD);
}
void Parallel_Common::bcast_double(double* object, const int n)
{
MPI_Bcast(object, n, MPI_DOUBLE, 0, MPI_COMM_WORLD);
}
void Parallel_Common::bcast_int(int& object)
{
MPI_Bcast(&object, 1, MPI_INT, 0, MPI_COMM_WORLD);
}
void Parallel_Common::bcast_int(int* object, const int n)
{
MPI_Bcast(object, n, MPI_INT, 0, MPI_COMM_WORLD);
}
void Parallel_Common::bcast_bool(bool& object)
{
int swap = object;
int my_rank;
MPI_Comm_rank(MPI_COMM_WORLD, &my_rank);
if (my_rank == 0)
swap = object;
MPI_Bcast(&swap, 1, MPI_INT, 0, MPI_COMM_WORLD);
if (my_rank != 0)
object = static_cast<bool>(swap);
}
void Parallel_Common::bcast_char(char* object, const int n)
{
MPI_Bcast(object, n, MPI_CHAR, 0, MPI_COMM_WORLD);
}
#endif
Morty Proxy This is a proxified and sanitized view of the page, visit original site.