jniallocations.cpp revision 5bbcc3861c44435f89481f80946ef5c9c49968f2
15bbcc3861c44435f89481f80946ef5c9c49968f2Luke Drummond/* 25bbcc3861c44435f89481f80946ef5c9c49968f2Luke Drummond* Copyright (C) 2016 The Android Open Source Project 35bbcc3861c44435f89481f80946ef5c9c49968f2Luke Drummond* 45bbcc3861c44435f89481f80946ef5c9c49968f2Luke Drummond* Licensed under the Apache License, Version 2.0 (the "License"); 55bbcc3861c44435f89481f80946ef5c9c49968f2Luke Drummond* you may not use this file except in compliance with the License. 65bbcc3861c44435f89481f80946ef5c9c49968f2Luke Drummond* You may obtain a copy of the License at 75bbcc3861c44435f89481f80946ef5c9c49968f2Luke Drummond* 85bbcc3861c44435f89481f80946ef5c9c49968f2Luke Drummond* http://www.apache.org/licenses/LICENSE-2.0 95bbcc3861c44435f89481f80946ef5c9c49968f2Luke Drummond* 105bbcc3861c44435f89481f80946ef5c9c49968f2Luke Drummond* Unless required by applicable law or agreed to in writing, software 115bbcc3861c44435f89481f80946ef5c9c49968f2Luke Drummond* distributed under the License is distributed on an "AS IS" BASIS, 125bbcc3861c44435f89481f80946ef5c9c49968f2Luke Drummond* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 135bbcc3861c44435f89481f80946ef5c9c49968f2Luke Drummond* See the License for the specific language governing permissions and 145bbcc3861c44435f89481f80946ef5c9c49968f2Luke Drummond* limitations under the License. 155bbcc3861c44435f89481f80946ef5c9c49968f2Luke Drummond*/ 165bbcc3861c44435f89481f80946ef5c9c49968f2Luke Drummond 17dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo#include <memory> 18dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo 19dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo#include <jni.h> 20dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo#include <RenderScript.h> 21dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo 22dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo#include "ScriptC_allocs.h" 23dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo 24dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leousing namespace android; 25dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leousing namespace RSC; 26dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo 27dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leosp<RS> mRS; 28dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo 29dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leosp<Allocation> mBoolAllocation; // boolean 30dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo 31dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leosp<Allocation> mCharAllocation; // char 32dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leosp<Allocation> mChar2Allocation; // char2 33dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leosp<Allocation> mChar3Allocation; // char3 34dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leosp<Allocation> mChar4Allocation; // char4 35dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo 36dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leosp<Allocation> mUCharAllocation; // uchar 37dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leosp<Allocation> mUChar2Allocation; // uchar2 38dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leosp<Allocation> mUChar3Allocation; // uchar3 39dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leosp<Allocation> mUChar4Allocation; // uchar4 40dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo 41dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leosp<Allocation> mShortAllocation; // short 42dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leosp<Allocation> mShort2Allocation; // short2 43dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leosp<Allocation> mShort3Allocation; // short3 44dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leosp<Allocation> mShort4Allocation; // short4 45dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo 46dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leosp<Allocation> mUShortAllocation; // ushort 47dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leosp<Allocation> mUShort2Allocation; // ushort2 48dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leosp<Allocation> mUShort3Allocation; // ushort3 49dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leosp<Allocation> mUShort4Allocation; // ushort4 50dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo 51dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leosp<Allocation> mIntAllocation; // int 52dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leosp<Allocation> mInt2Allocation; // int2 53dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leosp<Allocation> mInt3Allocation; // int3 54dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leosp<Allocation> mInt4Allocation; // int4 55dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo 56dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leosp<Allocation> mUIntAllocation; // uint 57dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leosp<Allocation> mUInt2Allocation; // uint2 58dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leosp<Allocation> mUInt3Allocation; // uint3 59dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leosp<Allocation> mUInt4Allocation; // uint4 60dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo 61dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leosp<Allocation> mLongAllocation; // long 62dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leosp<Allocation> mLong2Allocation; // long2 63dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leosp<Allocation> mLong3Allocation; // long3 64dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leosp<Allocation> mLong4Allocation; // long4 65dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo 66dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leosp<Allocation> mULongAllocation; // ulong 67dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leosp<Allocation> mULong2Allocation; // ulong2 68dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leosp<Allocation> mULong3Allocation; // ulong3 69dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leosp<Allocation> mULong4Allocation; // ulong4 70dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo 71dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leosp<Allocation> mHalfAllocation; // half 72dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leosp<Allocation> mHalf2Allocation; // half2 73dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leosp<Allocation> mHalf3Allocation; // half3 74dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leosp<Allocation> mHalf4Allocation; // half4 75dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo 76dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leosp<Allocation> mFloatAllocation; // float 77dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leosp<Allocation> mFloat2Allocation; // float2 78dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leosp<Allocation> mFloat3Allocation; // float3 79dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leosp<Allocation> mFloat4Allocation; // float4 80dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo 81dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leosp<Allocation> mDoubleAllocation; // double 82dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leosp<Allocation> mDouble2Allocation; // double2 83dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leosp<Allocation> mDouble3Allocation; // double3 84dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leosp<Allocation> mDouble4Allocation; // double4 85dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo 86dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leoconst int mAllocSize = 24; // Needs to be < CHAR_MAX and divisible by 4. 87dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leoconst int mBitmapSize = 64; 88dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo 89dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leovoid createSignedAllocations() { 90dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo Type::Builder typeI8Builder(mRS, Element::I8(mRS)); 91dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo typeI8Builder.setX(1); // One element here to test 16 byte memory alignment 92dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo typeI8Builder.setY(3); 93dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo typeI8Builder.setZ(8); 94dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo 95dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo mCharAllocation = Allocation::createTyped(mRS, typeI8Builder.create()); 96dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo mChar2Allocation = Allocation::createSized(mRS, Element::I8_2(mRS), mAllocSize / 2); 97dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo mChar3Allocation = Allocation::createSized(mRS, Element::I8_3(mRS), mAllocSize / 4); 98dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo mChar4Allocation = Allocation::createSized(mRS, Element::I8_4(mRS), mAllocSize / 4); 99dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo 100dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo Type::Builder typeI16_2Builder(mRS, Element::I16_2(mRS)); 101dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo typeI16_2Builder.setX(6); 102dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo typeI16_2Builder.setY(1); 103dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo typeI16_2Builder.setZ(2); 104dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo 105dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo mShortAllocation = Allocation::createSized(mRS, Element::I16(mRS), mAllocSize); 106dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo mShort2Allocation = Allocation::createTyped(mRS, typeI16_2Builder.create()); 107dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo mShort3Allocation = Allocation::createSized(mRS, Element::I16_3(mRS), mAllocSize / 4); 108dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo mShort4Allocation = Allocation::createSized(mRS, Element::I16_4(mRS), mAllocSize / 4); 109dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo 110dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo Type::Builder typeI32_3Builder(mRS, Element::I32_3(mRS)); 111dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo typeI32_3Builder.setX(3); 112dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo typeI32_3Builder.setY(2); 113dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo 114dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo mIntAllocation = Allocation::createSized(mRS, Element::I32(mRS), mAllocSize); 115dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo mInt2Allocation = Allocation::createSized(mRS, Element::I32_2(mRS), mAllocSize / 2); 116dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo mInt3Allocation = Allocation::createTyped(mRS, typeI32_3Builder.create()); 117dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo mInt4Allocation = Allocation::createSized(mRS, Element::I32_4(mRS), mAllocSize / 4); 118dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo 119dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo Type::Builder typeI64_4Builder(mRS, Element::I64_4(mRS)); 120dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo typeI64_4Builder.setX(1); 121dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo typeI64_4Builder.setY(6); 122dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo 123dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo mLongAllocation = Allocation::createSized(mRS, Element::I64(mRS), mAllocSize); 124dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo mLong2Allocation = Allocation::createSized(mRS, Element::I64_2(mRS), mAllocSize / 2); 125dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo mLong3Allocation = Allocation::createSized(mRS, Element::I64_3(mRS), mAllocSize / 4); 126dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo mLong4Allocation = Allocation::createTyped(mRS, typeI64_4Builder.create()); 127dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo 128dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo mBoolAllocation = Allocation::createSized(mRS, Element::BOOLEAN(mRS), mAllocSize); 129dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo} 130dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo 131dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leovoid initSignedAllocations() { 132dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo char *buffer_char = new char[mAllocSize]; 133dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo short *buffer_short = new short[mAllocSize]; 134dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo int *buffer_int = new int[mAllocSize]; 135dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo int64_t *buffer_long = new int64_t[mAllocSize]; 136dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo char *buffer_bool = new char[mAllocSize]; 137dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo 138dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo for(int i = 0; i < mAllocSize; ++i) { 139dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo buffer_char[i] = (char) i; 140dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo buffer_short[i] = (short) i; 141dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo buffer_int[i] = (int) i; 142dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo buffer_long[i] = (int64_t) i; 143dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo buffer_bool[i] = (char) (0x01 & i); 144dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo } 145dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo 146dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo mCharAllocation->copy3DRangeFrom(0, 0, 0, 1, 3, 8, buffer_char); 147dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo mChar2Allocation->copy1DRangeFrom(0, mAllocSize/2, buffer_char); 148dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo mChar3Allocation->copy1DRangeFrom(0, mAllocSize/4, buffer_char); 149dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo mChar4Allocation->copy1DRangeFrom(0, mAllocSize/4, buffer_char); 150dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo 151dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo delete [] buffer_char; 152dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo 153dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo mShortAllocation->copy1DRangeFrom(0, mAllocSize, buffer_short); 154dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo mShort2Allocation->copy3DRangeFrom(0, 0, 0, 6, 1, 2, buffer_short); 155dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo mShort3Allocation->copy1DRangeFrom(0, mAllocSize/4, buffer_short); 156dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo mShort4Allocation->copy1DRangeFrom(0, mAllocSize/4, buffer_short); 157dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo 158dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo delete [] buffer_short; 159dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo 160dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo mIntAllocation->copy1DRangeFrom(0, mAllocSize, buffer_int); 161dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo mInt2Allocation->copy1DRangeFrom(0, mAllocSize/2, buffer_int); 162dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo mInt3Allocation->copy2DRangeFrom(0, 0, 3, 2, buffer_int); 163dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo mInt4Allocation->copy1DRangeFrom(0, mAllocSize/4, buffer_int); 164dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo 165dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo delete [] buffer_int; 166dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo 167dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo mLongAllocation->copy1DRangeFrom(0, mAllocSize, buffer_long); 168dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo mLong2Allocation->copy1DRangeFrom(0, mAllocSize/2, buffer_long); 169dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo mLong3Allocation->copy1DRangeFrom(0, mAllocSize/4, buffer_long); 170dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo mLong4Allocation->copy2DRangeFrom(0, 0, 1, 6, buffer_long); 171dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo 172dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo delete [] buffer_long; 173dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo 174dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo mBoolAllocation->copy1DRangeFrom(0, mAllocSize, buffer_bool); 175dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo 176dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo delete [] buffer_bool; 177dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo} 178dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo 179dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leovoid createUnsignedAllocations() { 180dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo Type::Builder typeU8_2Builder(mRS, Element::U8_2(mRS)); 181dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo typeU8_2Builder.setX(2); 182dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo typeU8_2Builder.setY(6); 183dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo 184dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo mUCharAllocation = Allocation::createSized(mRS, Element::U8(mRS), mAllocSize); 185dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo mUChar2Allocation = Allocation::createTyped(mRS, typeU8_2Builder.create()); 186dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo mUChar3Allocation = Allocation::createSized(mRS, Element::U8_3(mRS), mAllocSize / 4); 187dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo mUChar4Allocation = Allocation::createSized(mRS, Element::U8_4(mRS), mAllocSize / 4); 188dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo 189dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo Type::Builder typeU16_3Builder(mRS, Element::U16_3(mRS)); 190dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo typeU16_3Builder.setX(1); 191dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo typeU16_3Builder.setY(6); 192dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo 193dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo mUShortAllocation = Allocation::createSized(mRS, Element::U16(mRS), mAllocSize); 194dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo mUShort2Allocation = Allocation::createSized(mRS, Element::U16_2(mRS), mAllocSize / 2); 195dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo mUShort3Allocation = Allocation::createTyped(mRS, typeU16_3Builder.create()); 196dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo mUShort4Allocation = Allocation::createSized(mRS, Element::U16_4(mRS), mAllocSize / 4); 197dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo 198dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo Type::Builder typeU32_4Builder(mRS, Element::U32_4(mRS)); 199dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo typeU32_4Builder.setX(1); 200dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo typeU32_4Builder.setY(1); 201dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo typeU32_4Builder.setZ(6); 202dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo 203dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo mUIntAllocation = Allocation::createSized(mRS, Element::U32(mRS), mAllocSize); 204dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo mUInt2Allocation = Allocation::createSized(mRS, Element::U32_2(mRS), mAllocSize / 2); 205dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo mUInt3Allocation = Allocation::createSized(mRS, Element::U32_3(mRS), mAllocSize / 4); 206dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo mUInt4Allocation = Allocation::createTyped(mRS, typeU32_4Builder.create()); 207dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo 208dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo Type::Builder typeU64Builder(mRS, Element::U64(mRS)); 209dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo typeU64Builder.setX(4); 210dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo typeU64Builder.setY(3); 211dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo typeU64Builder.setZ(2); 212dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo 213dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo mULongAllocation = Allocation::createTyped(mRS, typeU64Builder.create()); 214dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo mULong2Allocation = Allocation::createSized(mRS, Element::U64_2(mRS), mAllocSize / 2); 215dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo mULong3Allocation = Allocation::createSized(mRS, Element::U64_3(mRS), mAllocSize / 4); 216dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo mULong4Allocation = Allocation::createSized(mRS, Element::U64_4(mRS), mAllocSize / 4); 217dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo} 218dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo 219dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leovoid initUnsignedAllocations() { 220dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo char *buffer_char = new char[mAllocSize]; 221dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo short *buffer_short = new short[mAllocSize]; 222dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo int *buffer_int = new int[mAllocSize]; 223dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo uint64_t *buffer_long = new uint64_t[mAllocSize]; 224dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo 225dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo for(int i = 0; i < mAllocSize; ++i) { 226dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo buffer_char[i] = (char) i; 227dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo buffer_short[i] = (short) i; 228dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo buffer_int[i] = (int) i; 229dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo buffer_long[i] = (uint64_t) i; 230dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo } 231dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo 232dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo mUCharAllocation->copy1DRangeFrom(0, mAllocSize, buffer_char); 233dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo mUChar2Allocation->copy2DRangeFrom(0, 0, 2, 6, buffer_char); 234dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo mUChar3Allocation->copy1DRangeFrom(0, mAllocSize/4, buffer_char); 235dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo mUChar4Allocation->copy1DRangeFrom(0, mAllocSize/4, buffer_char); 236dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo 237dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo delete [] buffer_char; 238dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo 239dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo mUShortAllocation->copy1DRangeFrom(0, mAllocSize, buffer_short); 240dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo mUShort2Allocation->copy1DRangeFrom(0, mAllocSize/2, buffer_short); 241dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo mUShort3Allocation->copy2DRangeFrom(0, 0, 1, 6, buffer_short); 242dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo mUShort4Allocation->copy1DRangeFrom(0, mAllocSize/4, buffer_short); 243dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo 244dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo delete [] buffer_short; 245dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo 246dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo mUIntAllocation->copy1DRangeFrom(0, mAllocSize, buffer_int); 247dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo mUInt2Allocation->copy1DRangeFrom(0, mAllocSize/2, buffer_int); 248dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo mUInt3Allocation->copy1DRangeFrom(0, mAllocSize/4, buffer_int); 249dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo mUInt4Allocation->copy3DRangeFrom(0, 0, 0, 1, 1, 6, buffer_int); 250dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo 251dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo delete [] buffer_int; 252dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo 253dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo mULongAllocation->copy3DRangeFrom(0, 0, 0, 4, 3, 2, buffer_long); 254dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo mULong2Allocation->copy1DRangeFrom(0, mAllocSize/2, buffer_long); 255dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo mULong3Allocation->copy1DRangeFrom(0, mAllocSize/4, buffer_long); 256dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo mULong4Allocation->copy1DRangeFrom(0, mAllocSize/4, buffer_long); 257dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo 258dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo delete [] buffer_long; 259dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo} 260dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo 261dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leovoid createFloatAllocations() { 262dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo Type::Builder typeF16_3Builder(mRS, Element::F16_3(mRS)); 263dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo typeF16_3Builder.setX(1); 264dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo typeF16_3Builder.setY(6); 265dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo 266dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo mHalfAllocation = Allocation::createSized(mRS, Element::F16(mRS), mAllocSize); 267dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo mHalf2Allocation = Allocation::createSized(mRS, Element::F16_2(mRS), mAllocSize / 2); 268dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo mHalf3Allocation = Allocation::createTyped(mRS, typeF16_3Builder.create()); 269dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo mHalf4Allocation = Allocation::createSized(mRS, Element::F16_4(mRS), mAllocSize / 4); 270dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo 271dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo Type::Builder typeF32_4Builder(mRS, Element::F32_4(mRS)); 272dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo typeF32_4Builder.setX(3); 273dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo typeF32_4Builder.setY(2); 274dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo 275dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo mFloatAllocation = Allocation::createSized(mRS, Element::F32(mRS), mAllocSize); 276dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo mFloat2Allocation = Allocation::createSized(mRS, Element::F32_2(mRS), mAllocSize / 2); 277dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo mFloat3Allocation = Allocation::createSized(mRS, Element::F32_3(mRS), mAllocSize / 4); 278dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo mFloat4Allocation = Allocation::createTyped(mRS, typeF32_4Builder.create()); 279dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo 280dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo Type::Builder typeF64_2Builder(mRS, Element::F64_2(mRS)); 281dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo typeF64_2Builder.setX(4); 282dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo typeF64_2Builder.setY(1); 283dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo typeF64_2Builder.setZ(3); 284dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo 285dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo mDoubleAllocation = Allocation::createSized(mRS, Element::F64(mRS), mAllocSize); 286dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo mDouble2Allocation = Allocation::createTyped(mRS, typeF64_2Builder.create()); 287dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo 288dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo Type::Builder typeF64_3Builder(mRS, Element::F64_3(mRS)); 289dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo typeF64_3Builder.setX(1); 290dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo typeF64_3Builder.setY(2); 291dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo typeF64_3Builder.setZ(3); 292dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo 293dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo Type::Builder typeF64_4Builder(mRS, Element::F64_4(mRS)); 294dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo typeF64_4Builder.setX(1); 295dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo typeF64_4Builder.setY(2); 296dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo typeF64_4Builder.setZ(3); 297dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo 298dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo mDouble3Allocation = Allocation::createTyped(mRS, typeF64_3Builder.create()); 299dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo mDouble4Allocation = Allocation::createTyped(mRS, typeF64_4Builder.create()); 300dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo} 301dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo 302dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leovoid initFloatAllocations() { 303dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo __fp16 *buffer_half = new __fp16[mAllocSize]; 304dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo float *buffer_float = new float[mAllocSize]; 305dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo double *buffer_double = new double[mAllocSize]; 306dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo 307dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo for(int i = 0; i < mAllocSize; ++i) { 308dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo buffer_half[i] = (__fp16) 1 / i; 309dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo buffer_float[i] = (float) 1 / i; 310dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo buffer_double[i] = (double) 1 / i; 311dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo } 312dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo 313dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo mHalfAllocation->copy1DRangeFrom(0, mAllocSize, buffer_half); 314dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo mHalf2Allocation->copy1DRangeFrom(0, mAllocSize/2, buffer_half); 315dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo mHalf3Allocation->copy2DRangeFrom(0, 0, 1, 6, buffer_half); 316dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo mHalf4Allocation->copy1DRangeFrom(0, mAllocSize/4, buffer_half); 317dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo 318dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo delete [] buffer_half; 319dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo 320dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo mFloatAllocation->copy1DRangeFrom(0, mAllocSize, buffer_float); 321dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo mFloat2Allocation->copy1DRangeFrom(0, mAllocSize/2, buffer_float); 322dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo mFloat3Allocation->copy1DRangeFrom(0, mAllocSize/4, buffer_float); 323dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo mFloat4Allocation->copy2DRangeFrom(0, 0, 3, 2, buffer_float); 324dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo 325dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo delete [] buffer_float; 326dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo 327dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo mDoubleAllocation->copy1DRangeFrom(0, mAllocSize, buffer_double); 328dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo mDouble2Allocation->copy3DRangeFrom(0, 0, 0, 4, 1, 3, buffer_double); 329dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo mDouble3Allocation->copy3DRangeFrom(0, 0, 0, 1, 2, 3, buffer_double); 330dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo mDouble4Allocation->copy3DRangeFrom(0, 0, 0, 1, 2, 3, buffer_double); 331dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo 332dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo delete [] buffer_double; 333dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo} 334dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo 335dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leoextern "C" void JNICALL 336dcecc0c8d22e894525e25a122ce25129b51338f2Dean De LeoJava_com_android_rs_jniallocations_MainActivity_nativeRS( 337dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo JNIEnv * env, 338dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo jclass, 339dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo jstring pathObj) 340dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo{ 341dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo mRS = new RS(); 342dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo 343dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo const char * path = env->GetStringUTFChars(pathObj, nullptr); 344dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo mRS->init(path, RS_INIT_LOW_LATENCY | RS_INIT_WAIT_FOR_ATTACH); 345dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo env->ReleaseStringUTFChars(pathObj, path); 346dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo 347dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo sp<ScriptC_allocs> mScript = new ScriptC_allocs(mRS); 348dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo 349dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo Type::Builder typeRGBA_888Builder(mRS, Element::RGBA_8888(mRS)); 350dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo typeRGBA_888Builder.setX(mBitmapSize); 351dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo typeRGBA_888Builder.setY(mBitmapSize); 352dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo 353dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo sp<Allocation> mInAllocation = Allocation::createTyped(mRS, typeRGBA_888Builder.create()); 354dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo 355dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo const int image_area = mBitmapSize*mBitmapSize; 356dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo const int image_size = image_area*sizeof(int); 357dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo 358dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo char *zero_buffer = new char[image_size]; 359dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo memset(zero_buffer, 0, image_size); 360dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo mInAllocation->copy1DRangeFrom(0, image_area, zero_buffer); 361dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo delete [] zero_buffer; 362dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo 363dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo sp<Allocation> mOutAllocation = Allocation::createTyped(mRS, typeRGBA_888Builder.create()); 364dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo createSignedAllocations(); 365dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo initSignedAllocations(); 366dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo 367dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo mRS->finish(); 368dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo mScript->forEach_swizzle_kernel(mInAllocation, mOutAllocation); 369dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo mRS->finish(); 370dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo 371dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo mCharAllocation.clear(); 372dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo mChar2Allocation.clear(); 373dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo mChar3Allocation.clear(); 374dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo mChar4Allocation.clear(); 375dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo 376dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo mShort2Allocation.clear(); 377dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo mShort3Allocation.clear(); 378dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo mShort4Allocation.clear(); 379dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo 380dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo mIntAllocation.clear(); 381dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo mInt2Allocation.clear(); 382dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo mInt3Allocation.clear(); 383dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo mInt4Allocation.clear(); 384dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo 385dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo mLongAllocation.clear(); 386dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo mLong2Allocation.clear(); 387dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo mLong3Allocation.clear(); 388dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo mLong4Allocation.clear(); 389dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo 390dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo mBoolAllocation.clear(); 391dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo 392dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo createUnsignedAllocations(); 393dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo initUnsignedAllocations(); 394dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo 395dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo mInAllocation = mUShortAllocation; // Host side assignment 396dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo 397dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo mRS->finish(); 398dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo mScript->forEach_square_kernel(mInAllocation, mUIntAllocation); 399dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo mRS->finish(); 400dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo 401dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo mUCharAllocation.clear(); 402dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo mUChar2Allocation.clear(); 403dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo mUChar3Allocation.clear(); 404dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo mUChar4Allocation.clear(); 405dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo 406dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo mUShortAllocation.clear(); 407dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo mUShort2Allocation.clear(); 408dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo mUShort3Allocation.clear(); 409dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo mUShort4Allocation.clear(); 410dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo 411dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo mUInt2Allocation.clear(); 412dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo mUInt3Allocation.clear(); 413dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo mUInt4Allocation.clear(); 414dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo 415dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo mULongAllocation.clear(); 416dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo mULong2Allocation.clear(); 417dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo mULong3Allocation.clear(); 418dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo mULong4Allocation.clear(); 419dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo 420dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo createFloatAllocations(); 421dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo initFloatAllocations(); 422dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo 423dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo mRS->finish(); 424dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo mScript->forEach_add_half_kernel(mDouble4Allocation, mDouble3Allocation); 425dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo mRS->finish(); 426dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo} 427dcecc0c8d22e894525e25a122ce25129b51338f2Dean De Leo 428