Commit c7acd11d authored by Thomas Jahns's avatar Thomas Jahns 🤸
Browse files

Speed up tests.

parent 81807f5a
......@@ -327,10 +327,12 @@ test_gather(MPI_Comm comm, Xt_exchanger_new exchanger_new)
}
}
bool mismatch = false;
for (size_t j = 0; j < nrecv; ++j)
if (((size_t)dst_data[j] != j + 1)
|| (dst_data[nrecv + j] != comm_size - (int)j - 1))
PUT_ERR("invalid data\n");
mismatch |= (((size_t)dst_data[j] != j + 1)
|| (dst_data[nrecv + j] != comm_size - (int)j - 1));
if (mismatch)
PUT_ERR("invalid data\n");
}
// cleanup
......@@ -407,8 +409,11 @@ test_all2all(MPI_Comm comm, Xt_exchanger_new exchanger_new)
xt_exchanger_s_exchange(exchanger, (void*)src_data, (void*)dst_data);
}
bool mismatch = false;
for (int k = 0; k < comm_size; ++k)
if (dst_data[k] != k) PUT_ERR("invalid data\n");
mismatch |= (dst_data[k] != k);
if (mismatch)
PUT_ERR("invalid data\n");
}
// cleanup
......@@ -550,8 +555,11 @@ test_intercomm_all2all(MPI_Comm comm, Xt_exchanger_new exchanger_new)
}
int dst_data_offset = (my_rank >= splitRank)?0:splitRank;
bool mismatch = false;
for (int i = 0; i < nrecv; ++i)
if (dst_data[i] != i + dst_data_offset) PUT_ERR("invalid data\n");
mismatch |= (dst_data[i] != i + dst_data_offset);
if (mismatch)
PUT_ERR("invalid data\n");
}
// cleanup
......
......@@ -261,9 +261,12 @@ int main(void) {
xt_idxlist_get_bounding_box(collectionlist, ndim, global_size_bb,
global_start_index, bounds);
bool mismatch = false;
for (size_t i = 0; i < ndim; ++i)
if (bounds[i].size != 0)
PUT_ERR("ERROR: xt_idxlist_get_bounding_box\n");
mismatch |= (bounds[i].size != 0);
if (mismatch)
PUT_ERR("ERROR: xt_idxlist_get_bounding_box\n");
xt_idxlist_delete(collectionlist);
}
......@@ -299,9 +302,12 @@ int main(void) {
static const Xt_int ref_start[3] = { 2, 2, 1 };
bool mismatch = false;
for (size_t i = 0; i < ndim; ++i)
if (bounds[i].size != 2 || bounds[i].start != ref_start[i])
PUT_ERR("ERROR: xt_idxlist_get_bounding_box\n");
mismatch |= (bounds[i].size != 2 || bounds[i].start != ref_start[i]);
if (mismatch)
PUT_ERR("ERROR: xt_idxlist_get_bounding_box\n");
xt_idxlist_delete(collectionlist);
}
......
......@@ -117,111 +117,116 @@ void check_idxlist(Xt_idxlist idxlist, Xt_int const * ref_indices,
xt_idxlist_get_indices(idxlist, indices);
const Xt_int *indices_const = xt_idxlist_get_indices_const(idxlist);
{
bool mismatch = false;
for(int i=0; i<ref_num_indices; i++)
if (ref_indices[i] != indices_const[i])
PUT_ERR("check_idxlist: ref_indices[i] != indices_const[i]\n");
mismatch |= (ref_indices[i] != indices_const[i]);
if (mismatch)
PUT_ERR("check_idxlist: ref_indices[i] != indices_const[i]\n");
}
{
int ref_positions[2][ref_num_indices_];
{
int position;
int ref_positions[ref_num_indices_];
ref_get_positions_of_indices(indices, num_indices, ref_indices,
ref_num_indices, ref_positions, 1);
int position;
for (int i = 0; i < ref_num_indices; ++i) {
ref_get_positions_of_indices(indices, num_indices, ref_indices,
ref_num_indices, ref_positions[1], 1);
if (indices[i] != ref_indices[i])
bool mismatch = false;
for (int i = 0; i < ref_num_indices; ++i)
mismatch |= (indices[i] != ref_indices[i]);
if (mismatch)
PUT_ERR("index list contains wrong indices\n");
if (xt_idxlist_get_index_at_position(idxlist, (int)i, &index) || index != ref_indices[i])
PUT_ERR("error in xt_idxlist_get_index_at_position\n");
for (int i = 0; i < ref_num_indices; ++i) {
if (xt_idxlist_get_position_of_index(idxlist, ref_indices[i], &position) ||
position != ref_positions[i])
PUT_ERR("error in xt_idxlist_get_position_of_index\n");
}
if (xt_idxlist_get_index_at_position(idxlist, (int)i, &index)
|| index != ref_indices[i])
PUT_ERR("error in xt_idxlist_get_index_at_position\n");
ref_get_positions_of_indices(indices, num_indices, ref_indices,
ref_num_indices, ref_positions, 0);
position = -1;
for (int i = 0; i < ref_num_indices; ++i) {
if (xt_idxlist_get_position_of_index_off(idxlist, ref_indices[i], &position,
position+1))
PUT_ERR("error in xt_idxlist_get_position_of_index_off\n");
if (xt_idxlist_get_position_of_index(idxlist, ref_indices[i], &position)
|| position != ref_positions[1][i])
PUT_ERR("error in xt_idxlist_get_position_of_index\n");
}
if (position != ref_positions[i])
PUT_ERR("get_positions_of_indices returned wrong position\n");
}
}
ref_get_positions_of_indices(indices, num_indices, ref_indices,
ref_num_indices, ref_positions[0], 0);
position = -1;
for (int i = 0; i < ref_num_indices; ++i) {
if (xt_idxlist_get_position_of_index_off(idxlist, ref_indices[i],
&position, position+1))
PUT_ERR("error in xt_idxlist_get_position_of_index_off\n");
{
int ref_positions[ref_num_indices_], positions[ref_num_indices_];
if (position != ref_positions[0][i])
PUT_ERR("get_positions_of_indices returned wrong position\n");
}
}
ref_get_positions_of_indices(indices, num_indices, ref_indices,
ref_num_indices, ref_positions, 0);
{
int positions[ref_num_indices_];
if (xt_idxlist_get_positions_of_indices(idxlist, ref_indices,
ref_num_indices, positions, 1))
PUT_ERR("get_positions_of_indices failed\n");
if (xt_idxlist_get_positions_of_indices(idxlist, ref_indices,
ref_num_indices, positions, 1))
PUT_ERR("get_positions_of_indices failed\n");
for (int i = 0; i < ref_num_indices; ++i)
if (positions[i] != ref_positions[i])
bool mismatch = false;
for (int i = 0; i < ref_num_indices; ++i)
mismatch |= (positions[i] != ref_positions[0][i]);
if (mismatch)
PUT_ERR("check_idxlist: get_positions_of_indices failed (case 1)\n");
}
{
int ref_positions[ref_num_indices_], positions[ref_num_indices_];
}
ref_get_positions_of_indices(indices, num_indices, ref_indices,
ref_num_indices, ref_positions, 1);
{
int positions[ref_num_indices_];
if (xt_idxlist_get_positions_of_indices(idxlist, ref_indices,
ref_num_indices, positions, 0))
PUT_ERR("get_positions_of_indices failed\n");
if (xt_idxlist_get_positions_of_indices(idxlist, ref_indices,
ref_num_indices, positions, 0))
PUT_ERR("get_positions_of_indices failed\n");
for (int i = 0; i < ref_num_indices; ++i)
if (positions[i] != ref_positions[i])
bool mismatch = false;
for (int i = 0; i < ref_num_indices; ++i)
mismatch |= (positions[i] != ref_positions[1][i]);
if (mismatch)
PUT_ERR("check_idxlist: get_positions_of_indices failed (case 2)\n");
}
}
{
Xt_int reverse_ref_indices[ref_num_indices_];
{
Xt_int reverse_ref_indices[ref_num_indices_];
for (int i = 0; i < ref_num_indices; ++i)
reverse_ref_indices[i] = ref_indices[ref_num_indices - i - 1];
for (int i = 0; i < ref_num_indices; ++i)
reverse_ref_indices[i] = ref_indices[ref_num_indices - i - 1];
{
int ref_positions[ref_num_indices_], positions[ref_num_indices_];
{
int positions[ref_num_indices_];
ref_get_positions_of_indices(indices, num_indices, reverse_ref_indices,
ref_num_indices, ref_positions, 0);
ref_get_positions_of_indices(indices, num_indices, reverse_ref_indices,
ref_num_indices, ref_positions[0], 0);
if (xt_idxlist_get_positions_of_indices(idxlist, reverse_ref_indices,
ref_num_indices, positions,
1))
PUT_ERR("get_positions_of_indices failed\n");
if (xt_idxlist_get_positions_of_indices(idxlist, reverse_ref_indices,
ref_num_indices, positions, 1))
PUT_ERR("get_positions_of_indices failed\n");
for (int i = 0; i < ref_num_indices; ++i)
if (positions[i] != ref_positions[i])
bool mismatch = false;
for (int i = 0; i < ref_num_indices; ++i)
mismatch |= (positions[i] != ref_positions[0][i]);
if (mismatch)
PUT_ERR("check_idxlist: get_positions_of_indices failed (case 3)\n");
}
{
int ref_positions[ref_num_indices_], positions[ref_num_indices_];
}
ref_get_positions_of_indices(indices, num_indices, reverse_ref_indices,
ref_num_indices, ref_positions, 1);
{
int positions[ref_num_indices_];
if (xt_idxlist_get_positions_of_indices(idxlist, reverse_ref_indices,
ref_num_indices, positions,
0))
PUT_ERR("get_positions_of_indices failed\n");
if (xt_idxlist_get_positions_of_indices(idxlist, reverse_ref_indices,
ref_num_indices, positions, 0))
PUT_ERR("get_positions_of_indices failed\n");
for (int i = 0; i < ref_num_indices; ++i)
if (positions[i] != ref_positions[i])
bool mismatch = false;
for (int i = 0; i < ref_num_indices; ++i)
mismatch |= (positions[i] != ref_positions[1][ref_num_indices-1-i]);
if (mismatch)
PUT_ERR("check_idxlist: get_positions_of_indices failed (case 4)\n");
}
}
}
......@@ -252,19 +257,23 @@ check_stripes(struct Xt_stripe const * stripes, int num_stripes,
if (num_stripes != ref_num_stripes)
PUT_ERR("wrong number of stripes\n");
bool mismatch = false;
for (i = 0; i < ref_num_stripes; ++i)
if (stripes[i].start != ref_stripes[i].start ||
stripes[i].nstrides != ref_stripes[i].nstrides ||
stripes[i].stride != ref_stripes[i].stride)
PUT_ERR("error in stripe (start, nstrides and/or stride)\n");
mismatch |= (stripes[i].start != ref_stripes[i].start ||
stripes[i].nstrides != ref_stripes[i].nstrides ||
stripes[i].stride != ref_stripes[i].stride);
if (mismatch)
PUT_ERR("error in stripe (start, nstrides and/or stride)\n");
}
void
check_offsets(size_t num_offsets, const int *offsets_a, const int *offsets_b)
{
bool mismatch = false;
for(size_t i=0; i<num_offsets; i++)
if (offsets_a[i] != offsets_b[i])
PUT_ERR("unexpected results for offsets or index positions\n");
mismatch |= (offsets_a[i] != offsets_b[i]);
if (mismatch)
PUT_ERR("unexpected results for offsets or index positions\n");
}
Xt_idxlist
......
......@@ -47,6 +47,7 @@
#include <config.h>
#endif
#include <stdbool.h>
#include <stdlib.h>
#include <assert.h>
......@@ -128,10 +129,11 @@ int main(void) {
static const int ref_mstate[]
= {1, 2|mod_mask, 3|mod_mask, 4|mod_mask, 5|mod_mask, 6, 7, 8};
// check mstate:
for (size_t i = 0; i < patch_num; i++) {
if (mstate[i] != ref_mstate[i])
PUT_ERR("(mstate[i] != ref_mstate[i])\n");
}
bool mismatch = false;
for (size_t i = 0; i < patch_num; i++)
mismatch |= (mstate[i] != ref_mstate[i]);
if (mismatch)
PUT_ERR("(mstate[i] != ref_mstate[i])\n");
xt_idxlist_delete(mpatch_idxlist);
xt_idxlist_delete(patch_idxlist);
......@@ -184,10 +186,11 @@ int main(void) {
check_idxlist(mpatch_idxlist, ref_mpatch_idx, patch_num);
// check mstate:
for (size_t i = 0; i < patch_num; i++) {
if (mstate[i] != ref_mstate[i])
PUT_ERR("(mstate[i] != ref_mstate[i])\n");
}
bool mismatch = false;
for (size_t i = 0; i < patch_num; i++)
mismatch |= (mstate[i] != ref_mstate[i]);
if (mismatch)
PUT_ERR("(mstate[i] != ref_mstate[i])\n");
xt_idxlist_delete(mpatch_idxlist);
xt_idxlist_delete(patch_idxlist);
......
......@@ -439,11 +439,12 @@ int main(void) {
PUT_ERR("xt_idxlist_get_position_of_indices returned incorrect"
" num_unmatched\n");
for (int i=0; i<num_selection; i++) {
if (positions[i] != ref_positions[i])
PUT_ERR("xt_idxlist_get_position_of_indices returned incorrect"
" position\n");
}
bool mismatch = false;
for (int i=0; i<num_selection; i++)
mismatch |= (positions[i] != ref_positions[i]);
if (mismatch)
PUT_ERR("xt_idxlist_get_position_of_indices returned incorrect"
" position\n");
xt_idxlist_delete(idxsection);
}
......@@ -452,34 +453,40 @@ int main(void) {
// check get_positions_of_indices with single_match_only = 0
Xt_int start = 0;
int num_dimensions = 2;
Xt_int global_size[2] = {4,4};
int local_size [2] = {2,2};
Xt_int local_start[2] = {0,2};
enum { num_dimensions = 2 };
static const Xt_int global_size[num_dimensions] = {4,4};
static const int local_size[num_dimensions] = {2,2};
static const Xt_int local_start[num_dimensions] = {0,2};
Xt_idxlist idxsection = xt_idxsection_new(start, num_dimensions, global_size,
local_size, local_start);
Xt_idxlist idxsection
= xt_idxsection_new(start, num_dimensions, global_size,
local_size, local_start);
// we have indices = {2,3,6,7}
Xt_int selection[] = {2,1,5,7,6,7,7,6,8};
int num_selection = (int)(sizeof(selection) / sizeof(*selection));
static const Xt_int selection[] = {2,1,5,7,6,7,7,6,8};
enum { num_selection = sizeof(selection) / sizeof(*selection) };
int positions[num_selection];
int ref_positions[] = {2*0+0, 1*0-1, 5*0-1, 7*0+3, 6*0+2, 7*0+3, 7*0+3, 6*0+2, 8*0-1};
static const int ref_positions[]
= {2*0+0, 1*0-1, 5*0-1, 7*0+3, 6*0+2, 7*0+3, 7*0+3, 6*0+2, 8*0-1};
int single_match_only = 0;
if (xt_idxlist_get_positions_of_indices(idxsection, selection, num_selection, positions, single_match_only) != 3)
PUT_ERR("xt_idxlist_get_position_of_indices did not return correct num_unmatched\n");
bool mismatch = false;
for (int i=0; i<num_selection; i++)
mismatch |= (positions[i] != ref_positions[i]);
if (mismatch)
PUT_ERR("xt_idxlist_get_positions_of_indices did not return correct"
" position\n");
for (int i=0; i<num_selection; i++) {
int p;
xt_idxlist_get_position_of_index(idxsection, selection[i], &p);
if (p != ref_positions[i])
PUT_ERR("xt_idxlist_get_position_of_index did not return correct position\n");
if (positions[i] != ref_positions[i])
PUT_ERR("xt_idxlist_get_positions_of_indices did not return correct position\n");
PUT_ERR("xt_idxlist_get_position_of_index did not return correct"
" position\n");
}
xt_idxlist_delete(idxsection);
......@@ -744,9 +751,12 @@ int main(void) {
PUT_ERR("error in xt_idxlist_get_positions_of_indices"
" (wrong number of unmatched indices)\n");
bool mismatch = false;
for (int i = 0; i < 34; ++i)
if (ref_positions[i] != positions[i])
PUT_ERR("error in xt_idxlist_get_positions_of_indices (wrong position)\n");
mismatch |= (ref_positions[i] != positions[i]);
if (mismatch)
PUT_ERR("error in xt_idxlist_get_positions_of_indices"
" (wrong position)\n");
// clean up
......@@ -867,9 +877,11 @@ int main(void) {
Xt_int ref_start[3] = {2,2,1};
for (unsigned i = 0; i < ndim; ++i)
if (bounds[i].size != 2 || bounds[i].start != ref_start[i])
PUT_ERR("ERROR: xt_idxlist_get_bounding_box\n");
bool mismatch = false;
for (int 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");
xt_idxlist_delete(idxsection);
}
......@@ -904,9 +916,12 @@ int main(void) {
Xt_int ref_start[3] = {2,1,1};
Xt_int ref_size[3] = {2,3,2};
for (unsigned i = 0; i < ndim; ++i)
if (bounds[i].size != ref_size[i] || bounds[i].start != ref_start[i])
PUT_ERR("ERROR: xt_idxlist_get_bounding_box\n");
bool mismatch = false;
for (int i = 0; i < ndim; ++i)
mismatch |= (bounds[i].size != ref_size[i]
|| bounds[i].start != ref_start[i]);
if (mismatch)
PUT_ERR("ERROR: xt_idxlist_get_bounding_box\n");
xt_idxlist_delete(idxsection);
}
......
......@@ -1463,14 +1463,16 @@ stripe_test_general(int num_stripes, const struct Xt_stripe *stripes,
struct Xt_pos_ext *pos_ext;
xt_idxlist_get_pos_exts_of_index_stripes(idxstripes, num_stripes, stripes,
&num_ext, &pos_ext, 1);
bool mismatch = false;
size_t num_pos = 0;
for (int i = 0; i < num_ext; ++i)
{
size_t ext_size = (size_t)pos_ext[i].size;
if (num_pos != (size_t)pos_ext[i].start)
PUT_ERR("position/start mismatch at extent %d\n", i);
mismatch |= (num_pos != (size_t)pos_ext[i].start);
num_pos += ext_size;
}
if (mismatch)
PUT_ERR("position/start mismatch\n");
if (num_pos != (size_t)xt_idxlist_get_num_indices(idxstripes))
PUT_ERR("index list length/positions overlap mismatch\n");
......@@ -1648,11 +1650,13 @@ check_idxvec_get_indices_at_positions(int num_stripes,
int undef_count = xt_idxlist_get_indices_at_positions(idxlist, pos, num_pos,
sel_idx, undef_idx);
if (undef_count != ref_undef_count)
PUT_ERR("test_idxvec.c: (undef_count != ref_undef_count)\n");
for (int i=0; i<num_pos; i++) {
if (sel_idx[i] != ref_sel_idx[i])
PUT_ERR("test_idxvec.c: (sel_idx[%d] != ref_sel_idx[%d])\n", i, i);
}
PUT_ERR("test_idxstripes.c: (undef_count != ref_undef_count)\n");
bool mismatch = false;
for (int i=0; i<num_pos; i++)
mismatch |= (sel_idx[i] != ref_sel_idx[i]);
if (mismatch)
PUT_ERR("test_idxstripes.c: sel_idx mismatch\n");
xt_idxlist_delete(idxlist);
}
......@@ -1668,7 +1672,7 @@ get_idxlist_pos_exts_of_index_stripes(
idxlist, (int)num_stripes, stripes, &num_ext_, &pos_ext_,
single_match_only);
if (retval != 0 || num_ext_ < 0)
PUT_ERR("error in xt_idxlist_get_pos_exts_of_index_stripes\n");
PUT_ERR("error in xt_idxlist_get_pos_exts_of_index_stripes\n");
*num_ext = (size_t)num_ext_;
return pos_ext_;
}
......@@ -1725,10 +1729,13 @@ check_bb(int num_stripes, const struct Xt_stripe *stripes,
xt_idxlist_get_bounding_box(idxstripes, ndim, global_size,
global_start_index, bounds);
for (unsigned i = 0; i < ndim; ++i)
if ((bounds[i].size != ref_bounds[i].size) |
((ref_bounds[i].size != 0) & (bounds[i].start != ref_bounds[i].start)))
PUT_ERR("ERROR: xt_idxlist_get_bounding_box\n");
bool mismatch = false;
for (size_t i = 0; i < ndim; ++i)
mismatch |= ((bounds[i].size != ref_bounds[i].size) |
((ref_bounds[i].size != 0)
& (bounds[i].start != ref_bounds[i].start)));
if (mismatch)
PUT_ERR("ERROR: xt_idxlist_get_bounding_box\n");
xt_idxlist_delete(idxstripes);
}
......@@ -1756,12 +1763,16 @@ check_pos_ext(size_t num_stripes, const struct Xt_stripe stripes[num_stripes],
PUT_ERR("error in number of unmatched indices for %s", test_desc);
if (num_ext < 0 || (size_t)num_ext != num_ref_pos_ext)
PUT_ERR("error finding %s\n", test_desc);
bool mismatched_start = false,
mismatched_size = false;
for (size_t i = 0; i < num_ref_pos_ext; ++i) {
if (pos_ext[i].start != ref_pos_ext[i].start)
PUT_ERR("incorrect starting position found in %s\n", test_desc);
if (pos_ext[i].size != ref_pos_ext[i].size)
PUT_ERR("incorrect position extent length found in %s\n", test_desc);
mismatched_start |= (pos_ext[i].start != ref_pos_ext[i].start);
mismatched_size |= (pos_ext[i].size != ref_pos_ext[i].size);
}
if (mismatched_start)
PUT_ERR("incorrect starting position found in %s\n", test_desc);
if (mismatched_size)
PUT_ERR("incorrect position extent length found in %s\n", test_desc);
free(pos_ext);
xt_idxlist_delete(idxstripes);
}
......
......@@ -482,10 +482,12 @@ int main(void) {
positions, 0) != 2)
PUT_ERR("xt_idxlist_get_position_of_indices did not return correct num_unmatched\n");
for (size_t i = 0; i < num_selection; i++) {
if (positions[i] != ref_positions[i])
PUT_ERR("xt_idxlist_get_position_of_indices did not return correct position\n");
}
bool mismatch = false;
for (size_t i = 0; i < num_selection; i++)
mismatch |= (positions[i] != ref_positions[i]);
if (mismatch)
PUT_ERR("xt_idxlist_get_position_of_indices did not return correct"
" position\n");
xt_idxlist_delete(idxvec);
}
......@@ -508,9 +510,11 @@ int main(void) {
xt_idxlist_get_bounding_box(idxvec, ndim, global_size,
global_start_index, bounds);
bool mismatch = false;
for (unsigned i = 0; i < ndim; ++i)
if (bounds[i].size != 2 || bounds[i].start != 1)
PUT_ERR("ERROR: xt_idxlist_get_bounding_box\n");
mismatch |= (bounds[i].size != 2 || bounds[i].start != 1);
if (mismatch)
PUT_ERR("ERROR: xt_idxlist_get_bounding_box\n");
xt_idxlist_delete(idxvec);
}
......@@ -536,9 +540,11 @@ int main(void) {
Xt_int ref_start[3] = {2,2,1};
for (unsigned i = 0; i < ndim; ++i)
if (bounds[i].size != 2 || bounds[i].start != ref_start[i])
PUT_ERR("ERROR: xt_idxlist_get_bounding_box\n");
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");
xt_idxlist_delete(idxvec);
}
......@@ -561,9 +567,11 @@ int main(void) {
xt_idxlist_get_bounding_box(idxvec, ndim, global_size,
global_start_index, bounds);
for (unsigned i = 0; i < ndim; ++i)
if (bounds[i].size != 0)
PUT_ERR("ERROR: xt_idxlist_get_bounding_box\n");
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");
xt_idxlist_delete(idxvec);
}
......@@ -626,11 +634,12 @@ test_get_indices_at_positions(int num_indices, const Xt_int *indices,
= xt_idxlist_