...
 
Commits (21)
...@@ -2,6 +2,6 @@ AM_CFLAGS = -Wall -Werror -pedantic ...@@ -2,6 +2,6 @@ AM_CFLAGS = -Wall -Werror -pedantic
lib_LTLIBRARIES = libexcit.la lib_LTLIBRARIES = libexcit.la
libexcit_la_SOURCES = excit.c slice.c prod.c cons.c repeat.c hilbert2d.c range.c tleaf.c libexcit_la_SOURCES = excit.c composition.c prod.c cons.c repeat.c hilbert2d.c range.c tleaf.c
include_HEADERS = excit.h include_HEADERS = excit.h
#include "dev/excit.h" #include "dev/excit.h"
#include "slice.h" #include "composition.h"
static int slice_it_alloc(excit_t data) static int composition_it_alloc(excit_t data)
{ {
struct slice_it_s *it = (struct slice_it_s *)data->data; struct composition_it_s *it = (struct composition_it_s *)data->data;
it->src = NULL; it->src = NULL;
it->indexer = NULL; it->indexer = NULL;
return EXCIT_SUCCESS; return EXCIT_SUCCESS;
} }
static void slice_it_free(excit_t data) static void composition_it_free(excit_t data)
{ {
struct slice_it_s *it = (struct slice_it_s *)data->data; struct composition_it_s *it = (struct composition_it_s *)data->data;
excit_free(it->src); excit_free(it->src);
excit_free(it->indexer); excit_free(it->indexer);
} }
static int slice_it_copy(excit_t dst, const excit_t src) static int composition_it_copy(excit_t dst, const excit_t src)
{ {
const struct slice_it_s *it = (const struct slice_it_s *)src->data; const struct composition_it_s *it = (const struct composition_it_s *)src->data;
struct slice_it_s *result = (struct slice_it_s *)dst->data; struct composition_it_s *result = (struct composition_it_s *)dst->data;
result->src = excit_dup(it->src); result->src = excit_dup(it->src);
if (!result->src) if (!result->src)
...@@ -34,9 +34,9 @@ static int slice_it_copy(excit_t dst, const excit_t src) ...@@ -34,9 +34,9 @@ static int slice_it_copy(excit_t dst, const excit_t src)
return EXCIT_SUCCESS; return EXCIT_SUCCESS;
} }
static int slice_it_next(excit_t data, ssize_t *indexes) static int composition_it_next(excit_t data, ssize_t *indexes)
{ {
struct slice_it_s *it = (struct slice_it_s *)data->data; struct composition_it_s *it = (struct composition_it_s *)data->data;
ssize_t n; ssize_t n;
int err = excit_next(it->indexer, &n); int err = excit_next(it->indexer, &n);
...@@ -45,9 +45,9 @@ static int slice_it_next(excit_t data, ssize_t *indexes) ...@@ -45,9 +45,9 @@ static int slice_it_next(excit_t data, ssize_t *indexes)
return excit_nth(it->src, n, indexes); return excit_nth(it->src, n, indexes);
} }
static int slice_it_peek(const excit_t data, ssize_t *indexes) static int composition_it_peek(const excit_t data, ssize_t *indexes)
{ {
const struct slice_it_s *it = (const struct slice_it_s *)data->data; const struct composition_it_s *it = (const struct composition_it_s *)data->data;
ssize_t n; ssize_t n;
int err = excit_peek(it->indexer, &n); int err = excit_peek(it->indexer, &n);
...@@ -56,23 +56,23 @@ static int slice_it_peek(const excit_t data, ssize_t *indexes) ...@@ -56,23 +56,23 @@ static int slice_it_peek(const excit_t data, ssize_t *indexes)
return excit_nth(it->src, n, indexes); return excit_nth(it->src, n, indexes);
} }
static int slice_it_size(const excit_t data, ssize_t *size) static int composition_it_size(const excit_t data, ssize_t *size)
{ {
const struct slice_it_s *it = (const struct slice_it_s *)data->data; const struct composition_it_s *it = (const struct composition_it_s *)data->data;
return excit_size(it->indexer, size); return excit_size(it->indexer, size);
} }
static int slice_it_rewind(excit_t data) static int composition_it_rewind(excit_t data)
{ {
struct slice_it_s *it = (struct slice_it_s *)data->data; struct composition_it_s *it = (struct composition_it_s *)data->data;
return excit_rewind(it->indexer); return excit_rewind(it->indexer);
} }
static int slice_it_nth(const excit_t data, ssize_t n, ssize_t *indexes) static int composition_it_nth(const excit_t data, ssize_t n, ssize_t *indexes)
{ {
const struct slice_it_s *it = (const struct slice_it_s *)data->data; const struct composition_it_s *it = (const struct composition_it_s *)data->data;
ssize_t p; ssize_t p;
int err = excit_nth(it->indexer, n, &p); int err = excit_nth(it->indexer, n, &p);
...@@ -81,10 +81,10 @@ static int slice_it_nth(const excit_t data, ssize_t n, ssize_t *indexes) ...@@ -81,10 +81,10 @@ static int slice_it_nth(const excit_t data, ssize_t n, ssize_t *indexes)
return excit_nth(it->src, p, indexes); return excit_nth(it->src, p, indexes);
} }
static int slice_it_rank(const excit_t data, const ssize_t *indexes, static int composition_it_rank(const excit_t data, const ssize_t *indexes,
ssize_t *n) ssize_t *n)
{ {
const struct slice_it_s *it = (const struct slice_it_s *)data->data; const struct composition_it_s *it = (const struct composition_it_s *)data->data;
ssize_t inner_n; ssize_t inner_n;
int err = excit_rank(it->src, indexes, &inner_n); int err = excit_rank(it->src, indexes, &inner_n);
...@@ -93,16 +93,16 @@ static int slice_it_rank(const excit_t data, const ssize_t *indexes, ...@@ -93,16 +93,16 @@ static int slice_it_rank(const excit_t data, const ssize_t *indexes,
return excit_rank(it->indexer, &inner_n, n); return excit_rank(it->indexer, &inner_n, n);
} }
static int slice_it_pos(const excit_t data, ssize_t *n) static int composition_it_pos(const excit_t data, ssize_t *n)
{ {
const struct slice_it_s *it = (const struct slice_it_s *)data->data; const struct composition_it_s *it = (const struct composition_it_s *)data->data;
return excit_pos(it->indexer, n); return excit_pos(it->indexer, n);
} }
static int slice_it_split(const excit_t data, ssize_t n, excit_t *results) static int composition_it_split(const excit_t data, ssize_t n, excit_t *results)
{ {
const struct slice_it_s *it = (const struct slice_it_s *)data->data; const struct composition_it_s *it = (const struct composition_it_s *)data->data;
int err = excit_split(it->indexer, n, results); int err = excit_split(it->indexer, n, results);
if (err) if (err)
...@@ -114,7 +114,7 @@ static int slice_it_split(const excit_t data, ssize_t n, excit_t *results) ...@@ -114,7 +114,7 @@ static int slice_it_split(const excit_t data, ssize_t n, excit_t *results)
excit_t tmp2; excit_t tmp2;
tmp = results[i]; tmp = results[i];
results[i] = excit_alloc(EXCIT_SLICE); results[i] = excit_alloc(EXCIT_COMPOSITION);
if (!results[i]) { if (!results[i]) {
excit_free(tmp); excit_free(tmp);
err = -EXCIT_ENOMEM; err = -EXCIT_ENOMEM;
...@@ -126,7 +126,7 @@ static int slice_it_split(const excit_t data, ssize_t n, excit_t *results) ...@@ -126,7 +126,7 @@ static int slice_it_split(const excit_t data, ssize_t n, excit_t *results)
err = -EXCIT_ENOMEM; err = -EXCIT_ENOMEM;
goto error; goto error;
} }
err = excit_slice_init(results[i], tmp2, tmp); err = excit_composition_init(results[i], tmp2, tmp);
if (err) { if (err) {
excit_free(tmp); excit_free(tmp);
excit_free(tmp2); excit_free(tmp2);
...@@ -140,26 +140,26 @@ error: ...@@ -140,26 +140,26 @@ error:
return err; return err;
} }
struct excit_func_table_s excit_slice_func_table = { struct excit_func_table_s excit_composition_func_table = {
slice_it_alloc, composition_it_alloc,
slice_it_free, composition_it_free,
slice_it_copy, composition_it_copy,
slice_it_next, composition_it_next,
slice_it_peek, composition_it_peek,
slice_it_size, composition_it_size,
slice_it_rewind, composition_it_rewind,
slice_it_split, composition_it_split,
slice_it_nth, composition_it_nth,
slice_it_rank, composition_it_rank,
slice_it_pos composition_it_pos
}; };
int excit_slice_init(excit_t it, excit_t src, excit_t indexer) int excit_composition_init(excit_t it, excit_t src, excit_t indexer)
{ {
if (!it || it->type != EXCIT_SLICE || !src || !indexer if (!it || it->type != EXCIT_COMPOSITION || !src || !indexer
|| indexer->dimension != 1) || indexer->dimension != 1)
return -EXCIT_EINVAL; return -EXCIT_EINVAL;
struct slice_it_s *slice_it = (struct slice_it_s *)it->data; struct composition_it_s *composition_it = (struct composition_it_s *)it->data;
ssize_t size_src; ssize_t size_src;
ssize_t size_indexer; ssize_t size_indexer;
int err = excit_size(src, &size_src); int err = excit_size(src, &size_src);
...@@ -171,8 +171,8 @@ int excit_slice_init(excit_t it, excit_t src, excit_t indexer) ...@@ -171,8 +171,8 @@ int excit_slice_init(excit_t it, excit_t src, excit_t indexer)
return err; return err;
if (size_indexer > size_src) if (size_indexer > size_src)
return -EXCIT_EDOM; return -EXCIT_EDOM;
slice_it->src = src; composition_it->src = src;
slice_it->indexer = indexer; composition_it->indexer = indexer;
it->dimension = src->dimension; it->dimension = src->dimension;
return EXCIT_SUCCESS; return EXCIT_SUCCESS;
} }
......
...@@ -4,12 +4,12 @@ ...@@ -4,12 +4,12 @@
#include "excit.h" #include "excit.h"
#include "dev/excit.h" #include "dev/excit.h"
struct slice_it_s { struct composition_it_s {
excit_t src; excit_t src;
excit_t indexer; excit_t indexer;
}; };
extern struct excit_func_table_s excit_slice_func_table; extern struct excit_func_table_s excit_composition_func_table;
#endif //EXCIT_SLICE_H #endif //EXCIT_SLICE_H
#include <stdlib.h> #include <stdlib.h>
#include "excit.h" #include "excit.h"
#include "dev/excit.h" #include "dev/excit.h"
#include "slice.h" #include "composition.h"
#include "prod.h" #include "prod.h"
#include "cons.h" #include "cons.h"
#include "repeat.h" #include "repeat.h"
...@@ -19,7 +19,7 @@ const char *excit_type_name(enum excit_type_e type) ...@@ -19,7 +19,7 @@ const char *excit_type_name(enum excit_type_e type)
CASE(EXCIT_REPEAT); CASE(EXCIT_REPEAT);
CASE(EXCIT_HILBERT2D); CASE(EXCIT_HILBERT2D);
CASE(EXCIT_PRODUCT); CASE(EXCIT_PRODUCT);
CASE(EXCIT_SLICE); CASE(EXCIT_COMPOSITION);
CASE(EXCIT_USER); CASE(EXCIT_USER);
CASE(EXCIT_TYPE_MAX); CASE(EXCIT_TYPE_MAX);
default: default:
...@@ -115,8 +115,8 @@ excit_t excit_alloc(enum excit_type_e type) ...@@ -115,8 +115,8 @@ excit_t excit_alloc(enum excit_type_e type)
case EXCIT_PRODUCT: case EXCIT_PRODUCT:
ALLOC_EXCIT(prod); ALLOC_EXCIT(prod);
break; break;
case EXCIT_SLICE: case EXCIT_COMPOSITION:
ALLOC_EXCIT(slice); ALLOC_EXCIT(composition);
break; break;
case EXCIT_TLEAF: case EXCIT_TLEAF:
ALLOC_EXCIT(tleaf); ALLOC_EXCIT(tleaf);
...@@ -270,12 +270,12 @@ int excit_split(const excit_t it, ssize_t n, excit_t *results) ...@@ -270,12 +270,12 @@ int excit_split(const excit_t it, ssize_t n, excit_t *results)
if (!tmp) if (!tmp)
goto error2; goto error2;
tmp2 = results[i]; tmp2 = results[i];
results[i] = excit_alloc(EXCIT_SLICE); results[i] = excit_alloc(EXCIT_COMPOSITION);
if (!results[i]) { if (!results[i]) {
excit_free(tmp2); excit_free(tmp2);
goto error2; goto error2;
} }
err = excit_slice_init(results[i], tmp, tmp2); err = excit_composition_init(results[i], tmp, tmp2);
if (err) { if (err) {
excit_free(tmp2); excit_free(tmp2);
goto error2; goto error2;
......
This diff is collapsed.
This diff is collapsed.
...@@ -6,10 +6,11 @@ ...@@ -6,10 +6,11 @@
struct tleaf_it_s { struct tleaf_it_s {
ssize_t depth; ssize_t depth;
ssize_t *arities; ssize_t *arities;
ssize_t *order;
ssize_t *order_inverse;
ssize_t *buf; ssize_t *buf;
ssize_t *order;
excit_t levels; excit_t levels;
ssize_t *order_inverse;
excit_t levels_inverse;
}; };
extern struct excit_func_table_s excit_tleaf_func_table; extern struct excit_func_table_s excit_tleaf_func_table;
......
...@@ -10,10 +10,11 @@ excit_range_SOURCES = $(LIBHSOURCES) $(LIBCSOURCES) excit_range.c ...@@ -10,10 +10,11 @@ excit_range_SOURCES = $(LIBHSOURCES) $(LIBCSOURCES) excit_range.c
excit_product_SOURCES = $(LIBHSOURCES) $(LIBCSOURCES) excit_product.c excit_product_SOURCES = $(LIBHSOURCES) $(LIBCSOURCES) excit_product.c
excit_repeat_SOURCES = $(LIBHSOURCES) $(LIBCSOURCES) excit_repeat.c excit_repeat_SOURCES = $(LIBHSOURCES) $(LIBCSOURCES) excit_repeat.c
excit_cons_SOURCES = $(LIBHSOURCES) $(LIBCSOURCES) excit_cons.c excit_cons_SOURCES = $(LIBHSOURCES) $(LIBCSOURCES) excit_cons.c
excit_tleaf_SOURCES = $(LIBHSOURCES) $(LIBCSOURCES) excit_tleaf.c
excit_hilbert2d_SOURCES = $(LIBHSOURCES) $(LIBCSOURCES) excit_hilbert2d.c excit_hilbert2d_SOURCES = $(LIBHSOURCES) $(LIBCSOURCES) excit_hilbert2d.c
excit_slice_SOURCES = $(LIBHSOURCES) $(LIBCSOURCES) excit_slice.c excit_composition_SOURCES = $(LIBHSOURCES) $(LIBCSOURCES) excit_composition.c
UNIT_TESTS = excit_range excit_product excit_repeat excit_cons excit_hilbert2d excit_slice UNIT_TESTS = excit_range excit_product excit_repeat excit_cons excit_hilbert2d excit_composition excit_tleaf
# all tests # all tests
check_PROGRAMS = $(UNIT_TESTS) check_PROGRAMS = $(UNIT_TESTS)
......
...@@ -15,16 +15,16 @@ excit_t create_test_range(ssize_t start, ssize_t stop, ssize_t step) ...@@ -15,16 +15,16 @@ excit_t create_test_range(ssize_t start, ssize_t stop, ssize_t step)
return it; return it;
} }
void test_alloc_init_slice(excit_t source, excit_t indexer) void test_alloc_init_composition(excit_t source, excit_t indexer)
{ {
excit_t it; excit_t it;
ssize_t dim, expected_dim, size, expected_size; ssize_t dim, expected_dim, size, expected_size;
it = excit_alloc_test(EXCIT_SLICE); it = excit_alloc_test(EXCIT_COMPOSITION);
assert(excit_dimension(it, &dim) == ES); assert(excit_dimension(it, &dim) == ES);
assert(dim == 0); assert(dim == 0);
assert(excit_slice_init(it, excit_dup(source), excit_dup(indexer)) == assert(excit_composition_init(it, excit_dup(source), excit_dup(indexer)) ==
ES); ES);
assert(excit_dimension(it, &dim) == ES); assert(excit_dimension(it, &dim) == ES);
assert(excit_dimension(source, &expected_dim) == ES); assert(excit_dimension(source, &expected_dim) == ES);
...@@ -36,19 +36,19 @@ void test_alloc_init_slice(excit_t source, excit_t indexer) ...@@ -36,19 +36,19 @@ void test_alloc_init_slice(excit_t source, excit_t indexer)
excit_free(it); excit_free(it);
} }
excit_t create_test_slice(excit_t source, excit_t indexer) excit_t create_test_composition(excit_t source, excit_t indexer)
{ {
excit_t it; excit_t it;
it = excit_alloc_test(EXCIT_SLICE); it = excit_alloc_test(EXCIT_COMPOSITION);
assert(excit_slice_init(it, excit_dup(source), excit_dup(indexer)) == assert(excit_composition_init(it, excit_dup(source), excit_dup(indexer)) ==
ES); ES);
return it; return it;
} }
void test_next_slice(excit_t source, excit_t indexer) void test_next_composition(excit_t source, excit_t indexer)
{ {
excit_t it = create_test_slice(source, indexer); excit_t it = create_test_composition(source, indexer);
excit_t iit = excit_dup(indexer); excit_t iit = excit_dup(indexer);
...@@ -73,16 +73,16 @@ void test_next_slice(excit_t source, excit_t indexer) ...@@ -73,16 +73,16 @@ void test_next_slice(excit_t source, excit_t indexer)
excit_free(iit); excit_free(iit);
} }
void test_slice_iterator(excit_t source, excit_t indexer) void test_composition_iterator(excit_t source, excit_t indexer)
{ {
test_alloc_init_slice(source, indexer); test_alloc_init_composition(source, indexer);
test_next_slice(source, indexer); test_next_composition(source, indexer);
int i = 0; int i = 0;
while (synthetic_tests[i]) { while (synthetic_tests[i]) {
excit_t it = create_test_slice(source, indexer); excit_t it = create_test_composition(source, indexer);
synthetic_tests[i] (it); synthetic_tests[i] (it);
excit_free(it); excit_free(it);
...@@ -96,13 +96,13 @@ int main(int argc, char *argv[]) ...@@ -96,13 +96,13 @@ int main(int argc, char *argv[])
source = create_test_range(-15, 14, 2); source = create_test_range(-15, 14, 2);
indexer = create_test_range(4, 12, 3); indexer = create_test_range(4, 12, 3);
test_slice_iterator(source, indexer); test_composition_iterator(source, indexer);
source2 = excit_alloc_test(EXCIT_PRODUCT); source2 = excit_alloc_test(EXCIT_PRODUCT);
assert(excit_product_add(source2, create_test_range(-15, 14, 2)) == ES); assert(excit_product_add(source2, create_test_range(-15, 14, 2)) == ES);
assert(excit_product_add(source2, create_test_range(4, 12, 3)) == ES); assert(excit_product_add(source2, create_test_range(4, 12, 3)) == ES);
indexer2 = create_test_range(4, 35, 2); indexer2 = create_test_range(4, 35, 2);
test_slice_iterator(source2, indexer2); test_composition_iterator(source2, indexer2);
excit_free(source); excit_free(source);
excit_free(source2); excit_free(source2);
......
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <stdint.h>
#include <string.h>
#include "excit.h"
#include "excit_test.h"
static excit_t create_test_tleaf(const ssize_t depth,
const ssize_t *arities,
excit_t *indexes,
const enum tleaf_it_policy_e policy,
const ssize_t *user_policy)
{
int err = EXCIT_SUCCESS;
excit_t it;
it = excit_alloc_test(EXCIT_TLEAF);
assert(it != NULL);
err =
excit_tleaf_init(it, depth + 1, arities, indexes, policy,
user_policy);
assert(err == EXCIT_SUCCESS);
ssize_t i, size = 1, it_size, arity;
for (i = 0; i < depth; i++) {
if (indexes && indexes[i])
assert(excit_size(indexes[i], &arity) == EXCIT_SUCCESS);
else
arity = arities[i];
size *= arity;
}
assert(excit_size(it, &it_size) == EXCIT_SUCCESS);
assert(it_size == size);
return it;
}
static void tleaf_test_round_robin_policy(excit_t tleaf)
{
ssize_t i, value, size;
assert(excit_size(tleaf, &size) == EXCIT_SUCCESS);
assert(excit_rewind(tleaf) == EXCIT_SUCCESS);
for (i = 0; i < size; i++) {
assert(excit_next(tleaf, &value) == EXCIT_SUCCESS);
assert(value == i);
}
assert(excit_next(tleaf, &value) == EXCIT_STOPIT);
}
static void tleaf_test_indexed_round_robin_policy(excit_t tleaf,
const ssize_t depth,
const ssize_t *arities,
excit_t *_indexes)
{
ssize_t i, j, value, indexed_value, indexed_mul, size, arity;
ssize_t *values = malloc(depth * sizeof(*values));
excit_t check = excit_alloc(EXCIT_PRODUCT);
assert(values != NULL);
assert(check != NULL);
for (i = 0; i < depth; i++) {
excit_t range = excit_alloc(EXCIT_RANGE);
assert(range != NULL);
assert(excit_range_init(range, 0, arities[i] - 1, 1) ==
EXCIT_SUCCESS);
if (_indexes[i] != NULL) {
excit_t comp = excit_alloc(EXCIT_COMPOSITION);
assert(comp != NULL);
excit_t index = excit_dup(_indexes[i]);
assert(index != NULL);
assert(excit_rewind(index) == EXCIT_SUCCESS);
assert(excit_composition_init(comp, range, index) ==
EXCIT_SUCCESS);
assert(excit_product_add(check, comp) == EXCIT_SUCCESS);
} else {
assert(excit_product_add(check, range) ==
EXCIT_SUCCESS);
}
}
assert(excit_size(tleaf, &size) == EXCIT_SUCCESS);
assert(excit_rewind(tleaf) == EXCIT_SUCCESS);
assert(excit_rewind(check) == EXCIT_SUCCESS);
for (i = 0; i < size; i++) {
assert(excit_next(tleaf, &value) == EXCIT_SUCCESS);
assert(excit_next(check, values) == EXCIT_SUCCESS);
indexed_value = 0;
indexed_mul = 1;
for (j = 0; j < depth; j++) {
arity = arities[depth - j - 1];
indexed_value += indexed_mul * values[depth - j - 1];
indexed_mul *= arity;
}
assert(value == indexed_value);
}
excit_free(check);
free(values);
}
static void tleaf_test_scatter_policy_no_split(excit_t tleaf,
const ssize_t depth,
const ssize_t *arities)
{
ssize_t i, j, r, n, c, value, val, size;
assert(excit_size(tleaf, &size) == EXCIT_SUCCESS);
assert(excit_rewind(tleaf) == EXCIT_SUCCESS);
for (i = 0; i < size; i++) {
c = i;
n = size;
val = 0;
assert(excit_next(tleaf, &value) == EXCIT_SUCCESS);
for (j = 0; j < depth; j++) {
r = c % arities[j];
n = n / arities[j];
c = c / arities[j];
val += n * r;
}
assert(value == val);
}
assert(excit_next(tleaf, &value) == EXCIT_STOPIT);
}
static void tleaf_test_round_robin_split(excit_t tleaf,
const ssize_t depth,
const ssize_t *arities)
{
ssize_t i, value, size, cut_size;
ssize_t ncut = arities[0];
assert(excit_size(tleaf, &size) == EXCIT_SUCCESS);
cut_size = size / ncut;
excit_t *split = malloc(sizeof(*split) * ncut);
assert(split != NULL);
int err = tleaf_it_split(tleaf, 0, ncut, split);
assert(err == EXCIT_SUCCESS);
ssize_t *cut_sizes = malloc(sizeof(*cut_sizes) * ncut);
assert(cut_sizes != NULL);
for (i = 0; i < ncut; i++) {
assert(excit_size(split[i], cut_sizes + i) == EXCIT_SUCCESS);
assert(cut_sizes[i] == cut_size);
}
for (i = 0; i < size; i++) {
excit_t it = split[i * ncut / size];
assert(excit_next(it, &value) == EXCIT_SUCCESS);
assert(value == i);
}
for (i = 0; i < ncut; i++)
excit_free(split[i]);
free(split);
free(cut_sizes);
}
void run_tests(const ssize_t depth, const ssize_t *arities)
{
/* Test of round robin policy */
excit_t rrobin =
create_test_tleaf(depth, arities, NULL, TLEAF_POLICY_ROUND_ROBIN,
NULL);
assert(rrobin != NULL);
tleaf_test_round_robin_policy(rrobin);
assert(excit_rewind(rrobin) == EXCIT_SUCCESS);
/* Test of split operation on round robin policy */
tleaf_test_round_robin_split(rrobin, depth, arities);
excit_free(rrobin);
/* Test of indexing on a round robin policy */
ssize_t i;
excit_t *indexes = malloc(depth * sizeof(*indexes));
assert(indexes != NULL);
for (i = 0; i < depth; i++) {
if (arities[i] > 2) {
indexes[i] = excit_alloc(EXCIT_RANGE);
assert(indexes[i] != NULL);
assert(excit_range_init
(indexes[i], 0, arities[i] / 2 - 1,
1) == EXCIT_SUCCESS);
} else {
indexes[i] = NULL;
}
}
excit_t indexed_rrobin =
create_test_tleaf(depth, arities, indexes, TLEAF_POLICY_ROUND_ROBIN,
NULL);
assert(indexed_rrobin != NULL);
tleaf_test_indexed_round_robin_policy(indexed_rrobin, depth, arities,
indexes);
excit_free(indexed_rrobin);
for (i = 0; i < depth; i++)
excit_free(indexes[i]);
free(indexes);
/* Test of scatter policy */
excit_t scatter =
create_test_tleaf(depth, arities, NULL, TLEAF_POLICY_SCATTER, NULL);
assert(scatter != NULL);
tleaf_test_scatter_policy_no_split(scatter, depth, arities);
excit_free(scatter);
/* Generic iterator tests */
i = 0;
while (synthetic_tests[i]) {
excit_t it =
create_test_tleaf(depth, arities, NULL,
TLEAF_POLICY_ROUND_ROBIN,
NULL);
synthetic_tests[i] (it);
excit_free(it);
i++;
}
}
int main(int argc, char *argv[])
{
ssize_t depth = 4;
const ssize_t arities_0[4] = { 4, 8, 2, 4 };
run_tests(depth, arities_0);
depth = 8;
const ssize_t arities_1[8] = { 4, 6, 2, 4, 3, 6, 2, 9 };
run_tests(depth, arities_1);
return 0;
}