aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorxueliang.zhong <xueliang.zhong@linaro.org>2017-07-07 11:36:48 +0100
committerxueliang.zhong <xueliang.zhong@linaro.org>2017-07-27 13:55:08 +0100
commit0bf8cd95fc684af856673963f30782c2894de802 (patch)
treecabe17c9081dd5f4dcf178b23a730bb990a056cc
parent21db0684d174b782f0c83cab08f0de97355f8a95 (diff)
downloadart-testing-0bf8cd95fc684af856673963f30782c2894de802.tar.gz
Introduce ArrayBoundsCheck case in micro benchmark.
This patch introduces ArrayBoundsCheck in micro benchmarks to test the performance of optimizing compiler. This ArrayBoundsCheck benchmark tests the compiler's ability to analyze and optimize away bounds checks in array index. Change-Id: Icc82ce93a8d90429d84fbc7b2cdaf23522eda536
-rw-r--r--README.md24
-rw-r--r--benchmarks/micro/ArrayBoundsCheck.java199
2 files changed, 223 insertions, 0 deletions
diff --git a/README.md b/README.md
index 4b74ae4..50befc3 100644
--- a/README.md
+++ b/README.md
@@ -222,6 +222,30 @@ existing benchmark. Besides, developers should also notice:
// Please refer to existing benchmarks for further examples.
+## Performance History Tracking
+
+### ART Reports
+
+The performance history of AOSP ART Tip running this benchmark suite is tracked on
+website: https://art-reports.linaro.org/.
+
+### Stable Benchmark Suites
+
+To maintain the performance history data and allow the team to track the performance
+of ART easily, the following existing benchmarks should have no new changes:
+
+1. algorithm
+2. benchmarksgame
+3. caffeinemark
+4. math
+5. reversigame
+6. stanford
+
+The following benchmarks are allowed to have new changes (e.g. new cases introduced):
+
+1. micro
+2. testsimd
+3. jit_aot
## Test Suite Details
diff --git a/benchmarks/micro/ArrayBoundsCheck.java b/benchmarks/micro/ArrayBoundsCheck.java
new file mode 100644
index 0000000..f8a1262
--- /dev/null
+++ b/benchmarks/micro/ArrayBoundsCheck.java
@@ -0,0 +1,199 @@
+/*
+ * Copyright (c) 2017, Linaro Limited. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+/*
+ * Description: Simple loops around array index bounds check performance.
+ * Main Focus: Test the compiler's ability to perform array bounds check elemination.
+ */
+
+package benchmarks.micro;
+
+import java.lang.System;
+import java.util.Random;
+
+public class ArrayBoundsCheck {
+
+ private static final int NUM_INVOKES = 500;
+
+ /* Random pool size. */
+ private static final int NUM_RANDS = 1024;
+
+ /* Pre-allocated pool of random numbers. */
+ private static final long[] static_array = new long[NUM_RANDS];
+
+ // These are written but not read. The computation routines below store their
+ // result to these static variables to ensure the computation code is not
+ // removed by DCE.
+ private static int res_int;
+ private static long res_long;
+
+ static {
+ Random rand = new Random();
+
+ for (int i = 0; i < NUM_RANDS; i++) {
+ static_array[i] = rand.nextLong();
+ }
+ }
+
+ private void init_array(long[] array) {
+ for (int i = 0; i < array.length; ++i) {
+ array[i] = i;
+ }
+ }
+
+ public void timeStaticArray_ModStaticField(int iterations) {
+ long res = 0;
+ for (int iter = 0; iter < iterations; ++iter) {
+ for (int i = 0; i < NUM_INVOKES; ++i) {
+ long a = static_array[i % NUM_RANDS];
+ long b = static_array[(i + 1) % NUM_RANDS];
+ res += a + b;
+ }
+ }
+ res_long = res;
+ }
+
+ public void timeStaticArray_ModLength(int iterations) {
+ long res = 0;
+ for (int iter = 0; iter < iterations; ++iter) {
+ for (int i = 0; i < NUM_INVOKES; ++i) {
+ long a = static_array[i % static_array.length];
+ long b = static_array[(i + 1) % static_array.length];
+ res += a + b;
+ }
+ }
+ res_long = res;
+ }
+
+ public void timeStaticArray_ModConst(int iterations) {
+ long res = 0;
+ int length = 1024; // Same as NUM_RANDS, except that it's a local const value.
+ for (int iter = 0; iter < iterations; ++iter) {
+ for (int i = 0; i < NUM_INVOKES; ++i) {
+ long a = static_array[i % length];
+ long b = static_array[(i + 1) % length];
+ res += a + b;
+ }
+ }
+ res_long = res;
+ }
+
+ public void timeLocalArray_ModStaticField(int iterations) {
+ long res = 0;
+ long[] array = new long[NUM_RANDS];
+ init_array(array);
+ for (int iter = 0; iter < iterations; ++iter) {
+ for (int i = 0; i < NUM_INVOKES; ++i) {
+ long a = array[i % NUM_RANDS];
+ long b = array[(i + 1) % NUM_RANDS];
+ res += a + b;
+ }
+ }
+ res_long = res;
+ }
+
+ public void timeLocalArray_ModLength(int iterations) {
+ long res = 0;
+ long[] array = new long[NUM_RANDS];
+ init_array(array);
+ for (int iter = 0; iter < iterations; ++iter) {
+ for (int i = 0; i < NUM_INVOKES; ++i) {
+ long a = array[i % array.length];
+ long b = array[(i + 1) % array.length];
+ res += a + b;
+ }
+ }
+ res_long = res;
+ }
+
+ public void timeLocalArray_ModConst(int iterations) {
+ long res = 0;
+ long[] array = new long[NUM_RANDS];
+ init_array(array);
+ int length = 1024; // Same as NUM_RANDS, except that it's a local const value.
+ for (int iter = 0; iter < iterations; ++iter) {
+ for (int i = 0; i < NUM_INVOKES; ++i) {
+ long a = array[i % length];
+ long b = array[(i + 1) % length];
+ res += a + b;
+ }
+ }
+ res_long = res;
+ }
+
+ public static boolean verify() {
+ ArrayBoundsCheck obj = new ArrayBoundsCheck();
+
+ obj.timeLocalArray_ModConst(1);
+ obj.timeLocalArray_ModLength(1);
+ obj.timeLocalArray_ModStaticField(1);
+ obj.timeStaticArray_ModConst(1);
+ obj.timeStaticArray_ModLength(1);
+ obj.timeStaticArray_ModStaticField(1);
+
+ return true;
+ }
+
+ private static final int ITER_COUNT = 300000;
+
+ public static void main(String[] args) {
+ int rc = 0;
+ ArrayBoundsCheck obj = new ArrayBoundsCheck();
+
+ long before = System.currentTimeMillis();
+ obj.timeStaticArray_ModStaticField(ITER_COUNT);
+ long after = System.currentTimeMillis();
+ System.out.println("benchmarks/optimizing/ArrayBoundsCheck/StaticArray_ModField: "
+ + (after - before));
+
+ before = System.currentTimeMillis();
+ obj.timeStaticArray_ModLength(ITER_COUNT);
+ after = System.currentTimeMillis();
+ System.out.println("benchmarks/optimizing/ArrayBoundsCheck/StaticArray_ModLength: "
+ + (after - before));
+
+ before = System.currentTimeMillis();
+ obj.timeStaticArray_ModConst(ITER_COUNT);
+ after = System.currentTimeMillis();
+ System.out.println("benchmarks/optimizing/ArrayBoundsCheck/StaticArray_ModConst: "
+ + (after - before));
+
+ before = System.currentTimeMillis();
+ obj.timeLocalArray_ModStaticField(ITER_COUNT);
+ after = System.currentTimeMillis();
+ System.out.println("benchmarks/optimizing/ArrayBoundsCheck/LocalArray_ModField: "
+ + (after - before));
+
+ before = System.currentTimeMillis();
+ obj.timeLocalArray_ModLength(ITER_COUNT);
+ after = System.currentTimeMillis();
+ System.out.println("benchmarks/optimizing/ArrayBoundsCheck/LocalArray_ModLength: "
+ + (after - before));
+
+ before = System.currentTimeMillis();
+ obj.timeLocalArray_ModConst(ITER_COUNT);
+ after = System.currentTimeMillis();
+ System.out.println("benchmarks/optimizing/ArrayBoundsCheck/LocalArray_ModConst: "
+ + (after - before));
+
+ if (!verify()) {
+ rc++;
+ }
+
+ System.exit(rc);
+ }
+}