diff options
| author | Pirama Arumuga Nainar <pirama@google.com> | 2015-12-02 11:40:54 -0800 |
|---|---|---|
| committer | Pirama Arumuga Nainar <pirama@google.com> | 2016-02-18 11:36:39 -0800 |
| commit | 1f6041ddc7658e252797626faae38db759413edc (patch) | |
| tree | 4a951e9ca3542a89b8c7c600fdfa2af465245e94 /tests/cppf16/compute.cpp | |
| parent | 291330fbaf7486a1cea33de7dd26c18e57c71391 (diff) | |
Add float16 elements to C++ API
Bug: 25972767
Add float16 elements to C++ API and test the ability to create float16
allocations.
Caveats:
- Element::F16 and such are accessible to the host-side code
irrespective of the target API level. This is because right now,
target API level seems to be set at runtime instead of compile time.
- We added float16 to RenderScript starting API level 23. Since we
cannot compile RS CPP apps targeting this level, Scripts cannot
manipulate float16 data yet.
Change-Id: I2bfba13fcad1c3aa984e97b44765fd2a57a054ac
(cherry picked from commit 566168431399086c146b2f845f6d0128852c9686)
Diffstat (limited to 'tests/cppf16/compute.cpp')
| -rw-r--r-- | tests/cppf16/compute.cpp | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/tests/cppf16/compute.cpp b/tests/cppf16/compute.cpp new file mode 100644 index 00000000..d39466d8 --- /dev/null +++ b/tests/cppf16/compute.cpp @@ -0,0 +1,41 @@ +#include "RenderScript.h" + +using namespace android; +using namespace RSC; + +static const uint32_t dimX = 7, dimY = 5, dimZ = 3; + +void testAllocationCreation(sp<RS> rs, sp<const Element> e, uint32_t nDims) { + Type::Builder tb(rs, e); + tb.setX(dimX); + if (nDims >= 2) + tb.setY(dimY); + if (nDims >= 3) + tb.setZ(dimZ); + + sp<const Type> t = tb.create(); + sp<Allocation> alloc = Allocation::createTyped(rs, t); +} + +int main(int , char** ) +{ + sp<RS> rs = new RS(); + + bool r = rs->init("/system/bin"); + + // Test ability to create 1D, 2D and 3D allocations of f16 scalars and + // vectors + sp<const Element> half = Element::F16(rs); + sp<const Element> half2 = Element::F16_2(rs); + sp<const Element> half3 = Element::F16_3(rs); + sp<const Element> half4 = Element::F16_4(rs); + + for (uint32_t nDims = 1; nDims <= 3; nDims ++) { + testAllocationCreation(rs, half, nDims); + testAllocationCreation(rs, half2, nDims); + testAllocationCreation(rs, half3, nDims); + testAllocationCreation(rs, half4, nDims); + } + + printf("Test successful!"); +} |
