FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
abacus-develop/source/source_base/parallel_common.cpp at develop · AroundPeking/abacus-develop · GitHub
AroundPeking
/
abacus-develop
Public
forked from
deepmodeling/abacus-develop
Notifications
You must be signed in to change notification settings
Fork
2
Star
2
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
abacus-develop
/
source
/
source_base
/
parallel_common.cpp
Copy path
More file actions
More file actions
Latest commit
History
History
History
81 lines (65 loc) · 1.81 KB
Breadcrumbs
abacus-develop
/
source
/
source_base
/
parallel_common.cpp
Copy path
File metadata and controls
81 lines (65 loc) · 1.81 KB
Raw
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
Back
|
FazBrowse Home
|
New Git URL