Mercurial > hg > graal-compiler
annotate graal/com.oracle.graal.compiler.hsail.test.infra/src/com/oracle/graal/compiler/hsail/test/infra/GraalKernelTester.java @ 12429:5124eeec1a7b
split HotSpotRuntime into separate provider implementations
moved HotSpot specific parts of HSAIL into new com.oracle.graal.hotspot.hsail project
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Tue, 15 Oct 2013 14:14:06 +0200 |
parents | 395d34c10e26 |
children | 8577cb721f51 |
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 */ |
12429
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
10769
diff
changeset
|
30 import com.oracle.graal.hotspot.hsail.*; |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
10769
diff
changeset
|
31 |
10662
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
32 import java.lang.reflect.Method; |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
33 import java.io.*; |
12429
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
10769
diff
changeset
|
34 |
10769 | 35 import static com.oracle.graal.phases.GraalOptions.*; |
10662
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
36 |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
37 public abstract class GraalKernelTester extends KernelTester { |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
38 |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
39 HSAILCompilationResult hsailCompResult; |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
40 private boolean showHsailSource = false; |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
41 private boolean saveInFile = false; |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
42 |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
43 @Override |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
44 public String getCompiledHSAILSource(Method testMethod) { |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
45 if (hsailCompResult == null) { |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
46 hsailCompResult = HSAILCompilationResult.getHSAILCompilationResult(testMethod); |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
47 } |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
48 String hsailSource = hsailCompResult.getHSAILCode(); |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
49 if (showHsailSource) { |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
50 logger.severe(hsailSource); |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
51 } |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
52 if (saveInFile) { |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
53 try { |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
54 File fout = File.createTempFile("tmp", ".hsail"); |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
55 logger.fine("creating " + fout.getCanonicalPath()); |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
56 FileWriter fw = new FileWriter(fout); |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
57 BufferedWriter bw = new BufferedWriter(fw); |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
58 bw.write(hsailSource); |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
59 bw.close(); |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
60 } catch (Exception e) { |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
61 e.printStackTrace(); |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
62 } |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
63 } |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
64 return hsailSource; |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
65 } |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
66 |
10769 | 67 public boolean aggressiveInliningEnabled() { |
68 return (InlineEverything.getValue()); | |
69 } | |
70 | |
71 public boolean canHandleHSAILMethodCalls() { | |
72 // needs 2 things, backend needs to be able to generate such calls, and target needs to be | |
73 // able to run them | |
74 boolean canGenerateCalls = false; // not implemented yet | |
75 boolean canExecuteCalls = runningOnSimulator(); | |
76 return (canGenerateCalls && canExecuteCalls); | |
77 } | |
10662
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
78 } |