From c9f0de12be31eea463bf022f3eee76490b30f8dc Mon Sep 17 00:00:00 2001 From: Tom Harley Date: Fri, 24 Jan 2020 05:15:35 +0000 Subject: Initial commit --- test/test.c | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 test/test.c (limited to 'test/test.c') diff --git a/test/test.c b/test/test.c new file mode 100644 index 0000000..8f51f62 --- /dev/null +++ b/test/test.c @@ -0,0 +1,55 @@ +#include + +#include "parapat.h" + +typedef struct { + int v; +} arg_t; + +void *test_work(void *v) { + arg_t *a = v; + a->v *= 2; + return a; +} + +void *test_fold(void *a, void *b) { + arg_t *x = a, *y = b; + + x->v += y->v; + + return x; +} + +int main() { + int i; + arg_t a, *res = &a; + + arg_t args[10]; + arg_t *ptrs[10]; + + work *fns[4] = { + &test_work, + &test_work, + &test_work, + &test_work + }; + + pipeline *pl; + + for (i = 0; i < 10; ++i) { + args[i].v = i; + ptrs[i] = &args[i]; + } + + a.v = 0; + + res = create_farm(&test_work, &test_fold, 10, (void **) &ptrs[0]); + printf("after farm: %d\n", res->v); + + pl = create_pipeline(fns, 4); + push(pl->in, res); + res = pop(pl->out); + printf("after pipeline: %d\n", res->v); + + return 0; +} -- cgit v1.2.1