Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Y
YAC
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
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
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
dkrz-sw
YAC
Commits
128018df
Commit
128018df
authored
1 year ago
by
Moritz Hanke
Browse files
Options
Downloads
Patches
Plain Diff
improves test coverage of component.c
parent
e72612db
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
tests/mci/test_component_config.c
+36
-20
36 additions, 20 deletions
tests/mci/test_component_config.c
with
36 additions
and
20 deletions
tests/mci/test_component_config.c
+
36
−
20
View file @
128018df
...
...
@@ -38,22 +38,23 @@ int main (void) {
// names of all components
char
const
*
all_comp_names
[]
=
{
"comp_a"
,
"comp_b"
,
"comp_c"
};
enum
{
NUM_COMPS
=
sizeof
(
all_comp_names
)
/
sizeof
(
all_comp_names
[
0
])};
// ranks for each component
int
comp_ranks
[
3
][
4
]
=
{{
0
,
1
,
2
,
4
},
{
0
,
1
,
3
,
5
},
{
0
,
2
,
3
,
6
}};
int
comp_ranks
[
NUM_COMPS
][
4
]
=
{{
0
,
1
,
2
,
4
},
{
0
,
1
,
3
,
5
},
{
0
,
2
,
3
,
6
}};
// number of ranks per component
int
num_comp_ranks
[
3
]
=
{
4
,
4
,
4
};
int
num_comp_ranks
[
NUM_COMPS
]
=
{
4
,
4
,
4
};
// get the names of all components that are to be defined on the local process
char
const
*
local_comp_names
[
3
];
char
const
*
local_comp_names
[
NUM_COMPS
];
size_t
num_local_comps
=
0
;
for
(
int
i
=
0
;
i
<
3
;
++
i
)
for
(
int
i
=
0
;
i
<
NUM_COMPS
;
++
i
)
for
(
int
j
=
0
;
j
<
num_comp_ranks
[
i
];
++
j
)
if
(
rank
==
comp_ranks
[
i
][
j
])
local_comp_names
[
num_local_comps
++
]
=
all_comp_names
[
i
];
// generate dummy couple_config
struct
yac_couple_config
*
couple_config
=
generate_couple_config
((
char
**
)
all_comp_names
,
3
);
generate_couple_config
((
char
**
)
all_comp_names
,
NUM_COMPS
);
// generate component configuration
struct
yac_component_config
*
comp_config
=
...
...
@@ -70,17 +71,17 @@ int main (void) {
// generate reference communicators for each component and for each
// component pair
MPI_Comm
ref_comp_comm
[
3
],
ref_comp_pair_comm
[
3
],
ref_all_comps_comm
;
MPI_Comm
ref_comp_comm
[
NUM_COMPS
],
ref_comp_pair_comm
[
NUM_COMPS
],
ref_all_comps_comm
;
{
MPI_Group
world_group
,
comp_group
[
3
];
MPI_Group
world_group
,
comp_group
[
NUM_COMPS
];
MPI_Comm_group
(
MPI_COMM_WORLD
,
&
world_group
);
for
(
int
i
=
0
;
i
<
3
;
++
i
)
{
for
(
int
i
=
0
;
i
<
NUM_COMPS
;
++
i
)
{
MPI_Group_incl
(
world_group
,
num_comp_ranks
[
i
],
comp_ranks
[
i
],
&
comp_group
[
i
]);
MPI_Comm_create
(
MPI_COMM_WORLD
,
comp_group
[
i
],
&
ref_comp_comm
[
i
]);
}
for
(
int
i
=
0
,
k
=
0
;
i
<
3
;
++
i
)
{
for
(
int
j
=
i
+
1
;
j
<
3
;
++
j
,
++
k
)
{
for
(
int
i
=
0
,
k
=
0
;
i
<
NUM_COMPS
;
++
i
)
{
for
(
int
j
=
i
+
1
;
j
<
NUM_COMPS
;
++
j
,
++
k
)
{
MPI_Group
comp_pair_group
;
MPI_Group_union
(
comp_group
[
i
],
comp_group
[
j
],
&
comp_pair_group
);
MPI_Comm_create
(
...
...
@@ -90,7 +91,7 @@ int main (void) {
}
{
MPI_Group
all_comps_group
=
MPI_GROUP_EMPTY
;
for
(
int
i
=
0
;
i
<
3
;
++
i
)
{
for
(
int
i
=
0
;
i
<
NUM_COMPS
;
++
i
)
{
MPI_Group
merge_group
;
MPI_Group_union
(
all_comps_group
,
comp_group
[
i
],
&
merge_group
);
if
(
all_comps_group
!=
MPI_GROUP_EMPTY
)
...
...
@@ -101,7 +102,7 @@ int main (void) {
MPI_COMM_WORLD
,
all_comps_group
,
&
ref_all_comps_comm
);
MPI_Group_free
(
&
all_comps_group
);
}
for
(
int
i
=
0
;
i
<
3
;
++
i
)
for
(
int
i
=
0
;
i
<
NUM_COMPS
;
++
i
)
MPI_Group_free
(
&
comp_group
[
i
]);
MPI_Group_free
(
&
world_group
);
}
...
...
@@ -110,15 +111,25 @@ int main (void) {
// testing
//----------------------------------------------------------------------------
for
(
int
i
=
0
;
i
<
3
;
++
i
)
{
for
(
int
i
=
0
;
i
<
NUM_COMPS
;
++
i
)
{
int
is_local
=
0
;
for
(
int
j
=
0
;
j
<
num_comp_ranks
[
i
];
++
j
)
if
(
comp_ranks
[
i
][
j
]
==
rank
)
is_local
=
1
;
int
rank_idx
;
for
(
rank_idx
=
0
;
(
rank_idx
<
num_comp_ranks
[
i
])
&&
!
is_local
;
++
rank_idx
)
if
(
comp_ranks
[
i
][
rank_idx
]
==
rank
)
is_local
=
1
;
if
(
yac_component_config_contains_component
(
comp_config
,
all_comp_names
[
i
])
!=
is_local
)
PUT_ERR
(
"error in yac_component_config_contains_component"
);
if
(
is_local
)
{
if
(
yac_component_config_comp_size
(
comp_config
,
all_comp_names
[
i
])
!=
num_comp_ranks
[
i
])
PUT_ERR
(
"error in yac_component_config_comp_size"
);
if
(
yac_component_config_comp_rank
(
comp_config
,
all_comp_names
[
i
])
!=
rank_idx
-
1
)
PUT_ERR
(
"error in yac_component_config_comp_rank"
);
}
}
if
(
yac_component_config_contains_component
(
comp_config
,
"dummy"
))
PUT_ERR
(
"error in yac_component_config_contains_component"
);
// encode into a single int which components are defined locally
int
comp_flags
=
0
;
...
...
@@ -126,8 +137,8 @@ int main (void) {
comp_flags
|=
(
1
<<
(
local_comp_names
[
i
][
5
]
-
'a'
));
// check component pair communicators
for
(
int
i
=
0
,
k
=
0
;
i
<
3
;
++
i
)
{
// for all component
for
(
int
j
=
i
+
1
;
j
<
3
;
++
j
,
++
k
)
{
// for all remaining components
for
(
int
i
=
0
,
k
=
0
;
i
<
NUM_COMPS
;
++
i
)
{
// for all component
for
(
int
j
=
i
+
1
;
j
<
NUM_COMPS
;
++
j
,
++
k
)
{
// for all remaining components
if
((
comp_flags
&
(
1
<<
i
))
||
(
comp_flags
&
(
1
<<
j
)))
{
MPI_Comm
comp_pair_comm
=
yac_component_config_get_comps_comm
(
...
...
@@ -146,7 +157,7 @@ int main (void) {
// check communicators containing all processes
if
(
ref_all_comps_comm
!=
MPI_COMM_NULL
)
{
MPI_Comm
all_comps_comm
=
yac_component_config_get_comps_comm
(
comp_config
,
all_comp_names
,
3
);
yac_component_config_get_comps_comm
(
comp_config
,
all_comp_names
,
NUM_COMPS
);
int
compare_result
;
MPI_Comm_compare
(
ref_all_comps_comm
,
all_comps_comm
,
&
compare_result
);
if
(
compare_result
!=
MPI_CONGRUENT
)
...
...
@@ -154,6 +165,11 @@ int main (void) {
MPI_Comm_free
(
&
all_comps_comm
);
}
// check communicator for empty component list
if
(
yac_component_config_get_comps_comm
(
comp_config
,
NULL
,
0
)
!=
MPI_COMM_NULL
)
PUT_ERR
(
"error in yac_component_config_get_comps_comm"
);
//----------------------------------------------------------------------------
// clean-up
//----------------------------------------------------------------------------
...
...
@@ -162,7 +178,7 @@ int main (void) {
if
(
ref_all_comps_comm
!=
MPI_COMM_NULL
)
MPI_Comm_free
(
&
ref_all_comps_comm
);
for
(
int
i
=
0
;
i
<
3
;
++
i
)
{
for
(
int
i
=
0
;
i
<
NUM_COMPS
;
++
i
)
{
if
(
ref_comp_comm
[
i
]
!=
MPI_COMM_NULL
)
MPI_Comm_free
(
&
ref_comp_comm
[
i
]);
if
(
ref_comp_pair_comm
[
i
]
!=
MPI_COMM_NULL
)
...
...
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