diff options
author | Tom Gall <tom.gall@linaro.org> | 2014-04-08 21:48:45 +0000 |
---|---|---|
committer | Tom Gall <tom.gall@linaro.org> | 2014-04-08 21:48:45 +0000 |
commit | 82810204213bc5734ecb4befbdad47484965228d (patch) | |
tree | 0ccf24b4ee0296b27c40a3d649a528290c9a6205 | |
parent | 53a45813e8c4e4918c160c14f0373e07166afd2b (diff) |
Initial roughed in versions of a hand coded renderscript kernelrenderscript
and driver program.
sql1.rs : solve the sql1 test
sq-rs.cpp : driver program that will mirror sq-cl.c
-rw-r--r-- | handcoded-renderscript/sql1.rs | 10 | ||||
-rw-r--r-- | sq-rs.cpp | 49 |
2 files changed, 59 insertions, 0 deletions
diff --git a/handcoded-renderscript/sql1.rs b/handcoded-renderscript/sql1.rs new file mode 100644 index 0000000..74d7794 --- /dev/null +++ b/handcoded-renderscript/sql1.rs @@ -0,0 +1,10 @@ +#pragma version(1) +#pragma rs java_package_name(com.linaro.sq-cl) + +int4 __attribute__((kernel)) x2_root(int4 data1, + int4 data2) { + + int 4 result = ((data1 > 60) && (v2 < 0 )); + + return result; +} diff --git a/sq-rs.cpp b/sq-rs.cpp new file mode 100644 index 0000000..68cd26e --- /dev/null +++ b/sq-rs.cpp @@ -0,0 +1,49 @@ +#include "RenderScript.h" +#include "ScriptC_sql1.h" + +using namespace android; +using namespace RSC; + +int main(int argc, char **argv) { + + sp<RS> rs = new RS(); + + bool status = rs->init(); + + sp<const Element> dataElement1 = Element::I32_4(rs); + sp<const Element> dataElement2 = Element::I32_4(rs); + + Type::Builder tb(ts, dataElement1); + tb.setX(100000/4); + sp<const Type> t = tb.create(); + + sp<Allocation> data1 = Allocation::createSized(rs, dataElement1, 100000/4); + sp<Allocation> data2 = Allocation::createSized(rs, dataElement2, 100000/4); + + sp<Allocation> data1in = Allocation::createTyped(rs, t); + sp<Allocation> data2in = Allocation::createTyped(rs, t); + + /* this seems sub-optimal ?? */ + ScriptC_sql1 *sc = new ScriptC_sql1(rs); + + /* make up some data */ + int *buf = new int[t->getCount()]; + for (int ct=0; ct < t->getCount(); ct++) { + buf[ct] = 90; + } + /* copy from column */ + data1in->copy1DRangeFrom(0, t->getCount(), buf); + + for (int ct=0; ct < t->getCount(); ct++) { + buf[ct] = -7; + } + data2in->copy1DRangeFrom(0, t->getCount(), buf); + + sc->forEach_x2_root(data1in, data2in, maskOut); + + rs->finish(); + + delete sc; + + return 0; +} |