Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dune-common
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Timo Koch
dune-common
Commits
dfdda976
Commit
dfdda976
authored
19 years ago
by
Peter Bastian
Browse files
Options
Downloads
Patches
Plain Diff
added barrier, broadcast and gather to collective communication class
[[Imported from SVN: r3655]]
parent
648cfd5d
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
common/collectivecommunication.hh
+50
-12
50 additions, 12 deletions
common/collectivecommunication.hh
with
50 additions
and
12 deletions
common/collectivecommunication.hh
+
50
−
12
View file @
dfdda976
...
...
@@ -22,8 +22,7 @@ namespace Dune
class
CollectiveCommunication
{
public:
CollectiveCommunication
(
const
C
&
c
)
:
communicator
(
c
)
CollectiveCommunication
()
{}
int
rank
()
...
...
@@ -84,8 +83,24 @@ namespace Dune
return
0
;
}
private
:
C
communicator
;
int
barrier
()
const
{
return
0
;
}
template
<
typename
T
>
int
broadcast
(
T
*
inout
,
int
len
,
int
root
)
const
{
return
0
;
}
template
<
typename
T
>
int
gather
(
T
*
in
,
T
*
out
,
int
len
,
int
root
)
const
// note out must have same size as in
{
for
(
int
i
=
0
;
i
<
len
;
i
++
)
out
[
i
]
=
in
[
i
];
return
0
;
}
};
...
...
@@ -528,19 +543,18 @@ namespace Dune
public:
CollectiveCommunication
(
const
MPI_Comm
&
c
)
:
communicator
(
c
)
{}
int
rank
()
{
int
me
;
MPI_Comm_rank
(
communicator
,
&
me
);
MPI_Comm_size
(
communicator
,
&
procs
);
}
int
rank
()
const
{
return
me
;
}
int
size
()
int
size
()
const
{
int
procs
;
MPI_Comm_size
(
communicator
,
&
procs
);
return
procs
;
}
...
...
@@ -612,13 +626,37 @@ namespace Dune
GenericMax_MPI_Op
<
T
>::
get
(),
communicator
);
}
operator
MPI_Comm
()
int
barrier
()
const
{
return
MPI_Barrier
(
communicator
);
}
//! send array from process with rank root to all others
template
<
typename
T
>
int
broadcast
(
T
*
inout
,
int
len
,
int
root
)
const
{
return
MPI_Bcast
(
inout
,
len
,
Generic_MPI_Datatype
<
T
>::
get
(),
root
,
communicator
);
}
//! receive array of values from each processor in root
template
<
typename
T
>
int
gather
(
T
*
in
,
T
*
out
,
int
len
,
int
root
)
const
// note out must have space for P*len elements
{
return
MPI_Gather
(
in
,
len
,
Generic_MPI_Datatype
<
T
>::
get
(),
out
,
len
,
Generic_MPI_Datatype
<
T
>::
get
(),
root
,
communicator
);
}
operator
MPI_Comm
()
const
{
return
communicator
;
}
private
:
MPI_Comm
communicator
;
int
me
;
int
procs
;
};
#endif
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment