15c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang/* 25c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang * Copyright (C) 2015 The Android Open Source Project 35c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang * 45c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang * Licensed under the Apache License, Version 2.0 (the "License"); 55c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang * you may not use this file except in compliance with the License. 65c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang * You may obtain a copy of the License at 75c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang * 85c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang * http://www.apache.org/licenses/LICENSE-2.0 95c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang * 105c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang * Unless required by applicable law or agreed to in writing, software 115c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang * distributed under the License is distributed on an "AS IS" BASIS, 125c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 135c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang * See the License for the specific language governing permissions and 145c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang * limitations under the License. 155c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang */ 165c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang 175c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wangpackage com.android.rs.test_compat; 185c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang 195c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wangimport android.content.Context; 205c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wangimport android.content.res.Resources; 215c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wangimport android.support.v8.renderscript.*; 225c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wangimport java.util.Random; 235c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang 245c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wangpublic class UT_alloc_copy extends UnitTest { 255c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang private Resources mRes; 265c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang 275c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang protected UT_alloc_copy(RSTestCore rstc, Resources res, Context ctx) { 285c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang super(rstc, "Allocation CopyTo", ctx); 295c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang mRes = res; 305c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang } 315c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang 325c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang public void run() { 335c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang RenderScript mRS = RenderScript.create(mCtx); 345c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang 355c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang allocation_copy1DRangeTo_Byte(mRS); 365c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang allocation_copy1DRangeTo_Short(mRS); 375c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang allocation_copy1DRangeTo_Int(mRS); 385c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang allocation_copy1DRangeTo_Float(mRS); 395c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang allocation_copy1DRangeTo_Long(mRS); 405c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang 415c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang allocation_copy2DRangeTo_Byte(mRS); 425c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang allocation_copy2DRangeTo_Short(mRS); 435c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang allocation_copy2DRangeTo_Int(mRS); 445c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang allocation_copy2DRangeTo_Float(mRS); 455c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang allocation_copy2DRangeTo_Long(mRS); 465c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang 475c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang allocation_copy1DRangeToUnchecked_Byte(mRS); 485c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang allocation_copy1DRangeToUnchecked_Short(mRS); 495c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang allocation_copy1DRangeToUnchecked_Int(mRS); 505c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang allocation_copy1DRangeToUnchecked_Float(mRS); 515c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang allocation_copy1DRangeToUnchecked_Long(mRS); 525c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang 535c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang mRS.destroy(); 545c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang passTest(); 555c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang } 565c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang 575c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang public void allocation_copy1DRangeTo_Byte(RenderScript mRS) { 585c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang Random random = new Random(0x172d8ab9); 595c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang int width = random.nextInt(512); 605c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang int arr_len = width; 615c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang 625c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang byte[] inArray = new byte[arr_len]; 635c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang byte[] outArray = new byte[arr_len]; 645c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang random.nextBytes(inArray); 655c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang 665c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang Type.Builder typeBuilder = new Type.Builder(mRS, Element.I8(mRS)); 675c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang typeBuilder.setX(width); 685c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang Allocation alloc = Allocation.createTyped(mRS, typeBuilder.create()); 695c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang int offset = random.nextInt(arr_len); 705c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang int count = arr_len - offset; 715c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang alloc.copy1DRangeFrom(offset, count, inArray); 725c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang alloc.copy1DRangeTo(offset, count, outArray); 735c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang 745c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang boolean result = true; 755c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang for (int i = 0; i < count; i++) { 765c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang if (inArray[i] != outArray[i]) { 775c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang result = false; 785c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang android.util.Log.v("Allocation CopyTo Test", "Failed: " + i + " " + inArray[i] + " " + outArray[i]); 795c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang break; 805c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang } 815c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang } 825c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang for (int i = count; i < arr_len; i++) { 835c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang if (outArray[i] != 0) { 845c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang result = false; 855c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang android.util.Log.v("Allocation CopyTo Test", "Failed: " + i + " " + inArray[i] + " " + outArray[i]); 865c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang break; 875c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang } 885c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang } 895c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang if (result) { 905c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang android.util.Log.v("Allocation CopyTo Test", "copy1DRangeTo_Byte TEST PASSED"); 915c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang } else { 925c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang failTest(); 935c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang } 945c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang } 955c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang 965c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang public void allocation_copy1DRangeTo_Short(RenderScript mRS) { 975c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang Random random = new Random(0x172d8ab9); 985c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang int width = random.nextInt(512); 995c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang int arr_len = width; 1005c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang 1015c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang short[] inArray = new short[arr_len]; 1025c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang short[] outArray = new short[arr_len]; 1035c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang 1045c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang for (int i = 0; i < arr_len; i++) { 1055c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang inArray[i] = (short)random.nextInt(); 1065c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang } 1075c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang 1085c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang Type.Builder typeBuilder = new Type.Builder(mRS, Element.I16(mRS)); 1095c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang typeBuilder.setX(width); 1105c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang Allocation alloc = Allocation.createTyped(mRS, typeBuilder.create()); 1115c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang int offset = random.nextInt(arr_len); 1125c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang int count = arr_len - offset; 1135c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang alloc.copy1DRangeFrom(offset, count, inArray); 1145c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang alloc.copy1DRangeTo(offset, count, outArray); 1155c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang 1165c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang boolean result = true; 1175c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang for (int i = 0; i < count; i++) { 1185c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang if (inArray[i] != outArray[i]) { 1195c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang result = false; 1205c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang android.util.Log.v("Allocation CopyTo Test", "Failed: " + i + " " + inArray[i] + " " + outArray[i]); 1215c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang break; 1225c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang } 1235c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang } 1245c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang for (int i = count; i < arr_len; i++) { 1255c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang if (outArray[i] != 0) { 1265c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang result = false; 1275c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang android.util.Log.v("Allocation CopyTo Test", "Failed: " + i + " " + inArray[i] + " " + outArray[i]); 1285c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang break; 1295c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang } 1305c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang } 1315c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang if (result) { 1325c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang android.util.Log.v("Allocation CopyTo Test", "copy1DRangeTo_Short TEST PASSED"); 1335c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang } else { 1345c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang failTest(); 1355c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang } 1365c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang } 1375c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang 1385c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang public void allocation_copy1DRangeTo_Int(RenderScript mRS) { 1395c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang Random random = new Random(0x172d8ab9); 1405c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang int width = random.nextInt(512); 1415c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang int arr_len = width; 1425c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang 1435c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang int[] inArray = new int[arr_len]; 1445c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang int[] outArray = new int[arr_len]; 1455c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang 1465c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang for (int i = 0; i < arr_len; i++) { 1475c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang inArray[i] = random.nextInt(); 1485c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang } 1495c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang 1505c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang Type.Builder typeBuilder = new Type.Builder(mRS, Element.I32(mRS)); 1515c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang typeBuilder.setX(width); 1525c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang Allocation alloc = Allocation.createTyped(mRS, typeBuilder.create()); 1535c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang int offset = random.nextInt(arr_len); 1545c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang int count = arr_len - offset; 1555c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang alloc.copy1DRangeFrom(offset, count, inArray); 1565c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang alloc.copy1DRangeTo(offset, count, outArray); 1575c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang 1585c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang boolean result = true; 1595c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang for (int i = 0; i < count; i++) { 1605c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang if (inArray[i] != outArray[i]) { 1615c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang result = false; 1625c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang android.util.Log.v("Allocation CopyTo Test", "Failed: " + i + " " + inArray[i] + " " + outArray[i]); 1635c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang break; 1645c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang } 1655c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang } 1665c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang for (int i = count; i < arr_len; i++) { 1675c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang if (outArray[i] != 0) { 1685c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang result = false; 1695c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang android.util.Log.v("Allocation CopyTo Test", "Failed: " + i + " " + inArray[i] + " " + outArray[i]); 1705c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang break; 1715c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang } 1725c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang } 1735c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang if (result) { 1745c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang android.util.Log.v("Allocation CopyTo Test", "copy1DRangeTo_Int TEST PASSED"); 1755c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang } else { 1765c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang failTest(); 1775c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang } 1785c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang } 1795c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang 1805c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang public void allocation_copy1DRangeTo_Float(RenderScript mRS) { 1815c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang Random random = new Random(0x172d8ab9); 1825c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang int width = random.nextInt(512); 1835c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang int arr_len = width; 1845c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang 1855c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang float[] inArray = new float[arr_len]; 1865c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang float[] outArray = new float[arr_len]; 1875c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang 1885c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang for (int i = 0; i < arr_len; i++) { 1895c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang inArray[i] = random.nextFloat(); 1905c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang } 1915c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang 1925c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang Type.Builder typeBuilder = new Type.Builder(mRS, Element.F32(mRS)); 1935c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang typeBuilder.setX(width); 1945c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang Allocation alloc = Allocation.createTyped(mRS, typeBuilder.create()); 1955c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang int offset = random.nextInt(arr_len); 1965c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang int count = arr_len - offset; 1975c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang alloc.copy1DRangeFrom(offset, count, inArray); 1985c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang alloc.copy1DRangeTo(offset, count, outArray); 1995c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang 2005c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang boolean result = true; 2015c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang for (int i = 0; i < count; i++) { 2025c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang if (inArray[i] != outArray[i]) { 2035c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang result = false; 2045c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang android.util.Log.v("Allocation CopyTo Test", "Failed: " + i + " " + inArray[i] + " " + outArray[i]); 2055c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang break; 2065c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang } 2075c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang } 2085c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang for (int i = count; i < arr_len; i++) { 2095c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang if (outArray[i] != 0f) { 2105c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang result = false; 2115c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang android.util.Log.v("Allocation CopyTo Test", "Failed: " + i + " " + inArray[i] + " " + outArray[i]); 2125c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang break; 2135c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang } 2145c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang } 2155c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang if (result) { 2165c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang android.util.Log.v("Allocation CopyTo Test", "copy1DRangeTo_Float TEST PASSED"); 2175c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang } else { 2185c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang failTest(); 2195c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang } 2205c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang } 2215c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang 2225c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang public void allocation_copy1DRangeTo_Long(RenderScript mRS) { 2235c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang Random random = new Random(0x172d8ab9); 2245c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang int width = random.nextInt(512); 2255c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang int arr_len = width; 2265c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang 2275c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang long[] inArray = new long[arr_len]; 2285c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang long[] outArray = new long[arr_len]; 2295c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang 2305c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang for (int i = 0; i < arr_len; i++) { 2315c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang inArray[i] = random.nextLong(); 2325c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang } 2335c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang 2345c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang Type.Builder typeBuilder = new Type.Builder(mRS, Element.I64(mRS)); 2355c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang typeBuilder.setX(width); 2365c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang Allocation alloc = Allocation.createTyped(mRS, typeBuilder.create()); 2375c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang int offset = random.nextInt(arr_len); 2385c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang int count = arr_len - offset; 2395c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang alloc.copy1DRangeFrom(offset, count, inArray); 2405c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang alloc.copy1DRangeTo(offset, count, outArray); 2415c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang 2425c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang boolean result = true; 2435c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang for (int i = 0; i < count; i++) { 2445c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang if (inArray[i] != outArray[i]) { 2455c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang result = false; 2465c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang android.util.Log.v("Allocation CopyTo Test", "Failed: " + i + " " + inArray[i] + " " + outArray[i]); 2475c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang break; 2485c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang } 2495c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang } 2505c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang for (int i = count; i < arr_len; i++) { 2515c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang if (outArray[i] != 0) { 2525c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang result = false; 2535c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang android.util.Log.v("Allocation CopyTo Test", "Failed: " + i + " " + inArray[i] + " " + outArray[i]); 2545c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang break; 2555c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang } 2565c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang } 2575c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang if (result) { 2585c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang android.util.Log.v("Allocation CopyTo Test", "copy1DRangeTo_Long TEST PASSED"); 2595c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang } else { 2605c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang failTest(); 2615c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang } 2625c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang } 2635c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang 2645c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang public void allocation_copy2DRangeTo_Byte(RenderScript mRS) { 2655c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang Random random = new Random(0x172d8ab9); 2665c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang int width = random.nextInt(128); 2675c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang int height = random.nextInt(128); 2685c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang int xoff = random.nextInt(width); 2695c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang int yoff = random.nextInt(height); 2705c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang int xcount = width - xoff; 2715c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang int ycount = height - yoff; 2725c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang int arr_len = xcount * ycount; 2735c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang 2745c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang byte[] inArray = new byte[arr_len]; 2755c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang byte[] outArray = new byte[arr_len]; 2765c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang random.nextBytes(inArray); 2775c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang 2785c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang Type.Builder typeBuilder = new Type.Builder(mRS, Element.I8(mRS)); 2795c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang typeBuilder.setX(width).setY(height); 2805c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang Allocation alloc = Allocation.createTyped(mRS, typeBuilder.create()); 2815c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang alloc.copy2DRangeFrom(xoff, yoff, xcount, ycount, inArray); 2825c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang alloc.copy2DRangeTo(xoff, yoff, xcount, ycount, outArray); 2835c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang 2845c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang boolean result = true; 2855c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang for (int i = 0; i < arr_len; i++) { 2865c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang if (inArray[i] != outArray[i]) { 2875c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang result = false; 2885c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang android.util.Log.v("Allocation CopyTo Test", "Failed: " + i + " " + inArray[i] + " " + outArray[i]); 2895c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang break; 2905c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang } 2915c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang } 2925c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang if (result) { 2935c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang android.util.Log.v("Allocation CopyTo Test", "copy2DRangeTo_Byte TEST PASSED"); 2945c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang } else { 2955c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang failTest(); 2965c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang } 2975c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang } 2985c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang 2995c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang public void allocation_copy2DRangeTo_Short(RenderScript mRS) { 3005c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang Random random = new Random(0x172d8ab9); 3015c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang int width = random.nextInt(128); 3025c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang int height = random.nextInt(128); 3035c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang int xoff = random.nextInt(width); 3045c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang int yoff = random.nextInt(height); 3055c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang int xcount = width - xoff; 3065c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang int ycount = height - yoff; 3075c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang int arr_len = xcount * ycount; 3085c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang 3095c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang short[] inArray = new short[arr_len]; 3105c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang short[] outArray = new short[arr_len]; 3115c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang 3125c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang for (int i = 0; i < arr_len; i++) { 3135c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang inArray[i] = (short)random.nextInt(); 3145c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang } 3155c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang 3165c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang Type.Builder typeBuilder = new Type.Builder(mRS, Element.I16(mRS)); 3175c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang typeBuilder.setX(width).setY(height); 3185c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang Allocation alloc = Allocation.createTyped(mRS, typeBuilder.create()); 3195c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang alloc.copy2DRangeFrom(xoff, yoff, xcount, ycount, inArray); 3205c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang alloc.copy2DRangeTo(xoff, yoff, xcount, ycount, outArray); 3215c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang 3225c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang boolean result = true; 3235c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang for (int i = 0; i < arr_len; i++) { 3245c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang if (inArray[i] != outArray[i]) { 3255c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang result = false; 3265c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang android.util.Log.v("Allocation CopyTo Test", "Failed: " + i + " " + inArray[i] + " " + outArray[i]); 3275c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang break; 3285c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang } 3295c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang } 3305c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang if (result) { 3315c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang android.util.Log.v("Allocation CopyTo Test", "copy2DRangeTo_Short TEST PASSED"); 3325c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang } else { 3335c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang failTest(); 3345c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang } 3355c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang } 3365c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang 3375c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang public void allocation_copy2DRangeTo_Int(RenderScript mRS) { 3385c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang Random random = new Random(0x172d8ab9); 3395c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang int width = random.nextInt(128); 3405c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang int height = random.nextInt(128); 3415c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang int xoff = random.nextInt(width); 3425c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang int yoff = random.nextInt(height); 3435c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang int xcount = width - xoff; 3445c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang int ycount = height - yoff; 3455c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang int arr_len = xcount * ycount; 3465c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang 3475c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang int[] inArray = new int[arr_len]; 3485c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang int[] outArray = new int[arr_len]; 3495c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang 3505c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang for (int i = 0; i < arr_len; i++) { 3515c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang inArray[i] = random.nextInt(); 3525c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang } 3535c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang 3545c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang Type.Builder typeBuilder = new Type.Builder(mRS, Element.I32(mRS)); 3555c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang typeBuilder.setX(width).setY(height); 3565c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang Allocation alloc = Allocation.createTyped(mRS, typeBuilder.create()); 3575c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang alloc.copy2DRangeFrom(xoff, yoff, xcount, ycount, inArray); 3585c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang alloc.copy2DRangeTo(xoff, yoff, xcount, ycount, outArray); 3595c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang 3605c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang boolean result = true; 3615c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang for (int i = 0; i < arr_len; i++) { 3625c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang if (inArray[i] != outArray[i]) { 3635c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang result = false; 3645c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang android.util.Log.v("Allocation CopyTo Test", "Failed: " + i + " " + inArray[i] + " " + outArray[i]); 3655c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang break; 3665c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang } 3675c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang } 3685c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang if (result) { 3695c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang android.util.Log.v("Allocation CopyTo Test", "copy2DRangeTo_Int TEST PASSED"); 3705c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang } else { 3715c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang failTest(); 3725c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang } 3735c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang } 3745c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang 3755c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang public void allocation_copy2DRangeTo_Float(RenderScript mRS) { 3765c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang Random random = new Random(0x172d8ab9); 3775c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang int width = random.nextInt(128); 3785c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang int height = random.nextInt(128); 3795c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang int xoff = random.nextInt(width); 3805c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang int yoff = random.nextInt(height); 3815c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang int xcount = width - xoff; 3825c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang int ycount = height - yoff; 3835c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang int arr_len = xcount * ycount; 3845c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang 3855c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang float[] inArray = new float[arr_len]; 3865c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang float[] outArray = new float[arr_len]; 3875c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang 3885c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang for (int i = 0; i < arr_len; i++) { 3895c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang inArray[i] = random.nextFloat(); 3905c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang } 3915c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang 3925c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang Type.Builder typeBuilder = new Type.Builder(mRS, Element.F32(mRS)); 3935c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang typeBuilder.setX(width).setY(height); 3945c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang Allocation alloc = Allocation.createTyped(mRS, typeBuilder.create()); 3955c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang alloc.copy2DRangeFrom(xoff, yoff, xcount, ycount, inArray); 3965c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang alloc.copy2DRangeTo(xoff, yoff, xcount, ycount, outArray); 3975c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang 3985c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang boolean result = true; 3995c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang for (int i = 0; i < arr_len; i++) { 4005c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang if (inArray[i] != outArray[i]) { 4015c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang result = false; 4025c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang android.util.Log.v("Allocation CopyTo Test", "Failed: " + i + " " + inArray[i] + " " + outArray[i]); 4035c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang break; 4045c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang } 4055c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang } 4065c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang if (result) { 4075c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang android.util.Log.v("Allocation CopyTo Test", "copy2DRangeTo_Float TEST PASSED"); 4085c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang } else { 4095c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang failTest(); 4105c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang } 4115c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang } 4125c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang 4135c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang public void allocation_copy2DRangeTo_Long(RenderScript mRS) { 4145c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang Random random = new Random(0x172d8ab9); 4155c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang int width = random.nextInt(128); 4165c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang int height = random.nextInt(128); 4175c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang int xoff = random.nextInt(width); 4185c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang int yoff = random.nextInt(height); 4195c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang int xcount = width - xoff; 4205c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang int ycount = height - yoff; 4215c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang int arr_len = xcount * ycount; 4225c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang 4235c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang long[] inArray = new long[arr_len]; 4245c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang long[] outArray = new long[arr_len]; 4255c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang 4265c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang for (int i = 0; i < arr_len; i++) { 4275c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang inArray[i] = random.nextLong(); 4285c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang } 4295c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang 4305c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang Type.Builder typeBuilder = new Type.Builder(mRS, Element.I64(mRS)); 4315c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang typeBuilder.setX(width).setY(height); 4325c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang Allocation alloc = Allocation.createTyped(mRS, typeBuilder.create()); 4335c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang alloc.copy2DRangeFrom(xoff, yoff, xcount, ycount, inArray); 4345c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang alloc.copy2DRangeTo(xoff, yoff, xcount, ycount, outArray); 4355c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang 4365c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang boolean result = true; 4375c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang for (int i = 0; i < arr_len; i++) { 4385c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang if (inArray[i] != outArray[i]) { 4395c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang result = false; 4405c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang android.util.Log.v("Allocation CopyTo Test", "Failed: " + i + " " + inArray[i] + " " + outArray[i]); 4415c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang break; 4425c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang } 4435c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang } 4445c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang if (result) { 4455c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang android.util.Log.v("Allocation CopyTo Test", "copy2DRangeTo_Long TEST PASSED"); 4465c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang } else { 4475c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang failTest(); 4485c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang } 4495c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang } 4505c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang 4515c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang 4525c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang public void allocation_copy1DRangeToUnchecked_Byte(RenderScript mRS) { 4535c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang Random random = new Random(0x172d8ab9); 4545c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang int width = random.nextInt(512); 4555c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang int arr_len = width; 4565c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang 4575c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang byte[] inArray = new byte[arr_len]; 4585c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang byte[] outArray = new byte[arr_len]; 4595c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang random.nextBytes(inArray); 4605c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang 4615c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang Type.Builder typeBuilder = new Type.Builder(mRS, Element.I8(mRS)); 4625c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang typeBuilder.setX(width); 4635c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang Allocation alloc = Allocation.createTyped(mRS, typeBuilder.create()); 4645c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang int offset = random.nextInt(arr_len); 4655c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang int count = arr_len - offset; 4665c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang alloc.copy1DRangeFrom(offset, count, inArray); 4675c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang alloc.copy1DRangeToUnchecked(offset, count, outArray); 4685c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang 4695c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang boolean result = true; 4705c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang for (int i = 0; i < count; i++) { 4715c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang if (inArray[i] != outArray[i]) { 4725c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang result = false; 4735c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang android.util.Log.v("Allocation CopyTo Test", "Failed: " + i + " " + inArray[i] + " " + outArray[i]); 4745c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang break; 4755c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang } 4765c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang } 4775c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang for (int i = count; i < arr_len; i++) { 4785c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang if (outArray[i] != 0) { 4795c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang result = false; 4805c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang android.util.Log.v("Allocation CopyTo Test", "Failed: " + i + " " + inArray[i] + " " + outArray[i]); 4815c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang break; 4825c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang } 4835c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang } 4845c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang if (result) { 4855c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang android.util.Log.v("Allocation CopyTo Test", "copy1DRangeToUnchecked_Byte TEST PASSED"); 4865c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang } else { 4875c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang failTest(); 4885c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang } 4895c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang } 4905c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang 4915c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang public void allocation_copy1DRangeToUnchecked_Short(RenderScript mRS) { 4925c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang Random random = new Random(0x172d8ab9); 4935c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang int width = random.nextInt(512); 4945c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang int arr_len = width; 4955c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang 4965c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang short[] inArray = new short[arr_len]; 4975c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang short[] outArray = new short[arr_len]; 4985c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang 4995c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang for (int i = 0; i < arr_len; i++) { 5005c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang inArray[i] = (short)random.nextInt(); 5015c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang } 5025c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang 5035c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang Type.Builder typeBuilder = new Type.Builder(mRS, Element.I16(mRS)); 5045c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang typeBuilder.setX(width); 5055c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang Allocation alloc = Allocation.createTyped(mRS, typeBuilder.create()); 5065c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang int offset = random.nextInt(arr_len); 5075c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang int count = arr_len - offset; 5085c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang alloc.copy1DRangeFrom(offset, count, inArray); 5095c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang alloc.copy1DRangeToUnchecked(offset, count, outArray); 5105c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang 5115c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang boolean result = true; 5125c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang for (int i = 0; i < count; i++) { 5135c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang if (inArray[i] != outArray[i]) { 5145c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang result = false; 5155c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang android.util.Log.v("Allocation CopyTo Test", "Failed: " + i + " " + inArray[i] + " " + outArray[i]); 5165c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang break; 5175c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang } 5185c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang } 5195c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang for (int i = count; i < arr_len; i++) { 5205c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang if (outArray[i] != 0) { 5215c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang result = false; 5225c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang android.util.Log.v("Allocation CopyTo Test", "Failed: " + i + " " + inArray[i] + " " + outArray[i]); 5235c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang break; 5245c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang } 5255c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang } 5265c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang if (result) { 5275c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang android.util.Log.v("Allocation CopyTo Test", "copy1DRangeToUnchecked_Short TEST PASSED"); 5285c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang } else { 5295c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang failTest(); 5305c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang } 5315c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang } 5325c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang 5335c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang public void allocation_copy1DRangeToUnchecked_Int(RenderScript mRS) { 5345c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang Random random = new Random(0x172d8ab9); 5355c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang int width = random.nextInt(512); 5365c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang int arr_len = width; 5375c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang 5385c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang int[] inArray = new int[arr_len]; 5395c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang int[] outArray = new int[arr_len]; 5405c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang 5415c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang for (int i = 0; i < arr_len; i++) { 5425c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang inArray[i] = random.nextInt(); 5435c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang } 5445c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang 5455c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang Type.Builder typeBuilder = new Type.Builder(mRS, Element.I32(mRS)); 5465c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang typeBuilder.setX(width); 5475c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang Allocation alloc = Allocation.createTyped(mRS, typeBuilder.create()); 5485c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang int offset = random.nextInt(arr_len); 5495c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang int count = arr_len - offset; 5505c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang alloc.copy1DRangeFrom(offset, count, inArray); 5515c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang alloc.copy1DRangeToUnchecked(offset, count, outArray); 5525c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang 5535c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang boolean result = true; 5545c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang for (int i = 0; i < count; i++) { 5555c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang if (inArray[i] != outArray[i]) { 5565c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang result = false; 5575c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang android.util.Log.v("Allocation CopyTo Test", "Failed: " + i + " " + inArray[i] + " " + outArray[i]); 5585c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang break; 5595c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang } 5605c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang } 5615c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang for (int i = count; i < arr_len; i++) { 5625c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang if (outArray[i] != 0) { 5635c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang result = false; 5645c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang android.util.Log.v("Allocation CopyTo Test", "Failed: " + i + " " + inArray[i] + " " + outArray[i]); 5655c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang break; 5665c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang } 5675c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang } 5685c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang if (result) { 5695c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang android.util.Log.v("Allocation CopyTo Test", "copy1DRangeToUnchecked_Int TEST PASSED"); 5705c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang } else { 5715c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang failTest(); 5725c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang } 5735c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang } 5745c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang 5755c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang public void allocation_copy1DRangeToUnchecked_Float(RenderScript mRS) { 5765c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang Random random = new Random(0x172d8ab9); 5775c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang int width = random.nextInt(512); 5785c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang int arr_len = width; 5795c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang 5805c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang float[] inArray = new float[arr_len]; 5815c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang float[] outArray = new float[arr_len]; 5825c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang 5835c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang for (int i = 0; i < arr_len; i++) { 5845c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang inArray[i] = random.nextFloat(); 5855c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang } 5865c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang 5875c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang Type.Builder typeBuilder = new Type.Builder(mRS, Element.F32(mRS)); 5885c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang typeBuilder.setX(width); 5895c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang Allocation alloc = Allocation.createTyped(mRS, typeBuilder.create()); 5905c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang int offset = random.nextInt(arr_len); 5915c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang int count = arr_len - offset; 5925c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang alloc.copy1DRangeFrom(offset, count, inArray); 5935c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang alloc.copy1DRangeToUnchecked(offset, count, outArray); 5945c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang 5955c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang boolean result = true; 5965c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang for (int i = 0; i < count; i++) { 5975c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang if (inArray[i] != outArray[i]) { 5985c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang result = false; 5995c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang android.util.Log.v("Allocation CopyTo Test", "Failed: " + i + " " + inArray[i] + " " + outArray[i]); 6005c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang break; 6015c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang } 6025c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang } 6035c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang for (int i = count; i < arr_len; i++) { 6045c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang if (outArray[i] != 0f) { 6055c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang result = false; 6065c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang android.util.Log.v("Allocation CopyTo Test", "Failed: " + i + " " + inArray[i] + " " + outArray[i]); 6075c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang break; 6085c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang } 6095c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang } 6105c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang if (result) { 6115c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang android.util.Log.v("Allocation CopyTo Test", "copy1DRangeToUnchecked_Float TEST PASSED"); 6125c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang } else { 6135c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang failTest(); 6145c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang } 6155c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang } 6165c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang 6175c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang public void allocation_copy1DRangeToUnchecked_Long(RenderScript mRS) { 6185c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang Random random = new Random(0x172d8ab9); 6195c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang int width = random.nextInt(512); 6205c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang int arr_len = width; 6215c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang 6225c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang long[] inArray = new long[arr_len]; 6235c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang long[] outArray = new long[arr_len]; 6245c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang 6255c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang for (int i = 0; i < arr_len; i++) { 6265c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang inArray[i] = random.nextLong(); 6275c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang } 6285c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang 6295c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang Type.Builder typeBuilder = new Type.Builder(mRS, Element.I64(mRS)); 6305c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang typeBuilder.setX(width); 6315c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang Allocation alloc = Allocation.createTyped(mRS, typeBuilder.create()); 6325c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang int offset = random.nextInt(arr_len); 6335c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang int count = arr_len - offset; 6345c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang alloc.copy1DRangeFrom(offset, count, inArray); 6355c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang alloc.copy1DRangeToUnchecked(offset, count, outArray); 6365c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang 6375c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang boolean result = true; 6385c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang for (int i = 0; i < count; i++) { 6395c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang if (inArray[i] != outArray[i]) { 6405c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang result = false; 6415c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang android.util.Log.v("Allocation CopyTo Test", "Failed: " + i + " " + inArray[i] + " " + outArray[i]); 6425c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang break; 6435c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang } 6445c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang } 6455c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang for (int i = count; i < arr_len; i++) { 6465c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang if (outArray[i] != 0) { 6475c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang result = false; 6485c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang android.util.Log.v("Allocation CopyTo Test", "Failed: " + i + " " + inArray[i] + " " + outArray[i]); 6495c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang break; 6505c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang } 6515c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang } 6525c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang if (result) { 6535c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang android.util.Log.v("Allocation CopyTo Test", "copy1DRangeToUnchecked_Long TEST PASSED"); 6545c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang } else { 6555c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang failTest(); 6565c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang } 6575c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang } 6585c6b231c46b6a2ce973d13bc5e2f682d4b3794caMiao Wang} 659