8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
23
24 package com.oracle.graal.compiler.hsail.test;
25
26 import com.oracle.graal.compiler.hsail.test.infra.GraalKernelTester;
27 import org.junit.Test;
28
29 /**
30 * Unit test that simulates the Mandelbrot application. The run method here is a static method
31 * version of the original mandel kernel and the invoke parameters are for the starting point of the
32 * mandel demo. Note: this will likely not pass the junit test on real hardware, but should pass on
33 * the simulator.
34 */
35 public class StaticMandelTest extends GraalKernelTester {
36
37 static final int initWidth = 768;
38 static final int initHeight = initWidth;
39 static final int maxIterations = 64;
40 static final int range = initWidth * initHeight;
41 @Result private int[] rgb = new int[range];
42
43 public static void run(int[] rgb, int[] pallette, float xoffset, float yoffset, float scale, int gid) {
44 final int width = initWidth;
45 final int height = initHeight;
46 float lx = (((gid % width * scale) - ((scale / 2) * width)) / width) + xoffset;
47 float ly = (((gid / width * scale) - ((scale / 2) * height)) / height) + yoffset;
62
63 void setupPalette(int[] in) {
64 for (int i = 0; i < in.length; i++) {
65 in[i] = i;
66 }
67 }
68
69 @Override
70 public void runTest() {
71 int[] palette = new int[256];
72 setupPalette(palette);
73 /**
74 * Call it for a range, specifying testmethod args (but not the fields it uses or the gid
75 * argument).
76 */
77 dispatchMethodKernel(range, rgb, palette, -1f, 0f, 3f);
78 }
79
80 @Test
81 public void test() {
82 testGeneratedHsail();
83 }
84 }
|
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
23
24 package com.oracle.graal.compiler.hsail.test;
25
26 import com.oracle.graal.compiler.hsail.test.infra.GraalKernelTester;
27 import org.junit.Test;
28 import static org.junit.Assume.*;
29
30 /**
31 * Unit test that simulates the Mandelbrot application. The run method here is a static method
32 * version of the original mandel kernel and the invoke parameters are for the starting point of the
33 * mandel demo. Note: this will likely not pass the junit test on real hardware, but should pass on
34 * the simulator.
35 */
36 public class StaticMandelTest extends GraalKernelTester {
37
38 static final int initWidth = 768;
39 static final int initHeight = initWidth;
40 static final int maxIterations = 64;
41 static final int range = initWidth * initHeight;
42 @Result private int[] rgb = new int[range];
43
44 public static void run(int[] rgb, int[] pallette, float xoffset, float yoffset, float scale, int gid) {
45 final int width = initWidth;
46 final int height = initHeight;
47 float lx = (((gid % width * scale) - ((scale / 2) * width)) / width) + xoffset;
48 float ly = (((gid / width * scale) - ((scale / 2) * height)) / height) + yoffset;
63
64 void setupPalette(int[] in) {
65 for (int i = 0; i < in.length; i++) {
66 in[i] = i;
67 }
68 }
69
70 @Override
71 public void runTest() {
72 int[] palette = new int[256];
73 setupPalette(palette);
74 /**
75 * Call it for a range, specifying testmethod args (but not the fields it uses or the gid
76 * argument).
77 */
78 dispatchMethodKernel(range, rgb, palette, -1f, 0f, 3f);
79 }
80
81 @Test
82 public void test() {
83 assumeTrue(runningOnSimulator());
84 testGeneratedHsail();
85 }
86 }
|