annotate graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/IntBitwiseNotTest.java @ 15217:ec7d8b646b9f

Truffle: Fixed display of installed code size.
author Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
date Thu, 17 Apr 2014 23:25:42 +0200
parents 64dcb92ee75a
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
12651
c73b857b1be9 Adds support to the HSAIL backend to generate code for bitwise right shift (>>), bitwise NOT (~), and arithmetic negation
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1 /*
c73b857b1be9 Adds support to the HSAIL backend to generate code for bitwise right shift (>>), bitwise NOT (~), and arithmetic negation
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
2 * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
c73b857b1be9 Adds support to the HSAIL backend to generate code for bitwise right shift (>>), bitwise NOT (~), and arithmetic negation
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
c73b857b1be9 Adds support to the HSAIL backend to generate code for bitwise right shift (>>), bitwise NOT (~), and arithmetic negation
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
4 *
c73b857b1be9 Adds support to the HSAIL backend to generate code for bitwise right shift (>>), bitwise NOT (~), and arithmetic negation
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
c73b857b1be9 Adds support to the HSAIL backend to generate code for bitwise right shift (>>), bitwise NOT (~), and arithmetic negation
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
c73b857b1be9 Adds support to the HSAIL backend to generate code for bitwise right shift (>>), bitwise NOT (~), and arithmetic negation
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
7 * published by the Free Software Foundation.
c73b857b1be9 Adds support to the HSAIL backend to generate code for bitwise right shift (>>), bitwise NOT (~), and arithmetic negation
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
8 *
c73b857b1be9 Adds support to the HSAIL backend to generate code for bitwise right shift (>>), bitwise NOT (~), and arithmetic negation
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
c73b857b1be9 Adds support to the HSAIL backend to generate code for bitwise right shift (>>), bitwise NOT (~), and arithmetic negation
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
c73b857b1be9 Adds support to the HSAIL backend to generate code for bitwise right shift (>>), bitwise NOT (~), and arithmetic negation
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
c73b857b1be9 Adds support to the HSAIL backend to generate code for bitwise right shift (>>), bitwise NOT (~), and arithmetic negation
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
c73b857b1be9 Adds support to the HSAIL backend to generate code for bitwise right shift (>>), bitwise NOT (~), and arithmetic negation
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
13 * accompanied this code).
c73b857b1be9 Adds support to the HSAIL backend to generate code for bitwise right shift (>>), bitwise NOT (~), and arithmetic negation
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
14 *
c73b857b1be9 Adds support to the HSAIL backend to generate code for bitwise right shift (>>), bitwise NOT (~), and arithmetic negation
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
c73b857b1be9 Adds support to the HSAIL backend to generate code for bitwise right shift (>>), bitwise NOT (~), and arithmetic negation
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
c73b857b1be9 Adds support to the HSAIL backend to generate code for bitwise right shift (>>), bitwise NOT (~), and arithmetic negation
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
c73b857b1be9 Adds support to the HSAIL backend to generate code for bitwise right shift (>>), bitwise NOT (~), and arithmetic negation
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
18 *
c73b857b1be9 Adds support to the HSAIL backend to generate code for bitwise right shift (>>), bitwise NOT (~), and arithmetic negation
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c73b857b1be9 Adds support to the HSAIL backend to generate code for bitwise right shift (>>), bitwise NOT (~), and arithmetic negation
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
c73b857b1be9 Adds support to the HSAIL backend to generate code for bitwise right shift (>>), bitwise NOT (~), and arithmetic negation
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
21 * questions.
c73b857b1be9 Adds support to the HSAIL backend to generate code for bitwise right shift (>>), bitwise NOT (~), and arithmetic negation
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
22 */
c73b857b1be9 Adds support to the HSAIL backend to generate code for bitwise right shift (>>), bitwise NOT (~), and arithmetic negation
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
23
c73b857b1be9 Adds support to the HSAIL backend to generate code for bitwise right shift (>>), bitwise NOT (~), and arithmetic negation
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
24 package com.oracle.graal.compiler.hsail.test;
c73b857b1be9 Adds support to the HSAIL backend to generate code for bitwise right shift (>>), bitwise NOT (~), and arithmetic negation
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
25
14991
64dcb92ee75a Truffle: Change signature for Truffle calls from (PackedFrame, Arguments) to (Object[]).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 12651
diff changeset
26 import org.junit.*;
64dcb92ee75a Truffle: Change signature for Truffle calls from (PackedFrame, Arguments) to (Object[]).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 12651
diff changeset
27
12651
c73b857b1be9 Adds support to the HSAIL backend to generate code for bitwise right shift (>>), bitwise NOT (~), and arithmetic negation
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
28 import com.oracle.graal.compiler.hsail.test.infra.*;
c73b857b1be9 Adds support to the HSAIL backend to generate code for bitwise right shift (>>), bitwise NOT (~), and arithmetic negation
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
29
c73b857b1be9 Adds support to the HSAIL backend to generate code for bitwise right shift (>>), bitwise NOT (~), and arithmetic negation
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
30 /**
c73b857b1be9 Adds support to the HSAIL backend to generate code for bitwise right shift (>>), bitwise NOT (~), and arithmetic negation
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
31 * Tests bitwise not of an integer.
c73b857b1be9 Adds support to the HSAIL backend to generate code for bitwise right shift (>>), bitwise NOT (~), and arithmetic negation
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
32 */
c73b857b1be9 Adds support to the HSAIL backend to generate code for bitwise right shift (>>), bitwise NOT (~), and arithmetic negation
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
33 public class IntBitwiseNotTest extends GraalKernelTester {
c73b857b1be9 Adds support to the HSAIL backend to generate code for bitwise right shift (>>), bitwise NOT (~), and arithmetic negation
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
34
c73b857b1be9 Adds support to the HSAIL backend to generate code for bitwise right shift (>>), bitwise NOT (~), and arithmetic negation
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
35 static final int num = 20;
c73b857b1be9 Adds support to the HSAIL backend to generate code for bitwise right shift (>>), bitwise NOT (~), and arithmetic negation
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
36 // Output array storing the results of the operations.
c73b857b1be9 Adds support to the HSAIL backend to generate code for bitwise right shift (>>), bitwise NOT (~), and arithmetic negation
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
37 @Result protected int[] outArray = new int[num];
c73b857b1be9 Adds support to the HSAIL backend to generate code for bitwise right shift (>>), bitwise NOT (~), and arithmetic negation
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
38
c73b857b1be9 Adds support to the HSAIL backend to generate code for bitwise right shift (>>), bitwise NOT (~), and arithmetic negation
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
39 /**
c73b857b1be9 Adds support to the HSAIL backend to generate code for bitwise right shift (>>), bitwise NOT (~), and arithmetic negation
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
40 * The static "kernel" method we will be testing. This method performs a bitwise not operation
c73b857b1be9 Adds support to the HSAIL backend to generate code for bitwise right shift (>>), bitwise NOT (~), and arithmetic negation
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
41 * on an element of an input array and writes the result to the corresponding index of an output
c73b857b1be9 Adds support to the HSAIL backend to generate code for bitwise right shift (>>), bitwise NOT (~), and arithmetic negation
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
42 * array. By convention the gid is the last parameter.
c73b857b1be9 Adds support to the HSAIL backend to generate code for bitwise right shift (>>), bitwise NOT (~), and arithmetic negation
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
43 *
c73b857b1be9 Adds support to the HSAIL backend to generate code for bitwise right shift (>>), bitwise NOT (~), and arithmetic negation
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
44 * @param out the output array
c73b857b1be9 Adds support to the HSAIL backend to generate code for bitwise right shift (>>), bitwise NOT (~), and arithmetic negation
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
45 * @param ina the input array
c73b857b1be9 Adds support to the HSAIL backend to generate code for bitwise right shift (>>), bitwise NOT (~), and arithmetic negation
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
46 * @param gid the parameter used to index into the input and output arrays
c73b857b1be9 Adds support to the HSAIL backend to generate code for bitwise right shift (>>), bitwise NOT (~), and arithmetic negation
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
47 */
c73b857b1be9 Adds support to the HSAIL backend to generate code for bitwise right shift (>>), bitwise NOT (~), and arithmetic negation
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
48 public static void run(int[] out, int[] ina, int gid) {
c73b857b1be9 Adds support to the HSAIL backend to generate code for bitwise right shift (>>), bitwise NOT (~), and arithmetic negation
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
49 out[gid] = ~(ina[gid]);
c73b857b1be9 Adds support to the HSAIL backend to generate code for bitwise right shift (>>), bitwise NOT (~), and arithmetic negation
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
50 }
c73b857b1be9 Adds support to the HSAIL backend to generate code for bitwise right shift (>>), bitwise NOT (~), and arithmetic negation
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
51
c73b857b1be9 Adds support to the HSAIL backend to generate code for bitwise right shift (>>), bitwise NOT (~), and arithmetic negation
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
52 /**
c73b857b1be9 Adds support to the HSAIL backend to generate code for bitwise right shift (>>), bitwise NOT (~), and arithmetic negation
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
53 * Tests the HSAIL code generated for this unit test by comparing the result of executing this
c73b857b1be9 Adds support to the HSAIL backend to generate code for bitwise right shift (>>), bitwise NOT (~), and arithmetic negation
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
54 * code with the result of executing a sequential Java version of this unit test.
c73b857b1be9 Adds support to the HSAIL backend to generate code for bitwise right shift (>>), bitwise NOT (~), and arithmetic negation
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
55 */
c73b857b1be9 Adds support to the HSAIL backend to generate code for bitwise right shift (>>), bitwise NOT (~), and arithmetic negation
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
56 @Test
c73b857b1be9 Adds support to the HSAIL backend to generate code for bitwise right shift (>>), bitwise NOT (~), and arithmetic negation
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
57 public void test() {
c73b857b1be9 Adds support to the HSAIL backend to generate code for bitwise right shift (>>), bitwise NOT (~), and arithmetic negation
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
58 super.testGeneratedHsail();
c73b857b1be9 Adds support to the HSAIL backend to generate code for bitwise right shift (>>), bitwise NOT (~), and arithmetic negation
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
59 }
c73b857b1be9 Adds support to the HSAIL backend to generate code for bitwise right shift (>>), bitwise NOT (~), and arithmetic negation
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
60
c73b857b1be9 Adds support to the HSAIL backend to generate code for bitwise right shift (>>), bitwise NOT (~), and arithmetic negation
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
61 /**
c73b857b1be9 Adds support to the HSAIL backend to generate code for bitwise right shift (>>), bitwise NOT (~), and arithmetic negation
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
62 * Initializes the input and output arrays passed to the run routine.
c73b857b1be9 Adds support to the HSAIL backend to generate code for bitwise right shift (>>), bitwise NOT (~), and arithmetic negation
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
63 *
c73b857b1be9 Adds support to the HSAIL backend to generate code for bitwise right shift (>>), bitwise NOT (~), and arithmetic negation
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
64 * @param in the input array
c73b857b1be9 Adds support to the HSAIL backend to generate code for bitwise right shift (>>), bitwise NOT (~), and arithmetic negation
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
65 */
c73b857b1be9 Adds support to the HSAIL backend to generate code for bitwise right shift (>>), bitwise NOT (~), and arithmetic negation
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
66 void setupArrays(int[] in) {
c73b857b1be9 Adds support to the HSAIL backend to generate code for bitwise right shift (>>), bitwise NOT (~), and arithmetic negation
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
67 for (int i = 0; i < num; i++) {
c73b857b1be9 Adds support to the HSAIL backend to generate code for bitwise right shift (>>), bitwise NOT (~), and arithmetic negation
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
68 in[i] = i < num / 2 ? i : -i;
c73b857b1be9 Adds support to the HSAIL backend to generate code for bitwise right shift (>>), bitwise NOT (~), and arithmetic negation
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
69 outArray[i] = 0;
c73b857b1be9 Adds support to the HSAIL backend to generate code for bitwise right shift (>>), bitwise NOT (~), and arithmetic negation
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
70 }
c73b857b1be9 Adds support to the HSAIL backend to generate code for bitwise right shift (>>), bitwise NOT (~), and arithmetic negation
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
71 }
c73b857b1be9 Adds support to the HSAIL backend to generate code for bitwise right shift (>>), bitwise NOT (~), and arithmetic negation
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
72
c73b857b1be9 Adds support to the HSAIL backend to generate code for bitwise right shift (>>), bitwise NOT (~), and arithmetic negation
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
73 /**
c73b857b1be9 Adds support to the HSAIL backend to generate code for bitwise right shift (>>), bitwise NOT (~), and arithmetic negation
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
74 * Dispatches the HSAIL kernel for this test case.
c73b857b1be9 Adds support to the HSAIL backend to generate code for bitwise right shift (>>), bitwise NOT (~), and arithmetic negation
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
75 */
c73b857b1be9 Adds support to the HSAIL backend to generate code for bitwise right shift (>>), bitwise NOT (~), and arithmetic negation
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
76 @Override
c73b857b1be9 Adds support to the HSAIL backend to generate code for bitwise right shift (>>), bitwise NOT (~), and arithmetic negation
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
77 public void runTest() {
c73b857b1be9 Adds support to the HSAIL backend to generate code for bitwise right shift (>>), bitwise NOT (~), and arithmetic negation
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
78 int[] inArray = new int[num];
c73b857b1be9 Adds support to the HSAIL backend to generate code for bitwise right shift (>>), bitwise NOT (~), and arithmetic negation
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
79 setupArrays(inArray);
c73b857b1be9 Adds support to the HSAIL backend to generate code for bitwise right shift (>>), bitwise NOT (~), and arithmetic negation
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
80 dispatchMethodKernel(num, outArray, inArray);
c73b857b1be9 Adds support to the HSAIL backend to generate code for bitwise right shift (>>), bitwise NOT (~), and arithmetic negation
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
81 }
c73b857b1be9 Adds support to the HSAIL backend to generate code for bitwise right shift (>>), bitwise NOT (~), and arithmetic negation
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
82 }