kernel2d.rs revision b93407a91a1e41dd46df83a7f8c538cfd2d9a0a8
1#include "shared.rsh"
2
3rs_allocation A;
4rs_allocation B;
5uint32_t gDimX, gDimY;
6static bool failed = false;
7
8void init_vars(int *out) {
9    *out = 7;
10}
11
12int RS_KERNEL root(int ain, rs_kernel_context context, uint32_t x, uint32_t y) {
13    if (!_RS_ASSERT_EQU(ain, 7))
14        rsDebug("root at x, y", x, y);
15    uint32_t dimX = rsGetDimX(context);
16    uint32_t dimY = rsGetDimY(context);
17    _RS_ASSERT_EQU(dimX, gDimX);
18    _RS_ASSERT_EQU(dimY, gDimY);
19    return ain + x + dimX * y;
20}
21
22static bool test_root_output() {
23    bool failed = false;
24    int i, j;
25
26    for (i = 0; i < gDimX; i++) {
27        for (j = 0; j < gDimY; j++) {
28            int bElt = rsGetElementAt_int(B, i, j);
29            int aElt = rsGetElementAt_int(A, i, j);
30            if (!_RS_ASSERT_EQU(bElt, (aElt + i + gDimX * j)))
31                rsDebug("test_root_output at i, j", i, j);
32        }
33    }
34
35    if (failed) {
36        rsDebug("kernel2d test_root_output FAILED", 0);
37    }
38    else {
39        rsDebug("kernel2d test_root_output PASSED", 0);
40    }
41
42    return failed;
43}
44
45void verify_root() {
46    failed |= test_root_output();
47}
48
49void kernel_test() {
50    if (failed) {
51        rsSendToClientBlocking(RS_MSG_TEST_FAILED);
52    }
53    else {
54        rsSendToClientBlocking(RS_MSG_TEST_PASSED);
55    }
56}
57