From 84a7a5d1cbb85bb29c210828056326b83cea2d1b Mon Sep 17 00:00:00 2001 From: Evghenii Date: Sat, 26 Oct 2013 16:16:28 +0200 Subject: [PATCH] added tests for 3d launch --- test_static.cpp | 15 +++++++++------ tests/launch-8.ispc | 42 ++++++++++++++++++++++++++++++++++++++++++ tests/launch-9.ispc | 42 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 93 insertions(+), 6 deletions(-) create mode 100644 tests/launch-8.ispc create mode 100644 tests/launch-9.ispc diff --git a/test_static.cpp b/test_static.cpp index 8985fdb3..fceeb64e 100644 --- a/test_static.cpp +++ b/test_static.cpp @@ -62,17 +62,20 @@ extern "C" { extern void f_di(float *result, double *a, int *b); extern void result(float *val); - void ISPCLaunch(void **handlePtr, void *f, void *d, int); + void ISPCLaunch(void **handlePtr, void *f, void *d, int,int,int); void ISPCSync(void *handle); void *ISPCAlloc(void **handlePtr, int64_t size, int32_t alignment); } - -void ISPCLaunch(void **handle, void *f, void *d, int count) { + +void ISPCLaunch(void **handle, void *f, void *d, int count0, int count1, int count2) { *handle = (void *)0xdeadbeef; - typedef void (*TaskFuncType)(void *, int, int, int, int); + typedef void (*TaskFuncType)(void *, int, int, int, int, int,int,int, int,int,int); TaskFuncType func = (TaskFuncType)f; - for (int i = 0; i < count; ++i) - func(d, 0, 1, i, count); + int count = count0*count1*count2, idx = 0; + for (int k = 0; k < count2; ++k) + for (int j = 0; j < count1; ++j) + for (int i = 0; i < count0; ++i) + func(d, 0, 1, idx++, count, i,j,k,count0,count1,count2); } void ISPCSync(void *) { diff --git a/tests/launch-8.ispc b/tests/launch-8.ispc new file mode 100644 index 00000000..a0b976e4 --- /dev/null +++ b/tests/launch-8.ispc @@ -0,0 +1,42 @@ + +export uniform int width() { return programCount; } + + +#define N0 10 +#define N1 20 +#define N2 50 +static uniform float array[N2][N1][N0]; + +task void x(const float f) { + uniform int j; + + assert(taskCount == N0*N1*N2); + assert(taskCount0 == N0); + assert(taskCount1 == N1); + assert(taskCount2 == N2); + assert(taskIndex == taskIndex0 + N0*(taskIndex1 + N1*taskIndex2)); + assert(taskIndex0 < N0); + assert(taskIndex1 < N1); + assert(taskIndex2 < N2); + + const uniform int i0 = taskIndex0; + const uniform int i1 = taskIndex1; + const uniform int i2 = taskIndex2; + const uniform int i = taskIndex; + array[i2][i1][i0] = i / 10000.; + cfor (j = 0; j < 10000; ++j) + array[i2][i1][i0] = sin(array[i2][i1][i0]); + if (array[i2][i1][i0] < .02) + array[i2][i1][i0] = i; +} +export void f_f(uniform float RET[], uniform float fFOO[]) { + float f = fFOO[programIndex]; + launch[N2][N1][N0] x(f); + sync; + RET[programIndex] = array[N2-1][N1-1][N0-1]; +} + + +export void result(uniform float RET[]) { + RET[programIndex] = 9999.000000; +} diff --git a/tests/launch-9.ispc b/tests/launch-9.ispc new file mode 100644 index 00000000..761b070c --- /dev/null +++ b/tests/launch-9.ispc @@ -0,0 +1,42 @@ + +export uniform int width() { return programCount; } + + +#define N0 10 +#define N1 20 +#define N2 50 +static uniform float array[N2][N1][N0]; + +task void x(const float f) { + uniform int j; + + assert(taskCount == N0*N1*N2); + assert(taskCount0 == N0); + assert(taskCount1 == N1); + assert(taskCount2 == N2); + assert(taskIndex == taskIndex0 + N0*(taskIndex1 + N1*taskIndex2)); + assert(taskIndex0 < N0); + assert(taskIndex1 < N1); + assert(taskIndex2 < N2); + + const uniform int i0 = taskIndex0; + const uniform int i1 = taskIndex1; + const uniform int i2 = taskIndex2; + const uniform int i = taskIndex; + array[i2][i1][i0] = i / 10000.; + cfor (j = 0; j < 10000; ++j) + array[i2][i1][i0] = sin(array[i2][i1][i0]); + if (array[i2][i1][i0] < .02) + array[i2][i1][i0] = i; +} +export void f_f(uniform float RET[], uniform float fFOO[]) { + float f = fFOO[programIndex]; + launch[N0,N1,N2] x(f); + sync; + RET[programIndex] = array[N2-1][N1-1][N0-1]; +} + + +export void result(uniform float RET[]) { + RET[programIndex] = 9999.000000; +}