diff options
| author | Jason Sams <jsams@google.com> | 2013-03-19 12:43:46 -0700 |
|---|---|---|
| committer | Jason Sams <jsams@google.com> | 2013-03-19 12:43:46 -0700 |
| commit | eacf9c80419cb7c870c61e020e19900c765ca0b4 (patch) | |
| tree | c5428802287019c7145a2b04f85c7c6c0539df05 /tests/RenderScriptTests/ComputePerf/src/com/example/android/rs | |
| parent | e4c9ac2df26f640fa9aeab5928e82bcc59a33da2 (diff) | |
| download | frameworks_base-eacf9c80419cb7c870c61e020e19900c765ca0b4.zip frameworks_base-eacf9c80419cb7c870c61e020e19900c765ca0b4.tar.gz frameworks_base-eacf9c80419cb7c870c61e020e19900c765ca0b4.tar.bz2 | |
Move compute tests from frameworks/base to frameworks/rs
Change-Id: I670027782f5ba6df0713dbdc3c99ae7c1eef7d22
Diffstat (limited to 'tests/RenderScriptTests/ComputePerf/src/com/example/android/rs')
6 files changed, 0 insertions, 261 deletions
diff --git a/tests/RenderScriptTests/ComputePerf/src/com/example/android/rs/computeperf/ComputePerf.java b/tests/RenderScriptTests/ComputePerf/src/com/example/android/rs/computeperf/ComputePerf.java deleted file mode 100644 index 5446f66..0000000 --- a/tests/RenderScriptTests/ComputePerf/src/com/example/android/rs/computeperf/ComputePerf.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright (C) 2011-2012 The Android Open Source Project - * - * 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. - */ - -package com.example.android.rs.computeperf; - -import android.app.Activity; -import android.os.Bundle; -import android.graphics.BitmapFactory; -import android.graphics.Bitmap; -import android.renderscript.RenderScript; -import android.renderscript.Allocation; -import android.util.Log; -import android.widget.ImageView; - -public class ComputePerf extends Activity { - private LaunchTest mLT; - private Mandelbrot mMandel; - private RenderScript mRS; - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.main); - - final int numTries = 100; - - long timesXLW = 0; - long timesXYW = 0; - - mRS = RenderScript.create(this); - mLT = new LaunchTest(mRS, getResources()); - mLT.XLW(); - mLT.XYW(); - for (int i = 0; i < numTries; i++) { - timesXLW += mLT.XLW(); - timesXYW += mLT.XYW(); - } - - timesXLW /= numTries; - timesXYW /= numTries; - - // XLW and XYW running times should match pretty closely - Log.v("ComputePerf", "xlw launch test " + timesXLW + "ms"); - Log.v("ComputePerf", "xyw launch test " + timesXYW + "ms"); - - mMandel = new Mandelbrot(mRS, getResources()); - mMandel.run(); - } -} diff --git a/tests/RenderScriptTests/ComputePerf/src/com/example/android/rs/computeperf/LaunchTest.java b/tests/RenderScriptTests/ComputePerf/src/com/example/android/rs/computeperf/LaunchTest.java deleted file mode 100644 index e2312ba..0000000 --- a/tests/RenderScriptTests/ComputePerf/src/com/example/android/rs/computeperf/LaunchTest.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (C) 2011-2012 The Android Open Source Project - * - * 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. - */ - -package com.example.android.rs.computeperf; - -import android.content.res.Resources; -import android.renderscript.*; - -public class LaunchTest { - private RenderScript mRS; - private Allocation mAllocationX; - private Allocation mAllocationXY; - private ScriptC_launchtestxlw mScript_xlw; - private ScriptC_launchtestxyw mScript_xyw; - - LaunchTest(RenderScript rs, Resources res) { - mRS = rs; - mScript_xlw = new ScriptC_launchtestxlw(mRS, res, R.raw.launchtestxlw); - mScript_xyw = new ScriptC_launchtestxyw(mRS, res, R.raw.launchtestxyw); - final int dim = mScript_xlw.get_dim(); - - mAllocationX = Allocation.createSized(rs, Element.U8(rs), dim); - Type.Builder tb = new Type.Builder(rs, Element.U8(rs)); - tb.setX(dim); - tb.setY(dim); - mAllocationXY = Allocation.createTyped(rs, tb.create()); - mScript_xlw.bind_buf(mAllocationXY); - } - - public long XLW() { - long t = java.lang.System.currentTimeMillis(); - mScript_xlw.forEach_root(mAllocationX); - mRS.finish(); - t = java.lang.System.currentTimeMillis() - t; - return t; - } - - public long XYW() { - long t = java.lang.System.currentTimeMillis(); - mScript_xyw.forEach_root(mAllocationXY); - mRS.finish(); - t = java.lang.System.currentTimeMillis() - t; - return t; - } -} diff --git a/tests/RenderScriptTests/ComputePerf/src/com/example/android/rs/computeperf/Mandelbrot.java b/tests/RenderScriptTests/ComputePerf/src/com/example/android/rs/computeperf/Mandelbrot.java deleted file mode 100644 index ea1cd62..0000000 --- a/tests/RenderScriptTests/ComputePerf/src/com/example/android/rs/computeperf/Mandelbrot.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (C) 2011 The Android Open Source Project - * - * 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. - */ - -package com.example.android.rs.computeperf; - -import android.content.res.Resources; -import android.renderscript.*; - -public class Mandelbrot implements Runnable { - private RenderScript mRS; - private Allocation mAllocationXY; - private ScriptC_mandelbrot mScript; - - Mandelbrot(RenderScript rs, Resources res) { - mRS = rs; - mScript = new ScriptC_mandelbrot(mRS, res, R.raw.mandelbrot); - - Type.Builder tb = new Type.Builder(rs, Element.U8_4(rs)); - tb.setX(mScript.get_gDimX()); - tb.setY(mScript.get_gDimY()); - mAllocationXY = Allocation.createTyped(rs, tb.create()); - } - - public void run() { - long t = java.lang.System.currentTimeMillis(); - mScript.forEach_root(mAllocationXY); - mRS.finish(); - t = java.lang.System.currentTimeMillis() - t; - android.util.Log.v("ComputePerf", "mandelbrot ms " + t); - } - -} diff --git a/tests/RenderScriptTests/ComputePerf/src/com/example/android/rs/computeperf/launchtestxlw.rs b/tests/RenderScriptTests/ComputePerf/src/com/example/android/rs/computeperf/launchtestxlw.rs deleted file mode 100644 index 7b81dfe..0000000 --- a/tests/RenderScriptTests/ComputePerf/src/com/example/android/rs/computeperf/launchtestxlw.rs +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (C) 2011 The Android Open Source Project - * - * 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. - */ - -#pragma version(1) -#pragma rs java_package_name(com.example.android.rs.computeperf) - -const int dim = 2048; -uint8_t *buf; - -void root(uchar *v_out, uint32_t x) { - uint8_t *p = buf; - p += x * dim; - for (int i=0; i<dim; i++) { - p[i] = 1; - } -} - diff --git a/tests/RenderScriptTests/ComputePerf/src/com/example/android/rs/computeperf/launchtestxyw.rs b/tests/RenderScriptTests/ComputePerf/src/com/example/android/rs/computeperf/launchtestxyw.rs deleted file mode 100644 index 7f7aa95..0000000 --- a/tests/RenderScriptTests/ComputePerf/src/com/example/android/rs/computeperf/launchtestxyw.rs +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright (C) 2011 The Android Open Source Project - * - * 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. - */ - -#pragma version(1) -#pragma rs java_package_name(com.example.android.rs.computeperf) - -void root(uchar *v_out, uint32_t x, uint32_t y) { - *v_out = 0; -} - diff --git a/tests/RenderScriptTests/ComputePerf/src/com/example/android/rs/computeperf/mandelbrot.rs b/tests/RenderScriptTests/ComputePerf/src/com/example/android/rs/computeperf/mandelbrot.rs deleted file mode 100644 index 0ffb0e5..0000000 --- a/tests/RenderScriptTests/ComputePerf/src/com/example/android/rs/computeperf/mandelbrot.rs +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright (C) 2011 The Android Open Source Project -// -// 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. - -#pragma version(1) -#pragma rs java_package_name(com.example.android.rs.computeperf) - -const int gMaxIteration = 500; -const int gDimX = 1024; -const int gDimY = 1024; - -void root(uchar4 *v_out, uint32_t x, uint32_t y) { - float2 p; - p.x = -2.5f + ((float)x / gDimX) * 3.5f; - p.y = -1.f + ((float)y / gDimY) * 2.f; - - float2 t = 0; - float2 t2 = t * t; - int iteration = 0; - while((t2.x + t2.y < 4.f) && (iteration < gMaxIteration)) { - float xtemp = t2.x - t2.y + p.x; - t.y = 2 * t.x * t.y + p.y; - t.x = xtemp; - iteration++; - t2 = t * t; - } - - if(iteration >= gMaxIteration) { - *v_out = 0; - } else { - *v_out = (uchar4){iteration & 0xff, (iteration >> 6) & 0xff, 0x8f, 0xff}; - } -} |
