Skip to content
Snippets Groups Projects
Commit 36c3f153 authored by Thomas Jahns's avatar Thomas Jahns :cartwheel:
Browse files

Split utility functions into partial interfaces.

parent c4e057b6
No related branches found
No related tags found
No related merge requests found
......@@ -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]) };
shift_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);
src_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_index_list[] = {5,67,4,5,13,9,2,1,0,96,13,12,1,3};
enum { num_src_indices = sizeof(src_index_list) / sizeof(src_index_list[0]) };
shift_idx(src_index_list, num_src_indices, 100);
Xt_int src_indices[] = {5,67,4,5,13,9,2,1,0,96,13,12,1,3};
enum { num_src_indices = sizeof(src_indices) / sizeof(src_indices[0]) };
shift_idx(src_indices, num_src_indices, 100);
// destination index list
Xt_int dst_index_list[] = {5,4,3,96,1,5,4,5,4,3,13,2,1};
enum { num_dst_indices = sizeof(dst_index_list) / sizeof(dst_index_list[0]) };
shift_idx(dst_index_list, num_dst_indices, 100);
Xt_int dst_indices[] = {5,4,3,96,1,5,4,5,4,3,13,2,1};
enum { num_dst_indices = sizeof(dst_indices) / sizeof(dst_indices[0]) };
shift_idx(dst_indices, num_dst_indices, 100);
test_self_xmap_construct(src_index_list, num_src_indices,
dst_index_list, num_dst_indices,
new_xmap, comm);
test_self_xmap_construct_idxvec(src_indices, num_src_indices,
dst_indices, num_dst_indices,
new_xmap, comm);
}
/*
......
......@@ -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);
......
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment