Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Y
yaxt
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
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
yaxt
Commits
36c3f153
Commit
36c3f153
authored
3 years ago
by
Thomas Jahns
Browse files
Options
Downloads
Patches
Plain Diff
Split utility functions into partial interfaces.
parent
c4e057b6
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
tests/test_xmap_common.c
+44
-23
44 additions, 23 deletions
tests/test_xmap_common.c
tests/test_xmap_common.h
+20
-2
20 additions, 2 deletions
tests/test_xmap_common.h
tests/test_xmap_common_f.f90
+51
-7
51 additions, 7 deletions
tests/test_xmap_common_f.f90
with
115 additions
and
32 deletions
tests/test_xmap_common.c
+
44
−
23
View file @
36c3f153
...
...
@@ -111,13 +111,34 @@ assert_xmap_is_to_self(Xt_xmap xmap)
void
test_self_xmap_construct
(
const
Xt_int
*
src_index_list
,
int
num_src_indices
,
const
Xt_int
*
dst_index_list
,
int
num_dst_indices
,
xmap_constructor
new_xmap
,
MPI_Comm
comm
)
test_self_xmap_construct_idxvec
(
const
Xt_int
*
src_index_list
,
int
num_src_indices
,
const
Xt_int
*
dst_index_list
,
int
num_dst_indices
,
xmap_constructor
new_xmap
,
MPI_Comm
comm
)
{
Xt_idxlist
src_idxlist
=
xt_idxvec_new
(
src_index_list
,
num_src_indices
),
dst_idxlist
=
xt_idxvec_new
(
dst_index_list
,
num_dst_indices
);
test_self_xmap_construct
(
src_idxlist
,
dst_idxlist
,
new_xmap
,
comm
);
}
void
test_self_xmap_construct_idxstripes
(
const
struct
Xt_stripe
*
src_indices
,
int
num_src_stripes
,
const
struct
Xt_stripe
*
dst_indices
,
int
num_dst_stripes
,
xmap_constructor
new_xmap
,
MPI_Comm
comm
)
{
Xt_idxlist
src_idxlist
=
xt_idxvec_new
(
src_index_list
,
num_src_indices
);
Xt_idxlist
dst_idxlist
=
xt_idxvec_new
(
dst_index_list
,
num_dst_indices
);
Xt_idxlist
src_idxlist
=
xt_idxstripes_new
(
src_indices
,
num_src_stripes
),
dst_idxlist
=
xt_idxstripes_new
(
dst_indices
,
num_dst_stripes
);
test_self_xmap_construct
(
src_idxlist
,
dst_idxlist
,
new_xmap
,
comm
);
}
void
test_self_xmap_construct
(
Xt_idxlist
src_idxlist
,
Xt_idxlist
dst_idxlist
,
xmap_constructor
new_xmap
,
MPI_Comm
comm
)
{
// test of exchange map
Xt_xmap
xmap
=
new_xmap
(
src_idxlist
,
dst_idxlist
,
comm
);
xt_idxlist_delete
(
src_idxlist
);
...
...
@@ -139,37 +160,37 @@ static inline void shift_idx(Xt_int idx[], int num, int offset) {
static
void
test_xmap1
(
xmap_constructor
new_xmap
,
MPI_Comm
comm
)
{
struct
Xt_stripe
src_stripe
,
dst_stripe
;
// source index list
Xt_int
src_index_list
[]
=
{
1
,
2
,
3
,
4
,
5
,
6
,
7
}
;
enum
{
num_src_indices
=
sizeof
(
src_index_list
)
/
sizeof
(
src_index_list
[
0
])
}
;
s
hift_idx
(
src_index_list
,
num_src_indices
,
7
)
;
src_stripe
.
nstrides
=
7
;
src_stripe
.
start
=
(
Xt_int
)(
1
+
(
Xt_int
)
my_rank
*
src_stripe
.
nstrides
)
;
s
rc_stripe
.
stride
=
1
;
// destination index list
Xt_int
dst_index_list
[]
=
{
7
,
6
,
5
,
4
,
3
,
2
,
1
}
;
enum
{
num_dst_indices
=
sizeof
(
dst_index_list
)
/
sizeof
(
dst_index_list
[
0
])
}
;
shift_idx
(
dst_index_list
,
num_dst_indices
,
7
)
;
dst_stripe
.
nstrides
=
src_stripe
.
nstrides
;
dst_stripe
.
start
=
(
Xt_int
)(
src_stripe
.
start
+
src_stripe
.
nstrides
-
1
)
;
dst_stripe
.
stride
=
-
1
;
test_self_xmap_construct
(
src_index_list
,
num_src_indices
,
dst_index_list
,
num_dst_indices
,
new_xmap
,
comm
);
test_self_xmap_construct_idxstripes
(
&
src_stripe
,
1
,
&
dst_stripe
,
1
,
new_xmap
,
comm
);
}
static
void
test_xmap2
(
xmap_constructor
new_xmap
,
MPI_Comm
comm
)
{
// source index list
Xt_int
src_ind
ex_list
[]
=
{
5
,
67
,
4
,
5
,
13
,
9
,
2
,
1
,
0
,
96
,
13
,
12
,
1
,
3
};
enum
{
num_src_indices
=
sizeof
(
src_ind
ex_list
)
/
sizeof
(
src_ind
ex_list
[
0
])
};
shift_idx
(
src_ind
ex_list
,
num_src_indices
,
100
);
Xt_int
src_ind
ices
[]
=
{
5
,
67
,
4
,
5
,
13
,
9
,
2
,
1
,
0
,
96
,
13
,
12
,
1
,
3
};
enum
{
num_src_indices
=
sizeof
(
src_ind
ices
)
/
sizeof
(
src_ind
ices
[
0
])
};
shift_idx
(
src_ind
ices
,
num_src_indices
,
100
);
// destination index list
Xt_int
dst_ind
ex_list
[]
=
{
5
,
4
,
3
,
96
,
1
,
5
,
4
,
5
,
4
,
3
,
13
,
2
,
1
};
enum
{
num_dst_indices
=
sizeof
(
dst_ind
ex_list
)
/
sizeof
(
dst_ind
ex_list
[
0
])
};
shift_idx
(
dst_ind
ex_list
,
num_dst_indices
,
100
);
Xt_int
dst_ind
ices
[]
=
{
5
,
4
,
3
,
96
,
1
,
5
,
4
,
5
,
4
,
3
,
13
,
2
,
1
};
enum
{
num_dst_indices
=
sizeof
(
dst_ind
ices
)
/
sizeof
(
dst_ind
ices
[
0
])
};
shift_idx
(
dst_ind
ices
,
num_dst_indices
,
100
);
test_self_xmap_construct
(
src_ind
ex_list
,
num_src_indices
,
dst_index_list
,
num_dst_indices
,
new_xmap
,
comm
);
test_self_xmap_construct
_idxvec
(
src_ind
ices
,
num_src_indices
,
dst_indices
,
num_dst_indices
,
new_xmap
,
comm
);
}
/*
...
...
This diff is collapsed.
Click to expand it.
tests/test_xmap_common.h
+
20
−
2
View file @
36c3f153
...
...
@@ -59,12 +59,30 @@ typedef Xt_xmap (*xmap_constructor)(Xt_idxlist src_idxlist,
Xt_idxlist
dst_idxlist
,
MPI_Comm
comm
);
enum
test_idxlist_size
{
SMALL
,
BIG
,
};
int
xt_xmap_self_test_main
(
xmap_constructor
xmap_constructor
);
/* note: calls xt_idxlist_delete for src_idxlist and dst_idxlist */
void
test_self_xmap_construct
(
const
Xt_int
*
src_index_list
,
int
num_src_indices
,
const
Xt_int
*
dst_index_list
,
int
num_dst_indices
,
test_self_xmap_construct
(
Xt_idxlist
src_idxlist
,
Xt_idxlist
dst_idxlist
,
xmap_constructor
new_xmap
,
MPI_Comm
comm
);
void
test_self_xmap_construct_idxvec
(
const
Xt_int
*
src_index_list
,
int
num_src_indices
,
const
Xt_int
*
dst_index_list
,
int
num_dst_indices
,
xmap_constructor
new_xmap
,
MPI_Comm
comm
);
void
test_self_xmap_construct_idxstripes
(
const
struct
Xt_stripe
*
src_index_list
,
int
num_src_stripes
,
const
struct
Xt_stripe
*
dst_index_list
,
int
num_dst_stripes
,
xmap_constructor
new_xmap
,
MPI_Comm
comm
);
int
xt_xmap_parallel_test_main
(
xmap_constructor
xmap_constructor
);
...
...
This diff is collapsed.
Click to expand it.
tests/test_xmap_common_f.f90
+
51
−
7
View file @
36c3f153
...
...
@@ -47,11 +47,13 @@
!
#include "fc_feature_defs.inc"
MODULE
test_xmap_common
USE
iso_c_binding
,
ONLY
:
c_int
USE
mpi
USE
ftest_common
,
ONLY
:
init_mpi
,
finish_mpi
,
test_abort
USE
test_idxlist_utils
,
ONLY
:
test_err_count
USE
yaxt
,
ONLY
:
xt_initialize
,
xt_finalize
,
xt_int_kind
,
&
xt_idxlist
,
xt_idxlist_delete
,
xt_idxvec_new
,
&
xt_stripe
,
xt_idxlist
,
xt_idxlist_delete
,
xt_idxvec_new
,
&
xt_idxstripes_new
,
xi
=>
xt_int_kind
,
&
xt_xmap
,
xt_xmap_copy
,
xt_xmap_delete
,
&
xt_xmap_get_num_destinations
,
xt_xmap_get_num_sources
,
&
xt_xmap_get_destination_ranks
,
xt_xmap_get_source_ranks
,
&
...
...
@@ -59,8 +61,12 @@ MODULE test_xmap_common
IMPLICIT
NONE
PRIVATE
INTEGER
::
my_rank
INTEGER
,
PARAMETER
::
xi
=
xt_int_kind
PUBLIC
::
xmap_self_test_main
,
test_self_xmap_construct
INTERFACE
test_self_xmap_construct
MODULE
PROCEDURE
test_self_xmap_construct_idxlist
MODULE
PROCEDURE
test_self_xmap_construct_indices
MODULE
PROCEDURE
test_self_xmap_construct_stripes
END
INTERFACE
test_self_xmap_construct
CHARACTER
(
len
=*
),
PARAMETER
::
filename
=
'test_xmap_common_f.f90'
CONTAINS
SUBROUTINE
xmap_self_test_main
(
xmap_new
)
...
...
@@ -133,9 +139,49 @@ CONTAINS
END
SUBROUTINE
assert_xmap_is_to_self
SUBROUTINE
test_self_xmap_construct
(
src_index_list
,
dst_index_list
,
xmap_new
,
comm
)
INTEGER
(
xt_int_kind
),
INTENT
(
in
)
::
src_index_list
(:),
dst_index_list
(:)
SUBROUTINE
test_self_xmap_construct_stripes
(
src_stripes
,
dst_stripes
,
&
xmap_new
,
comm
)
TYPE
(
xt_stripe
),
INTENT
(
in
)
::
src_stripes
(:),
dst_stripes
(:)
INTERFACE
FUNCTION
xmap_new
(
src_idxlist
,
dst_idxlist
,
comm
)
RESULT
(
res
)
IMPORT
::
xt_idxlist
,
xt_xmap
IMPLICIT
NONE
TYPE
(
xt_idxlist
),
INTENT
(
in
)
::
src_idxlist
TYPE
(
xt_idxlist
),
INTENT
(
in
)
::
dst_idxlist
INTEGER
,
INTENT
(
in
)
::
comm
TYPE
(
xt_xmap
)
::
res
END
FUNCTION
xmap_new
END
INTERFACE
INTEGER
,
INTENT
(
in
)
::
comm
TYPE
(
xt_idxlist
)
::
src_idxlist
,
dst_idxlist
src_idxlist
=
xt_idxstripes_new
(
src_stripes
)
dst_idxlist
=
xt_idxstripes_new
(
dst_stripes
)
CALL
test_self_xmap_construct
(
src_idxlist
,
dst_idxlist
,
xmap_new
,
comm
)
END
SUBROUTINE
test_self_xmap_construct_stripes
SUBROUTINE
test_self_xmap_construct_indices
(
src_indices
,
dst_indices
,
&
xmap_new
,
comm
)
INTEGER
(
xi
),
INTENT
(
in
)
::
src_indices
(:),
dst_indices
(:)
INTERFACE
FUNCTION
xmap_new
(
src_idxlist
,
dst_idxlist
,
comm
)
RESULT
(
res
)
IMPORT
::
xt_idxlist
,
xt_xmap
IMPLICIT
NONE
TYPE
(
xt_idxlist
),
INTENT
(
in
)
::
src_idxlist
TYPE
(
xt_idxlist
),
INTENT
(
in
)
::
dst_idxlist
INTEGER
,
INTENT
(
in
)
::
comm
TYPE
(
xt_xmap
)
::
res
END
FUNCTION
xmap_new
END
INTERFACE
INTEGER
,
INTENT
(
in
)
::
comm
TYPE
(
xt_idxlist
)
::
src_idxlist
,
dst_idxlist
src_idxlist
=
xt_idxvec_new
(
src_indices
)
dst_idxlist
=
xt_idxvec_new
(
dst_indices
)
CALL
test_self_xmap_construct
(
src_idxlist
,
dst_idxlist
,
xmap_new
,
comm
)
END
SUBROUTINE
test_self_xmap_construct_indices
SUBROUTINE
test_self_xmap_construct_idxlist
(
src_idxlist
,
dst_idxlist
,
&
xmap_new
,
comm
)
TYPE
(
xt_idxlist
),
INTENT
(
inout
)
::
src_idxlist
,
dst_idxlist
INTERFACE
FUNCTION
xmap_new
(
src_idxlist
,
dst_idxlist
,
comm
)
RESULT
(
res
)
IMPORT
::
xt_idxlist
,
xt_xmap
...
...
@@ -149,8 +195,6 @@ CONTAINS
INTEGER
,
INTENT
(
in
)
::
comm
TYPE
(
xt_xmap
)
::
xmap
,
xmap_copy
src_idxlist
=
xt_idxvec_new
(
src_index_list
)
dst_idxlist
=
xt_idxvec_new
(
dst_index_list
)
xmap
=
xmap_new
(
src_idxlist
,
dst_idxlist
,
comm
)
CALL
xt_idxlist_delete
(
src_idxlist
)
...
...
@@ -162,7 +206,7 @@ CONTAINS
CALL
xt_xmap_delete
(
xmap
)
CALL
xt_xmap_delete
(
xmap_copy
)
END
SUBROUTINE
test_self_xmap_construct
END
SUBROUTINE
test_self_xmap_construct
_idxlist
SUBROUTINE
test_xmap1
(
xmap_new
,
comm
)
INTERFACE
...
...
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