Mercurial > hg > graal-compiler
annotate graal/com.oracle.graal.compiler.hsail.test.infra/src/com/oracle/graal/compiler/hsail/test/infra/GraalKernelTester.java @ 15482:a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Contributed-by: Tom Deneau <tom.deneau@amd.com>
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Fri, 02 May 2014 21:58:28 +0200 |
parents | d90e5c22ba55 |
children | 66d31e70bd79 |
rev | line source |
---|---|
10662
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1 /* |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
2 * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved. |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
4 * |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
8 * |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
13 * accompanied this code). |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
14 * |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
18 * |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
21 * questions. |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
22 */ |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
23 |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
24 package com.oracle.graal.compiler.hsail.test.infra; |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
25 |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
26 /** |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
27 * This class extends KernelTester and provides a base class |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
28 * for which the HSAIL code comes from the Graal compiler. |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
29 */ |
15259
d90e5c22ba55
Move GraalOptions to graal.compiler.common.
Josef Eisl <josef.eisl@jku.at>
parents:
15193
diff
changeset
|
30 import static com.oracle.graal.compiler.common.GraalOptions.*; |
13784
219a84093dda
moved HSAIL compilation harness logic into HSAILHotSpotBackend and deleted HSAILCompilationResult
Doug Simon <doug.simon@oracle.com>
parents:
13105
diff
changeset
|
31 import static com.oracle.graal.hotspot.HotSpotGraalRuntime.*; |
14991
64dcb92ee75a
Truffle: Change signature for Truffle calls from (PackedFrame, Arguments) to (Object[]).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
14969
diff
changeset
|
32 import static org.junit.Assume.*; |
12429
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
10769
diff
changeset
|
33 |
10662
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
34 import java.io.*; |
12697
8577cb721f51
use scoped option overriding for some HSAIL tests
Doug Simon <doug.simon@oracle.com>
parents:
12429
diff
changeset
|
35 import java.lang.reflect.*; |
12429
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
10769
diff
changeset
|
36 |
13784
219a84093dda
moved HSAIL compilation harness logic into HSAILHotSpotBackend and deleted HSAILCompilationResult
Doug Simon <doug.simon@oracle.com>
parents:
13105
diff
changeset
|
37 import org.junit.*; |
219a84093dda
moved HSAIL compilation harness logic into HSAILHotSpotBackend and deleted HSAILCompilationResult
Doug Simon <doug.simon@oracle.com>
parents:
13105
diff
changeset
|
38 |
12743
f1a55428a8d7
more HSAIL support in the C++ layer for executing HSAIL code on the simulator
Doug Simon <doug.simon@oracle.com>
parents:
12697
diff
changeset
|
39 import com.oracle.graal.api.code.*; |
13784
219a84093dda
moved HSAIL compilation harness logic into HSAILHotSpotBackend and deleted HSAILCompilationResult
Doug Simon <doug.simon@oracle.com>
parents:
13105
diff
changeset
|
40 import com.oracle.graal.api.meta.*; |
15193
96bb07a5d667
Spit up and move GraalInternalError.
Josef Eisl <josef.eisl@jku.at>
parents:
15079
diff
changeset
|
41 import com.oracle.graal.compiler.common.*; |
13784
219a84093dda
moved HSAIL compilation harness logic into HSAILHotSpotBackend and deleted HSAILCompilationResult
Doug Simon <doug.simon@oracle.com>
parents:
13105
diff
changeset
|
42 import com.oracle.graal.compiler.target.*; |
12743
f1a55428a8d7
more HSAIL support in the C++ layer for executing HSAIL code on the simulator
Doug Simon <doug.simon@oracle.com>
parents:
12697
diff
changeset
|
43 import com.oracle.graal.debug.*; |
14768
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13819
diff
changeset
|
44 import com.oracle.graal.gpu.*; |
12697
8577cb721f51
use scoped option overriding for some HSAIL tests
Doug Simon <doug.simon@oracle.com>
parents:
12429
diff
changeset
|
45 import com.oracle.graal.hotspot.hsail.*; |
12743
f1a55428a8d7
more HSAIL support in the C++ layer for executing HSAIL code on the simulator
Doug Simon <doug.simon@oracle.com>
parents:
12697
diff
changeset
|
46 import com.oracle.graal.hotspot.meta.*; |
13784
219a84093dda
moved HSAIL compilation harness logic into HSAILHotSpotBackend and deleted HSAILCompilationResult
Doug Simon <doug.simon@oracle.com>
parents:
13105
diff
changeset
|
47 import com.oracle.graal.hsail.*; |
12697
8577cb721f51
use scoped option overriding for some HSAIL tests
Doug Simon <doug.simon@oracle.com>
parents:
12429
diff
changeset
|
48 import com.oracle.graal.options.*; |
13784
219a84093dda
moved HSAIL compilation harness logic into HSAILHotSpotBackend and deleted HSAILCompilationResult
Doug Simon <doug.simon@oracle.com>
parents:
13105
diff
changeset
|
49 import com.oracle.graal.options.OptionValue.OverrideScope; |
12756
70b138d008ff
HSAIL: used scoped option overriding for all GraalKernelTester based tests
Doug Simon <doug.simon@oracle.com>
parents:
12744
diff
changeset
|
50 |
10662
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
51 public abstract class GraalKernelTester extends KernelTester { |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
52 |
15482
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15259
diff
changeset
|
53 private static boolean substitutionsInstalled; |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15259
diff
changeset
|
54 |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15259
diff
changeset
|
55 private static synchronized void installSubstitutions() { |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15259
diff
changeset
|
56 if (!substitutionsInstalled) { |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15259
diff
changeset
|
57 getHSAILBackend().getProviders().getReplacements().registerSubstitutions(ForceDeoptSubstitutions.class); |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15259
diff
changeset
|
58 substitutionsInstalled = true; |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15259
diff
changeset
|
59 } |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15259
diff
changeset
|
60 } |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15259
diff
changeset
|
61 |
13819
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13784
diff
changeset
|
62 public GraalKernelTester() { |
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13784
diff
changeset
|
63 super(getHSAILBackend().isDeviceInitialized()); |
15482
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15259
diff
changeset
|
64 installSubstitutions(); |
13819
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13784
diff
changeset
|
65 } |
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13784
diff
changeset
|
66 |
14969
a6c144380ce7
HSAIL: added UseHSAILDeoptimization VM option for disabling HSAIL deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14768
diff
changeset
|
67 protected static HSAILHotSpotBackend getHSAILBackend() { |
13784
219a84093dda
moved HSAIL compilation harness logic into HSAILHotSpotBackend and deleted HSAILCompilationResult
Doug Simon <doug.simon@oracle.com>
parents:
13105
diff
changeset
|
68 Backend backend = runtime().getBackend(HSAIL.class); |
219a84093dda
moved HSAIL compilation harness logic into HSAILHotSpotBackend and deleted HSAILCompilationResult
Doug Simon <doug.simon@oracle.com>
parents:
13105
diff
changeset
|
69 Assume.assumeTrue(backend instanceof HSAILHotSpotBackend); |
219a84093dda
moved HSAIL compilation harness logic into HSAILHotSpotBackend and deleted HSAILCompilationResult
Doug Simon <doug.simon@oracle.com>
parents:
13105
diff
changeset
|
70 return (HSAILHotSpotBackend) backend; |
219a84093dda
moved HSAIL compilation harness logic into HSAILHotSpotBackend and deleted HSAILCompilationResult
Doug Simon <doug.simon@oracle.com>
parents:
13105
diff
changeset
|
71 } |
219a84093dda
moved HSAIL compilation harness logic into HSAILHotSpotBackend and deleted HSAILCompilationResult
Doug Simon <doug.simon@oracle.com>
parents:
13105
diff
changeset
|
72 |
219a84093dda
moved HSAIL compilation harness logic into HSAILHotSpotBackend and deleted HSAILCompilationResult
Doug Simon <doug.simon@oracle.com>
parents:
13105
diff
changeset
|
73 ExternalCompilationResult hsailCode; |
10662
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
74 private boolean showHsailSource = false; |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
75 private boolean saveInFile = false; |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
76 |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
77 @Override |
12743
f1a55428a8d7
more HSAIL support in the C++ layer for executing HSAIL code on the simulator
Doug Simon <doug.simon@oracle.com>
parents:
12697
diff
changeset
|
78 public String getCompiledHSAILSource(Method method) { |
13784
219a84093dda
moved HSAIL compilation harness logic into HSAILHotSpotBackend and deleted HSAILCompilationResult
Doug Simon <doug.simon@oracle.com>
parents:
13105
diff
changeset
|
79 if (hsailCode == null) { |
219a84093dda
moved HSAIL compilation harness logic into HSAILHotSpotBackend and deleted HSAILCompilationResult
Doug Simon <doug.simon@oracle.com>
parents:
13105
diff
changeset
|
80 HSAILHotSpotBackend backend = getHSAILBackend(); |
219a84093dda
moved HSAIL compilation harness logic into HSAILHotSpotBackend and deleted HSAILCompilationResult
Doug Simon <doug.simon@oracle.com>
parents:
13105
diff
changeset
|
81 ResolvedJavaMethod javaMethod = backend.getProviders().getMetaAccess().lookupJavaMethod(method); |
219a84093dda
moved HSAIL compilation harness logic into HSAILHotSpotBackend and deleted HSAILCompilationResult
Doug Simon <doug.simon@oracle.com>
parents:
13105
diff
changeset
|
82 hsailCode = backend.compileKernel(javaMethod, false); |
10662
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
83 } |
13784
219a84093dda
moved HSAIL compilation harness logic into HSAILHotSpotBackend and deleted HSAILCompilationResult
Doug Simon <doug.simon@oracle.com>
parents:
13105
diff
changeset
|
84 String hsailSource = hsailCode.getCodeString(); |
10662
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
85 if (showHsailSource) { |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
86 logger.severe(hsailSource); |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
87 } |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
88 if (saveInFile) { |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
89 try { |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
90 File fout = File.createTempFile("tmp", ".hsail"); |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
91 logger.fine("creating " + fout.getCanonicalPath()); |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
92 FileWriter fw = new FileWriter(fout); |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
93 BufferedWriter bw = new BufferedWriter(fw); |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
94 bw.write(hsailSource); |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
95 bw.close(); |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
96 } catch (Exception e) { |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
97 e.printStackTrace(); |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
98 } |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
99 } |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
100 return hsailSource; |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
101 } |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
102 |
10769 | 103 public boolean aggressiveInliningEnabled() { |
104 return (InlineEverything.getValue()); | |
105 } | |
106 | |
107 public boolean canHandleHSAILMethodCalls() { | |
108 // needs 2 things, backend needs to be able to generate such calls, and target needs to be | |
109 // able to run them | |
110 boolean canGenerateCalls = false; // not implemented yet | |
111 boolean canExecuteCalls = runningOnSimulator(); | |
112 return (canGenerateCalls && canExecuteCalls); | |
113 } | |
12697
8577cb721f51
use scoped option overriding for some HSAIL tests
Doug Simon <doug.simon@oracle.com>
parents:
12429
diff
changeset
|
114 |
15079
976c6cb2bf69
HSAIL: added tests using Java8 lambdas
Doug Simon <doug.simon@oracle.com>
parents:
15066
diff
changeset
|
115 private static boolean supportsObjectAllocation() { |
976c6cb2bf69
HSAIL: added tests using Java8 lambdas
Doug Simon <doug.simon@oracle.com>
parents:
15066
diff
changeset
|
116 return true; |
976c6cb2bf69
HSAIL: added tests using Java8 lambdas
Doug Simon <doug.simon@oracle.com>
parents:
15066
diff
changeset
|
117 } |
976c6cb2bf69
HSAIL: added tests using Java8 lambdas
Doug Simon <doug.simon@oracle.com>
parents:
15066
diff
changeset
|
118 |
976c6cb2bf69
HSAIL: added tests using Java8 lambdas
Doug Simon <doug.simon@oracle.com>
parents:
15066
diff
changeset
|
119 /** |
976c6cb2bf69
HSAIL: added tests using Java8 lambdas
Doug Simon <doug.simon@oracle.com>
parents:
15066
diff
changeset
|
120 * Determines if the runtime supports object allocation in HSAIL code. |
976c6cb2bf69
HSAIL: added tests using Java8 lambdas
Doug Simon <doug.simon@oracle.com>
parents:
15066
diff
changeset
|
121 */ |
15066
2cae21d9f122
HSAIL: initial support for object allocation in HSAIL kernels
Doug Simon <doug.simon@oracle.com>
parents:
15040
diff
changeset
|
122 public boolean canHandleObjectAllocation() { |
15079
976c6cb2bf69
HSAIL: added tests using Java8 lambdas
Doug Simon <doug.simon@oracle.com>
parents:
15066
diff
changeset
|
123 return supportsObjectAllocation() && canDeoptimize(); |
976c6cb2bf69
HSAIL: added tests using Java8 lambdas
Doug Simon <doug.simon@oracle.com>
parents:
15066
diff
changeset
|
124 } |
976c6cb2bf69
HSAIL: added tests using Java8 lambdas
Doug Simon <doug.simon@oracle.com>
parents:
15066
diff
changeset
|
125 |
976c6cb2bf69
HSAIL: added tests using Java8 lambdas
Doug Simon <doug.simon@oracle.com>
parents:
15066
diff
changeset
|
126 /** |
976c6cb2bf69
HSAIL: added tests using Java8 lambdas
Doug Simon <doug.simon@oracle.com>
parents:
15066
diff
changeset
|
127 * Determines if the runtime supports deoptimization in HSAIL code. |
976c6cb2bf69
HSAIL: added tests using Java8 lambdas
Doug Simon <doug.simon@oracle.com>
parents:
15066
diff
changeset
|
128 */ |
976c6cb2bf69
HSAIL: added tests using Java8 lambdas
Doug Simon <doug.simon@oracle.com>
parents:
15066
diff
changeset
|
129 public boolean canDeoptimize() { |
976c6cb2bf69
HSAIL: added tests using Java8 lambdas
Doug Simon <doug.simon@oracle.com>
parents:
15066
diff
changeset
|
130 return getHSAILBackend().getRuntime().getConfig().useHSAILDeoptimization; |
976c6cb2bf69
HSAIL: added tests using Java8 lambdas
Doug Simon <doug.simon@oracle.com>
parents:
15066
diff
changeset
|
131 } |
976c6cb2bf69
HSAIL: added tests using Java8 lambdas
Doug Simon <doug.simon@oracle.com>
parents:
15066
diff
changeset
|
132 |
976c6cb2bf69
HSAIL: added tests using Java8 lambdas
Doug Simon <doug.simon@oracle.com>
parents:
15066
diff
changeset
|
133 /** |
976c6cb2bf69
HSAIL: added tests using Java8 lambdas
Doug Simon <doug.simon@oracle.com>
parents:
15066
diff
changeset
|
134 * Determines if the runtime supports {@link VirtualObject}s in {@link DebugInfo} associated |
976c6cb2bf69
HSAIL: added tests using Java8 lambdas
Doug Simon <doug.simon@oracle.com>
parents:
15066
diff
changeset
|
135 * with HSAIL code. |
976c6cb2bf69
HSAIL: added tests using Java8 lambdas
Doug Simon <doug.simon@oracle.com>
parents:
15066
diff
changeset
|
136 */ |
976c6cb2bf69
HSAIL: added tests using Java8 lambdas
Doug Simon <doug.simon@oracle.com>
parents:
15066
diff
changeset
|
137 public boolean canHandleDeoptVirtualObjects() { |
976c6cb2bf69
HSAIL: added tests using Java8 lambdas
Doug Simon <doug.simon@oracle.com>
parents:
15066
diff
changeset
|
138 return false; |
976c6cb2bf69
HSAIL: added tests using Java8 lambdas
Doug Simon <doug.simon@oracle.com>
parents:
15066
diff
changeset
|
139 } |
976c6cb2bf69
HSAIL: added tests using Java8 lambdas
Doug Simon <doug.simon@oracle.com>
parents:
15066
diff
changeset
|
140 |
976c6cb2bf69
HSAIL: added tests using Java8 lambdas
Doug Simon <doug.simon@oracle.com>
parents:
15066
diff
changeset
|
141 /** |
976c6cb2bf69
HSAIL: added tests using Java8 lambdas
Doug Simon <doug.simon@oracle.com>
parents:
15066
diff
changeset
|
142 * Determines if the runtime supports {@link StackSlot}s in {@link DebugInfo} associated with |
976c6cb2bf69
HSAIL: added tests using Java8 lambdas
Doug Simon <doug.simon@oracle.com>
parents:
15066
diff
changeset
|
143 * HSAIL code. |
976c6cb2bf69
HSAIL: added tests using Java8 lambdas
Doug Simon <doug.simon@oracle.com>
parents:
15066
diff
changeset
|
144 */ |
976c6cb2bf69
HSAIL: added tests using Java8 lambdas
Doug Simon <doug.simon@oracle.com>
parents:
15066
diff
changeset
|
145 public boolean canHandleDeoptStackSlots() { |
976c6cb2bf69
HSAIL: added tests using Java8 lambdas
Doug Simon <doug.simon@oracle.com>
parents:
15066
diff
changeset
|
146 return false; |
15066
2cae21d9f122
HSAIL: initial support for object allocation in HSAIL kernels
Doug Simon <doug.simon@oracle.com>
parents:
15040
diff
changeset
|
147 } |
2cae21d9f122
HSAIL: initial support for object allocation in HSAIL kernels
Doug Simon <doug.simon@oracle.com>
parents:
15040
diff
changeset
|
148 |
14969
a6c144380ce7
HSAIL: added UseHSAILDeoptimization VM option for disabling HSAIL deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14768
diff
changeset
|
149 /** |
a6c144380ce7
HSAIL: added UseHSAILDeoptimization VM option for disabling HSAIL deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14768
diff
changeset
|
150 * Determines if the runtime has the capabilities required by this test. |
a6c144380ce7
HSAIL: added UseHSAILDeoptimization VM option for disabling HSAIL deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14768
diff
changeset
|
151 */ |
a6c144380ce7
HSAIL: added UseHSAILDeoptimization VM option for disabling HSAIL deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14768
diff
changeset
|
152 protected boolean supportsRequiredCapabilities() { |
a6c144380ce7
HSAIL: added UseHSAILDeoptimization VM option for disabling HSAIL deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14768
diff
changeset
|
153 return true; |
a6c144380ce7
HSAIL: added UseHSAILDeoptimization VM option for disabling HSAIL deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14768
diff
changeset
|
154 } |
a6c144380ce7
HSAIL: added UseHSAILDeoptimization VM option for disabling HSAIL deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14768
diff
changeset
|
155 |
12743
f1a55428a8d7
more HSAIL support in the C++ layer for executing HSAIL code on the simulator
Doug Simon <doug.simon@oracle.com>
parents:
12697
diff
changeset
|
156 @Override |
13105
d3fc35a43376
HSAIL: addressed issues in JUnit tests
Doug Simon <doug.simon@oracle.com>
parents:
12756
diff
changeset
|
157 protected void dispatchKernelOkra(int range, Object... args) { |
13784
219a84093dda
moved HSAIL compilation harness logic into HSAILHotSpotBackend and deleted HSAILCompilationResult
Doug Simon <doug.simon@oracle.com>
parents:
13105
diff
changeset
|
158 HSAILHotSpotBackend backend = getHSAILBackend(); |
13819
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13784
diff
changeset
|
159 if (backend.isDeviceInitialized()) { |
12743
f1a55428a8d7
more HSAIL support in the C++ layer for executing HSAIL code on the simulator
Doug Simon <doug.simon@oracle.com>
parents:
12697
diff
changeset
|
160 try { |
13819
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13784
diff
changeset
|
161 HotSpotNmethod code = backend.compileAndInstallKernel(testMethod); |
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13784
diff
changeset
|
162 backend.executeKernel(code, range, args); |
12743
f1a55428a8d7
more HSAIL support in the C++ layer for executing HSAIL code on the simulator
Doug Simon <doug.simon@oracle.com>
parents:
12697
diff
changeset
|
163 } catch (InvalidInstalledCodeException e) { |
f1a55428a8d7
more HSAIL support in the C++ layer for executing HSAIL code on the simulator
Doug Simon <doug.simon@oracle.com>
parents:
12697
diff
changeset
|
164 Debug.log("WARNING:Invalid installed code: " + e); |
f1a55428a8d7
more HSAIL support in the C++ layer for executing HSAIL code on the simulator
Doug Simon <doug.simon@oracle.com>
parents:
12697
diff
changeset
|
165 e.printStackTrace(); |
f1a55428a8d7
more HSAIL support in the C++ layer for executing HSAIL code on the simulator
Doug Simon <doug.simon@oracle.com>
parents:
12697
diff
changeset
|
166 } |
12744
41f0bd213b51
make 'mx unittest' still pass even if HSAIL device is not available
Doug Simon <doug.simon@oracle.com>
parents:
12743
diff
changeset
|
167 } else { |
13105
d3fc35a43376
HSAIL: addressed issues in JUnit tests
Doug Simon <doug.simon@oracle.com>
parents:
12756
diff
changeset
|
168 super.dispatchKernelOkra(range, args); |
12743
f1a55428a8d7
more HSAIL support in the C++ layer for executing HSAIL code on the simulator
Doug Simon <doug.simon@oracle.com>
parents:
12697
diff
changeset
|
169 } |
f1a55428a8d7
more HSAIL support in the C++ layer for executing HSAIL code on the simulator
Doug Simon <doug.simon@oracle.com>
parents:
12697
diff
changeset
|
170 } |
f1a55428a8d7
more HSAIL support in the C++ layer for executing HSAIL code on the simulator
Doug Simon <doug.simon@oracle.com>
parents:
12697
diff
changeset
|
171 |
15040
288c23143d47
Fix most raw type references.
Josef Eisl <josef.eisl@jku.at>
parents:
14991
diff
changeset
|
172 public static OptionValue<?> getOptionFromField(Class<?> declaringClass, String fieldName) { |
12697
8577cb721f51
use scoped option overriding for some HSAIL tests
Doug Simon <doug.simon@oracle.com>
parents:
12429
diff
changeset
|
173 try { |
8577cb721f51
use scoped option overriding for some HSAIL tests
Doug Simon <doug.simon@oracle.com>
parents:
12429
diff
changeset
|
174 Field f = declaringClass.getDeclaredField(fieldName); |
8577cb721f51
use scoped option overriding for some HSAIL tests
Doug Simon <doug.simon@oracle.com>
parents:
12429
diff
changeset
|
175 f.setAccessible(true); |
8577cb721f51
use scoped option overriding for some HSAIL tests
Doug Simon <doug.simon@oracle.com>
parents:
12429
diff
changeset
|
176 return (OptionValue<?>) f.get(null); |
8577cb721f51
use scoped option overriding for some HSAIL tests
Doug Simon <doug.simon@oracle.com>
parents:
12429
diff
changeset
|
177 } catch (Exception e) { |
8577cb721f51
use scoped option overriding for some HSAIL tests
Doug Simon <doug.simon@oracle.com>
parents:
12429
diff
changeset
|
178 throw new GraalInternalError(e); |
8577cb721f51
use scoped option overriding for some HSAIL tests
Doug Simon <doug.simon@oracle.com>
parents:
12429
diff
changeset
|
179 } |
8577cb721f51
use scoped option overriding for some HSAIL tests
Doug Simon <doug.simon@oracle.com>
parents:
12429
diff
changeset
|
180 } |
12756
70b138d008ff
HSAIL: used scoped option overriding for all GraalKernelTester based tests
Doug Simon <doug.simon@oracle.com>
parents:
12744
diff
changeset
|
181 |
70b138d008ff
HSAIL: used scoped option overriding for all GraalKernelTester based tests
Doug Simon <doug.simon@oracle.com>
parents:
12744
diff
changeset
|
182 private OptionValue<?> accessibleRemoveNeverExecutedCode = getOptionFromField(GraalOptions.class, "RemoveNeverExecutedCode"); |
70b138d008ff
HSAIL: used scoped option overriding for all GraalKernelTester based tests
Doug Simon <doug.simon@oracle.com>
parents:
12744
diff
changeset
|
183 |
70b138d008ff
HSAIL: used scoped option overriding for all GraalKernelTester based tests
Doug Simon <doug.simon@oracle.com>
parents:
12744
diff
changeset
|
184 // Special overrides for the testGeneratedxxx routines which set |
70b138d008ff
HSAIL: used scoped option overriding for all GraalKernelTester based tests
Doug Simon <doug.simon@oracle.com>
parents:
12744
diff
changeset
|
185 // required graal options that we need to run any junit test |
14768
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13819
diff
changeset
|
186 |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13819
diff
changeset
|
187 private OverrideScope getOverrideScope() { |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13819
diff
changeset
|
188 return OptionValue.override(GraalOptions.InlineEverything, true, accessibleRemoveNeverExecutedCode, false); |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13819
diff
changeset
|
189 } |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13819
diff
changeset
|
190 |
12756
70b138d008ff
HSAIL: used scoped option overriding for all GraalKernelTester based tests
Doug Simon <doug.simon@oracle.com>
parents:
12744
diff
changeset
|
191 @Override |
70b138d008ff
HSAIL: used scoped option overriding for all GraalKernelTester based tests
Doug Simon <doug.simon@oracle.com>
parents:
12744
diff
changeset
|
192 public void testGeneratedHsail() { |
14768
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13819
diff
changeset
|
193 try (OverrideScope s = getOverrideScope()) { |
14969
a6c144380ce7
HSAIL: added UseHSAILDeoptimization VM option for disabling HSAIL deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14768
diff
changeset
|
194 assumeTrue(supportsRequiredCapabilities()); |
12756
70b138d008ff
HSAIL: used scoped option overriding for all GraalKernelTester based tests
Doug Simon <doug.simon@oracle.com>
parents:
12744
diff
changeset
|
195 super.testGeneratedHsail(); |
70b138d008ff
HSAIL: used scoped option overriding for all GraalKernelTester based tests
Doug Simon <doug.simon@oracle.com>
parents:
12744
diff
changeset
|
196 } |
70b138d008ff
HSAIL: used scoped option overriding for all GraalKernelTester based tests
Doug Simon <doug.simon@oracle.com>
parents:
12744
diff
changeset
|
197 } |
70b138d008ff
HSAIL: used scoped option overriding for all GraalKernelTester based tests
Doug Simon <doug.simon@oracle.com>
parents:
12744
diff
changeset
|
198 |
70b138d008ff
HSAIL: used scoped option overriding for all GraalKernelTester based tests
Doug Simon <doug.simon@oracle.com>
parents:
12744
diff
changeset
|
199 @Override |
70b138d008ff
HSAIL: used scoped option overriding for all GraalKernelTester based tests
Doug Simon <doug.simon@oracle.com>
parents:
12744
diff
changeset
|
200 public void testGeneratedHsailUsingLambdaMethod() { |
14768
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13819
diff
changeset
|
201 try (OverrideScope s = getOverrideScope()) { |
15066
2cae21d9f122
HSAIL: initial support for object allocation in HSAIL kernels
Doug Simon <doug.simon@oracle.com>
parents:
15040
diff
changeset
|
202 assumeTrue(supportsRequiredCapabilities()); |
12756
70b138d008ff
HSAIL: used scoped option overriding for all GraalKernelTester based tests
Doug Simon <doug.simon@oracle.com>
parents:
12744
diff
changeset
|
203 super.testGeneratedHsailUsingLambdaMethod(); |
70b138d008ff
HSAIL: used scoped option overriding for all GraalKernelTester based tests
Doug Simon <doug.simon@oracle.com>
parents:
12744
diff
changeset
|
204 } |
70b138d008ff
HSAIL: used scoped option overriding for all GraalKernelTester based tests
Doug Simon <doug.simon@oracle.com>
parents:
12744
diff
changeset
|
205 } |
15482
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15259
diff
changeset
|
206 |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15259
diff
changeset
|
207 // used for forcing a deoptimization |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15259
diff
changeset
|
208 public static int forceDeopt(int x) { |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15259
diff
changeset
|
209 return x * x; |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15259
diff
changeset
|
210 } |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15259
diff
changeset
|
211 |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15259
diff
changeset
|
212 public static double forceDeopt(double x) { |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15259
diff
changeset
|
213 return x * x; |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15259
diff
changeset
|
214 } |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15259
diff
changeset
|
215 |
10662
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
216 } |