Mercurial > hg > truffle
annotate graal/com.oracle.graal.compiler.ptx.test/src/com/oracle/graal/compiler/ptx/test/BasicPTXTest.java @ 15877:f55153a2ca55
Stop propagating probability above loop header.
author | Thomas Wuerthinger <thomas.wuerthinger@oracle.com> |
---|---|
date | Tue, 13 May 2014 03:57:06 +0200 |
parents | 49db2c1e3bee |
children |
rev | line source |
---|---|
7834
13344e69455e
Added basic PTX test.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1 /* |
8995
585cc62fcdc5
PTX enhancements - arithmetic, control, float, integer math, control and basic switch
Morris Meyer <morris.meyer@oracle.com>
parents:
8959
diff
changeset
|
2 * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. |
7834
13344e69455e
Added basic PTX test.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
13344e69455e
Added basic PTX test.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
4 * |
13344e69455e
Added basic PTX test.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
13344e69455e
Added basic PTX test.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
13344e69455e
Added basic PTX test.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
13344e69455e
Added basic PTX test.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
8 * |
13344e69455e
Added basic PTX test.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
13344e69455e
Added basic PTX test.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
13344e69455e
Added basic PTX test.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
13344e69455e
Added basic PTX test.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
13344e69455e
Added basic PTX test.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
13 * accompanied this code). |
13344e69455e
Added basic PTX test.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
14 * |
13344e69455e
Added basic PTX test.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
13344e69455e
Added basic PTX test.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
13344e69455e
Added basic PTX test.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
13344e69455e
Added basic PTX test.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
18 * |
13344e69455e
Added basic PTX test.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
13344e69455e
Added basic PTX test.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
13344e69455e
Added basic PTX test.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
21 * questions. |
13344e69455e
Added basic PTX test.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
22 */ |
13344e69455e
Added basic PTX test.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
23 package com.oracle.graal.compiler.ptx.test; |
13344e69455e
Added basic PTX test.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
24 |
13819
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13683
diff
changeset
|
25 import static org.junit.Assert.*; |
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13683
diff
changeset
|
26 |
13185
06d9596a909e
refactored all PTX reporting to use PTXTestBase.printReport()
Doug Simon <doug.simon@oracle.com>
parents:
11923
diff
changeset
|
27 import org.junit.*; |
7834
13344e69455e
Added basic PTX test.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
28 |
13344e69455e
Added basic PTX test.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
29 /** |
13344e69455e
Added basic PTX test.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
30 * Test class for small Java methods compiled to PTX kernels. |
13344e69455e
Added basic PTX test.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
31 */ |
13650
1095dcf7f028
reworked PTX unit tests to PTX kernel call wrapper
Doug Simon <doug.simon@oracle.com>
parents:
13185
diff
changeset
|
32 public class BasicPTXTest extends PTXTest { |
7834
13344e69455e
Added basic PTX test.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
33 |
13344e69455e
Added basic PTX test.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
34 @Test |
13650
1095dcf7f028
reworked PTX unit tests to PTX kernel call wrapper
Doug Simon <doug.simon@oracle.com>
parents:
13185
diff
changeset
|
35 public void test() { |
1095dcf7f028
reworked PTX unit tests to PTX kernel call wrapper
Doug Simon <doug.simon@oracle.com>
parents:
13185
diff
changeset
|
36 test("testConstI"); |
9430
147162b27799
GRAAL-234 - PTX code loading
Morris Meyer <morris.meyer@oracle.com>
parents:
9007
diff
changeset
|
37 } |
147162b27799
GRAAL-234 - PTX code loading
Morris Meyer <morris.meyer@oracle.com>
parents:
9007
diff
changeset
|
38 |
11485
49bb1bc983c6
Implement several missing PTX codegen features; return value capture and method args passing of java method executed on GPU.
bharadwaj
parents:
10879
diff
changeset
|
39 public static int testConstI() { |
10577
9c7d9e2c8326
PTX kernel execution - no args or return value
Morris Meyer <morris.meyer@oracle.com>
parents:
9430
diff
changeset
|
40 return 42; |
7834
13344e69455e
Added basic PTX test.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
41 } |
13344e69455e
Added basic PTX test.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
42 |
13650
1095dcf7f028
reworked PTX unit tests to PTX kernel call wrapper
Doug Simon <doug.simon@oracle.com>
parents:
13185
diff
changeset
|
43 @Test |
1095dcf7f028
reworked PTX unit tests to PTX kernel call wrapper
Doug Simon <doug.simon@oracle.com>
parents:
13185
diff
changeset
|
44 public void testStaticIntKernel() { |
1095dcf7f028
reworked PTX unit tests to PTX kernel call wrapper
Doug Simon <doug.simon@oracle.com>
parents:
13185
diff
changeset
|
45 test("staticIntKernel", 'a', 42); |
1095dcf7f028
reworked PTX unit tests to PTX kernel call wrapper
Doug Simon <doug.simon@oracle.com>
parents:
13185
diff
changeset
|
46 } |
1095dcf7f028
reworked PTX unit tests to PTX kernel call wrapper
Doug Simon <doug.simon@oracle.com>
parents:
13185
diff
changeset
|
47 |
13683
de839ec35cc7
schedule lambda method compilation and execution on GPU (PTX) when possible; fix a couple of bugs.
S.Bharadwaj Yadavalli <bharadwaj.yadavalli@oracle.com>
parents:
13650
diff
changeset
|
48 public static int staticIntKernel(char p0, int p1) { |
de839ec35cc7
schedule lambda method compilation and execution on GPU (PTX) when possible; fix a couple of bugs.
S.Bharadwaj Yadavalli <bharadwaj.yadavalli@oracle.com>
parents:
13650
diff
changeset
|
49 return p1 + p0; |
de839ec35cc7
schedule lambda method compilation and execution on GPU (PTX) when possible; fix a couple of bugs.
S.Bharadwaj Yadavalli <bharadwaj.yadavalli@oracle.com>
parents:
13650
diff
changeset
|
50 } |
de839ec35cc7
schedule lambda method compilation and execution on GPU (PTX) when possible; fix a couple of bugs.
S.Bharadwaj Yadavalli <bharadwaj.yadavalli@oracle.com>
parents:
13650
diff
changeset
|
51 |
13650
1095dcf7f028
reworked PTX unit tests to PTX kernel call wrapper
Doug Simon <doug.simon@oracle.com>
parents:
13185
diff
changeset
|
52 @Test |
1095dcf7f028
reworked PTX unit tests to PTX kernel call wrapper
Doug Simon <doug.simon@oracle.com>
parents:
13185
diff
changeset
|
53 public void testVirtualIntKernel() { |
1095dcf7f028
reworked PTX unit tests to PTX kernel call wrapper
Doug Simon <doug.simon@oracle.com>
parents:
13185
diff
changeset
|
54 test("virtualIntKernel", 'a', 42); |
1095dcf7f028
reworked PTX unit tests to PTX kernel call wrapper
Doug Simon <doug.simon@oracle.com>
parents:
13185
diff
changeset
|
55 } |
1095dcf7f028
reworked PTX unit tests to PTX kernel call wrapper
Doug Simon <doug.simon@oracle.com>
parents:
13185
diff
changeset
|
56 |
1095dcf7f028
reworked PTX unit tests to PTX kernel call wrapper
Doug Simon <doug.simon@oracle.com>
parents:
13185
diff
changeset
|
57 public int virtualIntKernel(char p0, int p1) { |
1095dcf7f028
reworked PTX unit tests to PTX kernel call wrapper
Doug Simon <doug.simon@oracle.com>
parents:
13185
diff
changeset
|
58 return p1 + p0; |
1095dcf7f028
reworked PTX unit tests to PTX kernel call wrapper
Doug Simon <doug.simon@oracle.com>
parents:
13185
diff
changeset
|
59 } |
1095dcf7f028
reworked PTX unit tests to PTX kernel call wrapper
Doug Simon <doug.simon@oracle.com>
parents:
13185
diff
changeset
|
60 |
13819
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13683
diff
changeset
|
61 @Test |
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13683
diff
changeset
|
62 public void testGetAvailableProcessors() { |
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13683
diff
changeset
|
63 assertTrue(getPTXBackend().getAvailableProcessors() >= 0); |
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13683
diff
changeset
|
64 } |
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13683
diff
changeset
|
65 |
8463
b2161263e9f2
Cleanup unit tests : they should not print to stdout/stderr
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
8217
diff
changeset
|
66 public static void main(String[] args) { |
13650
1095dcf7f028
reworked PTX unit tests to PTX kernel call wrapper
Doug Simon <doug.simon@oracle.com>
parents:
13185
diff
changeset
|
67 compileAndPrintCode(new BasicPTXTest()); |
8463
b2161263e9f2
Cleanup unit tests : they should not print to stdout/stderr
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
8217
diff
changeset
|
68 } |
7834
13344e69455e
Added basic PTX test.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
69 } |