#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <assert.h>
#include <limits.h>
#include <stdlib.h>
#include <mpi.h>
#include <yaxt.h>
#define VERBOSE
#include "tests.h"
#include "ctest_common.h"
#include "test_idxlist_utils.h"
int main(int argc, char **argv) {
{
enum {
num_indices = 7,
num_ref_stripes = 2,
num_lists = 2,
};
static const Xt_int index_list[num_lists][num_indices]
= {{1,2,3,4,5,6,7},{7,6,5,4,3,2,1}};
for (size_t i = 0; i < num_lists; ++i)
for (size_t i = 0; i < num_lists; ++i)
check_idxlist(collectionlist, index_list[0], (int)(num_lists*num_indices));
static const struct Xt_stripe ref_stripes[num_ref_stripes]
= {{.
start = 1, .stride = 1, .nstrides = 7},
{.start = 7, .stride = -1, .nstrides = 7}};
= idxlist_pack_unpack_copy(collectionlist);
check_idxlist_copy(collectionlist, collectionlist_copy,
2 * (size_t)num_indices, index_list[0],
(size_t)num_ref_stripes, ref_stripes);
}
{
enum {
num_lists = 2,
num_indices = 7,
num_ref_stripes = 2,
};
static const Xt_int index_list[num_lists][num_indices]
= {{1,2,3,4,5,6,7},{7,6,5,4,3,2,1}};
for (size_t i = 0; i < num_lists; ++i)
for (size_t i = 0; i < num_lists; ++i)
check_idxlist(collectionlist, &index_list[0][0], 2 * num_indices);
check_idxlist(collectionlist_copy, &(index_list[0][0]),
2 * num_indices);
int num_stripes;
= {{.
start = 1, .stride = 1, .nstrides = 7},
{.start = 7, .stride = -1, .nstrides = 7}};
check_stripes(stripes, num_stripes, ref_stripes, num_ref_stripes);
free(stripes);
}
{
enum {
num_indices = 7,
num_vecs = 3
};
static const Xt_int index_list[num_vecs][num_indices]
= {{1,2,3,4,5,6,7},{7,6,5,4,3,2,1},{2,6,1,4,7,3,0}},
sorted_index_list[num_vecs * num_indices]
= {0,1,1,1,2,2,2,3,3,3,4,4,4,5,5,6,6,6,7,7,7};
for (size_t i = 0; i < num_vecs; ++i)
for (size_t i = 0; i < num_vecs; ++i)
check_idxlist(collectionlist, &(index_list[0][0]), (int)(3*num_indices));
check_idxlist(intersection, sorted_index_list, (int)(num_vecs*num_indices));
check_idxlist(intersection, sorted_index_list, (int)(num_vecs*num_indices));
}
{
enum {
num_lists = 3,
section_ndims = 2,
};
static const Xt_int index_list[] = {1,3,5,7,9,11};
= {{.
start = 0, .stride = 2, .nstrides = 5},
{.start = 1, .stride = 2, .nstrides = 5}};
static const Xt_int global_size[section_ndims] = {10,10};
static const int local_size[section_ndims] = {5,5};
static const Xt_int local_start[section_ndims] = {2,2};
static const Xt_int ref_index_list[] = {1,3,5,7,9,11,
0,2,4,6,8,1,3,5,7,9,
22,23,24,25,26,
32,33,34,35,36,
42,43,44,45,46,
52,53,54,55,56,
62,63,64,65,66};
= {
xt_idxvec_new(index_list,
sizeof(index_list)/
sizeof(index_list[0])),
for (size_t i = 0; i < num_lists; ++i)
check_idxlist(collectionlist, ref_index_list,
(int)(sizeof(ref_index_list)/sizeof(ref_index_list[0])));
}
{
enum { num_lists = 2 };
for (size_t i = 0; i < num_lists; ++i)
enum { ndim = 3 };
static const Xt_int global_start_index = 0;
for (size_t i = 0; i < ndim; ++i)
global_size_bb[i] = 4;
global_start_index, bounds);
bool mismatch = false;
for (size_t i = 0; i < ndim; ++i)
mismatch |= (bounds[i].
size != 0);
if (mismatch)
PUT_ERR("ERROR: xt_idxlist_get_bounding_box\n");
}
{
enum {
num_lists = 2,
num_indices = 3,
};
static const Xt_int indices[num_lists][num_indices]
= {{45,35,32},{32,48,33}};
for (size_t i = 0; i < num_lists; ++i)
for (size_t i = 0; i < num_lists; ++i)
enum { ndim = 3 };
static const Xt_int global_size[ndim] = { 5, 4, 3 };
static const Xt_int global_start_index = 1;
global_start_index, bounds);
static const Xt_int ref_start[3] = { 2, 2, 1 };
bool mismatch = false;
for (size_t i = 0; i < ndim; ++i)
mismatch |= (bounds[i].
size != 2 || bounds[i].
start != ref_start[i]);
if (mismatch)
PUT_ERR("ERROR: xt_idxlist_get_bounding_box\n");
}
return TEST_EXIT_CODE;
}
add versions of standard API functions not returning on error
void xt_initialize(MPI_Comm default_comm)
Xt_idxlist xt_idxempty_new(void)
void xt_idxlist_get_index_stripes(Xt_idxlist idxlist, struct Xt_stripe **stripes, int *num_stripes)
void xt_idxlist_get_bounding_box(Xt_idxlist idxlist, unsigned ndim, const Xt_int global_size[ndim], Xt_int global_start_index, struct Xt_bounds bounds[ndim])
Xt_idxlist xt_idxlist_get_intersection(Xt_idxlist idxlist_src, Xt_idxlist idxlist_dst)
Xt_idxlist xt_idxlist_copy(Xt_idxlist idxlist)
void xt_idxlist_delete(Xt_idxlist idxlist)
Xt_idxlist xt_idxlist_collection_new(Xt_idxlist *idxlists, int num_idxlists)
Xt_idxlist xt_idxsection_new(Xt_int start, int num_dimensions, const Xt_int global_size[num_dimensions], const int local_size[num_dimensions], const Xt_int local_start[num_dimensions])
Xt_idxlist xt_idxstripes_new(struct Xt_stripe const *stripes, int num_stripes)
Xt_idxlist xt_idxvec_new(const Xt_int *idxlist, int num_indices)
#define xt_mpi_call(call, comm)