1 #include "shared.rsh" 2 3 struct simpleStruct { 4 int i1; 5 char ignored1; 6 float f1; 7 int i2; 8 char ignored2; 9 float f2; 10 }; 11 12 struct simpleStruct *ain; 13 struct simpleStruct *aout; 14 int dimX; 15 static bool failed = false; 16 17 void init_vars(struct simpleStruct *out, uint32_t x) { 18 out->i1 = 0; 19 out->f1 = 0.f; 20 out->i2 = 1; 21 out->f2 = 1.0f; 22 } 23 24 struct simpleStruct RS_KERNEL 25 root(struct simpleStruct in, uint32_t x) { 26 struct simpleStruct s; 27 s.i1 = in.i1 + x; 28 s.f1 = in.f1 + x; 29 s.i2 = in.i2 + x; 30 s.f2 = in.f2 + x; 31 return s; 32 } 33 34 static bool test_root_output() { 35 bool failed = false; 36 int i; 37 38 for (i = 0; i < dimX; i++) { 39 _RS_ASSERT(aout[i].i1 == (i + ain[i].i1)); 40 _RS_ASSERT(aout[i].f1 == (i + ain[i].f1)); 41 _RS_ASSERT(aout[i].i2 == (i + ain[i].i2)); 42 _RS_ASSERT(aout[i].f2 == (i + ain[i].f2)); 43 } 44 45 if (failed) { 46 rsDebug("test_root_output FAILED", 0); 47 } 48 else { 49 rsDebug("test_root_output PASSED", 0); 50 } 51 52 return failed; 53 } 54 55 void verify_root() { 56 failed |= test_root_output(); 57 } 58 59 void kernel_struct_test() { 60 if (failed) { 61 rsSendToClientBlocking(RS_MSG_TEST_FAILED); 62 } 63 else { 64 rsSendToClientBlocking(RS_MSG_TEST_PASSED); 65 } 66 } 67