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
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
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
Core Modules
dune-common
Commits
3f3e2103
Commit
3f3e2103
authored
12 years ago
by
Martin Nolte
Browse files
Options
Downloads
Patches
Plain Diff
implement scan and partualSum (MPI_SCAN)
[[Imported from SVN: r6929]]
parent
94589f68
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
dune/common/parallel/collectivecommunication.hh
+36
-5
36 additions, 5 deletions
dune/common/parallel/collectivecommunication.hh
dune/common/parallel/mpicollectivecommunication.hh
+17
-0
17 additions, 0 deletions
dune/common/parallel/mpicollectivecommunication.hh
with
53 additions
and
5 deletions
dune/common/parallel/collectivecommunication.hh
+
36
−
5
View file @
3f3e2103
...
...
@@ -252,20 +252,51 @@ namespace Dune
* in every process.
*
* The template parameter BinaryFunction is the type of
* the binary function to use for the computation
* the binary function to use for the computation
.
*
* @param in The array to compute on.
* @param out The array to store the results in.
* @param len The number of components in the array
*/
template
<
typename
BinaryFunction
,
typename
Type
>
void
allreduce
(
Type
*
in
,
Type
*
out
,
int
len
)
const
int
allreduce
(
Type
*
in
,
Type
*
out
,
int
len
)
const
{
std
::
copy
(
in
,
in
+
len
,
out
);
return
;
return
0
;
}
/** \brief perform a partial reduction of processes 0, ..., rank
*
* The template parameter BinaryFunction gives the type of the reduction.
*
* Note: scan and allreduce are very similar. The only difference is that
* scan only returns the reduction of the arguments over processes
* 0, ..., rank instead of over all processes.
*
* \param[in] in array of input arguments
* \param[out] out array to store the output in
* \param[in] len number of elements in each array
*/
template
<
class
BinaryFunction
,
class
T
>
int
scan
(
T
*
in
,
T
*
out
,
int
len
)
const
{
std
::
copy
(
in
,
in
+
len
,
out
);
return
0
;
}
/** \brief compute the sum of the argument over processes 0, ..., rank
*
* Note: This function assumes that type T has an operator+
*
* \param[in] in argument for this process
*/
template
<
class
T
>
T
partialSum
(
T
&
in
)
const
{
return
in
;
}
};
}
#endif
}
// namespace Dune
#endif // #ifndef DUNE_COLLECTIVECOMMUNICATION_HH
This diff is collapsed.
Click to expand it.
dune/common/parallel/mpicollectivecommunication.hh
+
17
−
0
View file @
3f3e2103
...
...
@@ -295,6 +295,23 @@ namespace Dune
(
Generic_MPI_Op
<
Type
,
BinaryFunction
>::
get
()),
communicator
);
}
/** \copydoc CollectiveCommunication::scan(T *in,T *out,int len) const */
template
<
class
BinaryFunction
,
class
T
>
int
scan
(
T
*
in
,
T
*
out
,
int
len
)
const
{
return
MPI_Scan
(
in
,
out
,
len
,
MPITraits
<
T
>::
getType
(),
(
Generic_MPI_Op
<
T
,
BinaryFunction
>::
get
()),
communicator
);
}
/** \copydoc CollectiveCommunication::partialSum(T &in) const */
template
<
class
T
>
T
partialSum
(
T
&
in
)
const
{
T
out
;
scan
<
std
::
plus
<
T
>
>
(
&
in
,
&
out
,
1
);
return
out
;
}
private
:
MPI_Comm
communicator
;
int
me
;
...
...
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