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
4a6c87a1
Commit
4a6c87a1
authored
2 years ago
by
Christian Engwer
Browse files
Options
Downloads
Patches
Plain Diff
[test] more flexible mpipack test
parent
d59ffd8e
No related branches found
No related tags found
1 merge request
!1146
Fix async communication of MPIPack
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
dune/common/parallel/test/mpipacktest.cc
+31
-15
31 additions, 15 deletions
dune/common/parallel/test/mpipacktest.cc
with
31 additions
and
15 deletions
dune/common/parallel/test/mpipacktest.cc
+
31
−
15
View file @
4a6c87a1
...
...
@@ -7,36 +7,52 @@
#include
"config.h"
#endif
constexpr
int
TAG
=
42
;
#include
<iostream>
#include
<dune/common/parallel/mpihelper.hh>
#include
<dune/common/parallel/mpipack.hh>
#include
<dune/common/test/testsuite.hh>
constexpr
int
TAG
=
42
;
int
main
(
int
argc
,
char
**
argv
){
Dune
::
MPIHelper
&
helper
=
Dune
::
MPIHelper
::
instance
(
argc
,
argv
);
Dune
::
TestSuite
suite
;
suite
.
require
(
helper
.
size
()
==
2
)
<<
"This test must be executed on two processes"
;
auto
comm
=
helper
.
getCommunication
();
Dune
::
MPIPack
pack
(
comm
);
template
<
typename
Comm
>
auto
testSync
(
Comm
comm
)
{
Dune
::
TestSuite
suite
(
"testSync"
);
int
rank
=
comm
.
rank
();
// we receive from left and right
int
src
=
(
rank
-
1
+
comm
.
size
())
%
comm
.
size
();
int
dest
=
(
rank
+
1
)
%
comm
.
size
();
if
(
helper
.
rank
()
==
0
){
pack
<<
3
<<
helper
.
rank
();
// send
{
Dune
::
MPIPack
pack
(
comm
);
pack
<<
3
<<
comm
.
rank
();
pack
<<
std
::
vector
<
int
>
{
4711
,
42
};
comm
.
send
(
pack
,
1
,
TAG
);
comm
.
send
(
pack
,
dest
,
TAG
);
}
if
(
helper
.
rank
()
==
1
){
Dune
::
MPIPack
pack
=
comm
.
rrecv
(
Dune
::
MPIPack
(
comm
),
0
,
TAG
);
// recv
{
Dune
::
MPIPack
pack
=
comm
.
rrecv
(
Dune
::
MPIPack
(
comm
),
src
,
TAG
);
int
drei
;
pack
>>
drei
;
int
rank_
0
;
pack
>>
rank_
0
;
int
rank_
src
;
pack
>>
rank_
src
;
std
::
vector
<
int
>
vec
;
pack
>>
vec
;
suite
.
check
(
drei
==
3
)
<<
"received wrong value"
;
suite
.
check
(
rank_
0
==
0
)
<<
"received wrong value"
;
suite
.
check
(
rank_
src
==
src
)
<<
"received wrong value"
;
suite
.
check
(
vec
.
size
()
==
2
)
<<
"vector has wrong size!"
;
suite
.
check
(
vec
[
0
]
==
4711
&&
vec
[
1
]
==
42
)
<<
"vector contains wrong values!"
;
}
return
suite
;
}
int
main
(
int
argc
,
char
**
argv
){
Dune
::
MPIHelper
&
helper
=
Dune
::
MPIHelper
::
instance
(
argc
,
argv
);
Dune
::
TestSuite
suite
;
auto
comm
=
helper
.
getCommunication
();
suite
.
subTest
(
testSync
(
comm
));
return
0
;
return
suite
.
exit
()
;
}
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