Mercurial > hg > graal-compiler
annotate src/gpu/hsail/vm/gpu_hsail.cpp @ 14868:3efd4d8ace0b
Merge
author | Erik Eckstein <erik.eckstein@oracle.com> |
---|---|
date | Fri, 28 Mar 2014 09:05:22 +0100 |
parents | 3e9a960f0da1 |
children | a6c144380ce7 |
rev | line source |
---|---|
12743
f1a55428a8d7
more HSAIL support in the C++ layer for executing HSAIL code on the simulator
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1 /* |
f1a55428a8d7
more HSAIL support in the C++ layer for executing HSAIL code on the simulator
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
2 * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. |
f1a55428a8d7
more HSAIL support in the C++ layer for executing HSAIL code on the simulator
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
f1a55428a8d7
more HSAIL support in the C++ layer for executing HSAIL code on the simulator
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
4 * |
f1a55428a8d7
more HSAIL support in the C++ layer for executing HSAIL code on the simulator
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
f1a55428a8d7
more HSAIL support in the C++ layer for executing HSAIL code on the simulator
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
f1a55428a8d7
more HSAIL support in the C++ layer for executing HSAIL code on the simulator
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
f1a55428a8d7
more HSAIL support in the C++ layer for executing HSAIL code on the simulator
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
8 * |
f1a55428a8d7
more HSAIL support in the C++ layer for executing HSAIL code on the simulator
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
f1a55428a8d7
more HSAIL support in the C++ layer for executing HSAIL code on the simulator
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
f1a55428a8d7
more HSAIL support in the C++ layer for executing HSAIL code on the simulator
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
f1a55428a8d7
more HSAIL support in the C++ layer for executing HSAIL code on the simulator
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
f1a55428a8d7
more HSAIL support in the C++ layer for executing HSAIL code on the simulator
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
13 * accompanied this code). |
f1a55428a8d7
more HSAIL support in the C++ layer for executing HSAIL code on the simulator
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
14 * |
f1a55428a8d7
more HSAIL support in the C++ layer for executing HSAIL code on the simulator
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
f1a55428a8d7
more HSAIL support in the C++ layer for executing HSAIL code on the simulator
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
f1a55428a8d7
more HSAIL support in the C++ layer for executing HSAIL code on the simulator
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
f1a55428a8d7
more HSAIL support in the C++ layer for executing HSAIL code on the simulator
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
18 * |
f1a55428a8d7
more HSAIL support in the C++ layer for executing HSAIL code on the simulator
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f1a55428a8d7
more HSAIL support in the C++ layer for executing HSAIL code on the simulator
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
f1a55428a8d7
more HSAIL support in the C++ layer for executing HSAIL code on the simulator
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
21 * questions. |
f1a55428a8d7
more HSAIL support in the C++ layer for executing HSAIL code on the simulator
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
22 * |
f1a55428a8d7
more HSAIL support in the C++ layer for executing HSAIL code on the simulator
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
23 */ |
f1a55428a8d7
more HSAIL support in the C++ layer for executing HSAIL code on the simulator
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
24 |
f1a55428a8d7
more HSAIL support in the C++ layer for executing HSAIL code on the simulator
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
25 #include "precompiled.hpp" |
f1a55428a8d7
more HSAIL support in the C++ layer for executing HSAIL code on the simulator
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
26 #include "runtime/javaCalls.hpp" |
f1a55428a8d7
more HSAIL support in the C++ layer for executing HSAIL code on the simulator
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
27 #include "runtime/gpu.hpp" |
14768
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
28 #include "runtime/deoptimization.hpp" |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
29 #include "gpu_hsail.hpp" |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
30 #include "utilities/debug.hpp" |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
31 #include "utilities/exceptions.hpp" |
13888
51584f76462d
pulled Ptx and Hsail classes out of gpu class namespace
Doug Simon <doug.simon@oracle.com>
parents:
13826
diff
changeset
|
32 #include "hsail/vm/gpu_hsail.hpp" |
12743
f1a55428a8d7
more HSAIL support in the C++ layer for executing HSAIL code on the simulator
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
33 #include "utilities/globalDefinitions.hpp" |
f1a55428a8d7
more HSAIL support in the C++ layer for executing HSAIL code on the simulator
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
34 #include "utilities/ostream.hpp" |
13819
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13740
diff
changeset
|
35 #include "graal/graalEnv.hpp" |
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13740
diff
changeset
|
36 #include "graal/graalCompiler.hpp" |
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13740
diff
changeset
|
37 #include "graal/graalJavaAccess.hpp" |
12743
f1a55428a8d7
more HSAIL support in the C++ layer for executing HSAIL code on the simulator
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
38 #include "hsailKernelArguments.hpp" |
14768
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
39 #include "hsailJavaCallArguments.hpp" |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
40 #include "code/pcDesc.hpp" |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
41 #include "code/scopeDesc.hpp" |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
42 #include "graal/graalVMToCompiler.hpp" |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
43 #include "gpu_hsail_Frame.hpp" |
12743
f1a55428a8d7
more HSAIL support in the C++ layer for executing HSAIL code on the simulator
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
44 |
13819
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13740
diff
changeset
|
45 // Entry to GPU native method implementation that transitions current thread to '_thread_in_vm'. |
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13740
diff
changeset
|
46 #define GPU_VMENTRY(result_type, name, signature) \ |
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13740
diff
changeset
|
47 JNIEXPORT result_type JNICALL name signature { \ |
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13740
diff
changeset
|
48 GRAAL_VM_ENTRY_MARK; \ |
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13740
diff
changeset
|
49 |
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13740
diff
changeset
|
50 // Entry to GPU native method implementation that calls a JNI function |
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13740
diff
changeset
|
51 // and hence cannot transition current thread to '_thread_in_vm'. |
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13740
diff
changeset
|
52 #define GPU_ENTRY(result_type, name, signature) \ |
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13740
diff
changeset
|
53 JNIEXPORT result_type JNICALL name signature { \ |
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13740
diff
changeset
|
54 |
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13740
diff
changeset
|
55 #define GPU_END } |
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13740
diff
changeset
|
56 |
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13740
diff
changeset
|
57 #define CC (char*) /*cast a literal from (const char*)*/ |
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13740
diff
changeset
|
58 #define FN_PTR(f) CAST_FROM_FN_PTR(void*, &(f)) |
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13740
diff
changeset
|
59 |
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13740
diff
changeset
|
60 #define OBJECT "Ljava/lang/Object;" |
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13740
diff
changeset
|
61 #define STRING "Ljava/lang/String;" |
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13740
diff
changeset
|
62 #define HS_INSTALLED_CODE "Lcom/oracle/graal/hotspot/meta/HotSpotInstalledCode;" |
14768
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
63 #define HS_COMPILED_NMETHOD "Lcom/oracle/graal/hotspot/HotSpotCompiledNmethod;" |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
64 #define HS_NMETHOD "Lcom/oracle/graal/hotspot/meta/HotSpotNmethod;" |
13819
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13740
diff
changeset
|
65 |
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13740
diff
changeset
|
66 // public native void executeKernel(HotSpotNmethod kernel, int jobSize, int i, int j, Object[] args) throws InvalidInstalledCodeException; |
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13740
diff
changeset
|
67 |
13888
51584f76462d
pulled Ptx and Hsail classes out of gpu class namespace
Doug Simon <doug.simon@oracle.com>
parents:
13826
diff
changeset
|
68 JNINativeMethod Hsail::HSAIL_methods[] = { |
51584f76462d
pulled Ptx and Hsail classes out of gpu class namespace
Doug Simon <doug.simon@oracle.com>
parents:
13826
diff
changeset
|
69 {CC"initialize", CC"()Z", FN_PTR(Hsail::initialize)}, |
51584f76462d
pulled Ptx and Hsail classes out of gpu class namespace
Doug Simon <doug.simon@oracle.com>
parents:
13826
diff
changeset
|
70 {CC"generateKernel", CC"([B" STRING ")J", FN_PTR(Hsail::generate_kernel)}, |
14768
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
71 {CC"executeKernel0", CC"("HS_INSTALLED_CODE"I["OBJECT"["OBJECT")Z", FN_PTR(Hsail::execute_kernel_void_1d)}, |
13819
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13740
diff
changeset
|
72 }; |
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13740
diff
changeset
|
73 |
13888
51584f76462d
pulled Ptx and Hsail classes out of gpu class namespace
Doug Simon <doug.simon@oracle.com>
parents:
13826
diff
changeset
|
74 void * Hsail::_device_context = NULL; |
12743
f1a55428a8d7
more HSAIL support in the C++ layer for executing HSAIL code on the simulator
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
75 |
13888
51584f76462d
pulled Ptx and Hsail classes out of gpu class namespace
Doug Simon <doug.simon@oracle.com>
parents:
13826
diff
changeset
|
76 Hsail::okra_create_context_func_t Hsail::_okra_create_context; |
51584f76462d
pulled Ptx and Hsail classes out of gpu class namespace
Doug Simon <doug.simon@oracle.com>
parents:
13826
diff
changeset
|
77 Hsail::okra_create_kernel_func_t Hsail::_okra_create_kernel; |
51584f76462d
pulled Ptx and Hsail classes out of gpu class namespace
Doug Simon <doug.simon@oracle.com>
parents:
13826
diff
changeset
|
78 Hsail::okra_push_object_func_t Hsail::_okra_push_object; |
51584f76462d
pulled Ptx and Hsail classes out of gpu class namespace
Doug Simon <doug.simon@oracle.com>
parents:
13826
diff
changeset
|
79 Hsail::okra_push_boolean_func_t Hsail::_okra_push_boolean; |
51584f76462d
pulled Ptx and Hsail classes out of gpu class namespace
Doug Simon <doug.simon@oracle.com>
parents:
13826
diff
changeset
|
80 Hsail::okra_push_byte_func_t Hsail::_okra_push_byte; |
51584f76462d
pulled Ptx and Hsail classes out of gpu class namespace
Doug Simon <doug.simon@oracle.com>
parents:
13826
diff
changeset
|
81 Hsail::okra_push_double_func_t Hsail::_okra_push_double; |
51584f76462d
pulled Ptx and Hsail classes out of gpu class namespace
Doug Simon <doug.simon@oracle.com>
parents:
13826
diff
changeset
|
82 Hsail::okra_push_float_func_t Hsail::_okra_push_float; |
51584f76462d
pulled Ptx and Hsail classes out of gpu class namespace
Doug Simon <doug.simon@oracle.com>
parents:
13826
diff
changeset
|
83 Hsail::okra_push_int_func_t Hsail::_okra_push_int; |
51584f76462d
pulled Ptx and Hsail classes out of gpu class namespace
Doug Simon <doug.simon@oracle.com>
parents:
13826
diff
changeset
|
84 Hsail::okra_push_long_func_t Hsail::_okra_push_long; |
51584f76462d
pulled Ptx and Hsail classes out of gpu class namespace
Doug Simon <doug.simon@oracle.com>
parents:
13826
diff
changeset
|
85 Hsail::okra_execute_with_range_func_t Hsail::_okra_execute_with_range; |
51584f76462d
pulled Ptx and Hsail classes out of gpu class namespace
Doug Simon <doug.simon@oracle.com>
parents:
13826
diff
changeset
|
86 Hsail::okra_clearargs_func_t Hsail::_okra_clearargs; |
51584f76462d
pulled Ptx and Hsail classes out of gpu class namespace
Doug Simon <doug.simon@oracle.com>
parents:
13826
diff
changeset
|
87 Hsail::okra_register_heap_func_t Hsail::_okra_register_heap; |
12743
f1a55428a8d7
more HSAIL support in the C++ layer for executing HSAIL code on the simulator
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
88 |
f1a55428a8d7
more HSAIL support in the C++ layer for executing HSAIL code on the simulator
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
89 |
13888
51584f76462d
pulled Ptx and Hsail classes out of gpu class namespace
Doug Simon <doug.simon@oracle.com>
parents:
13826
diff
changeset
|
90 void Hsail::register_heap() { |
12743
f1a55428a8d7
more HSAIL support in the C++ layer for executing HSAIL code on the simulator
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
91 // After the okra functions are set up and the heap is initialized, register the java heap with HSA |
f1a55428a8d7
more HSAIL support in the C++ layer for executing HSAIL code on the simulator
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
92 guarantee(Universe::heap() != NULL, "heap should be there by now."); |
f1a55428a8d7
more HSAIL support in the C++ layer for executing HSAIL code on the simulator
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
93 if (TraceGPUInteraction) { |
f1a55428a8d7
more HSAIL support in the C++ layer for executing HSAIL code on the simulator
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
94 tty->print_cr("[HSAIL] heap=" PTR_FORMAT, Universe::heap()); |
f1a55428a8d7
more HSAIL support in the C++ layer for executing HSAIL code on the simulator
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
95 tty->print_cr("[HSAIL] base=0x%08x, capacity=%ld", Universe::heap()->base(), Universe::heap()->capacity()); |
f1a55428a8d7
more HSAIL support in the C++ layer for executing HSAIL code on the simulator
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
96 } |
f1a55428a8d7
more HSAIL support in the C++ layer for executing HSAIL code on the simulator
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
97 _okra_register_heap(Universe::heap()->base(), Universe::heap()->capacity()); |
f1a55428a8d7
more HSAIL support in the C++ layer for executing HSAIL code on the simulator
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
98 } |
f1a55428a8d7
more HSAIL support in the C++ layer for executing HSAIL code on the simulator
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
99 |
14768
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
100 GPU_VMENTRY(jboolean, Hsail::execute_kernel_void_1d, (JNIEnv* env, jclass, jobject kernel_handle, jint dimX, jobject args_handle, jobject oops_save_handle)) |
13819
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13740
diff
changeset
|
101 |
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13740
diff
changeset
|
102 ResourceMark rm; |
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13740
diff
changeset
|
103 jlong nmethodValue = HotSpotInstalledCode::codeBlob(kernel_handle); |
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13740
diff
changeset
|
104 if (nmethodValue == 0) { |
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13740
diff
changeset
|
105 SharedRuntime::throw_and_post_jvmti_exception(JavaThread::current(), vmSymbols::com_oracle_graal_api_code_InvalidInstalledCodeException(), NULL); |
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13740
diff
changeset
|
106 } |
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13740
diff
changeset
|
107 nmethod* nm = (nmethod*) (address) nmethodValue; |
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13740
diff
changeset
|
108 methodHandle mh = nm->method(); |
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13740
diff
changeset
|
109 Symbol* signature = mh->signature(); |
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13740
diff
changeset
|
110 |
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13740
diff
changeset
|
111 void* kernel = (void*) HotSpotInstalledCode::codeStart(kernel_handle); |
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13740
diff
changeset
|
112 if (kernel == NULL) { |
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13740
diff
changeset
|
113 SharedRuntime::throw_and_post_jvmti_exception(JavaThread::current(), vmSymbols::com_oracle_graal_api_code_InvalidInstalledCodeException(), NULL); |
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13740
diff
changeset
|
114 } |
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13740
diff
changeset
|
115 |
14768
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
116 return execute_kernel_void_1d_internal((address) kernel, dimX, args_handle, mh, nm, oops_save_handle, CHECK_0); |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
117 GPU_END |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
118 |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
119 static void showRanges(jboolean *a, int len) { |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
120 // show ranges |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
121 bool lookFor = true; |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
122 for (int i = 0; i < len; i++) { |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
123 if ((lookFor == true) && (a[i] != 0)) { |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
124 tty->print("%d", i); |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
125 lookFor = false; |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
126 } else if ((lookFor == false) && (a[i] == 0)) { |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
127 tty->print_cr("-%d", i-1); |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
128 lookFor = true; |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
129 } |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
130 } |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
131 if (lookFor == false) { |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
132 tty->print_cr("-%d", len-1); |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
133 } |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
134 } |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
135 |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
136 |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
137 // for experimentation |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
138 static bool useDeoptInfo = true; |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
139 |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
140 jboolean Hsail::execute_kernel_void_1d_internal(address kernel, int dimX, jobject args_handle, methodHandle& mh, nmethod *nm, jobject oops_save_handle, TRAPS) { |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
141 |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
142 ResourceMark rm(THREAD); |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
143 objArrayOop argsArray = (objArrayOop) JNIHandles::resolve(args_handle); |
12743
f1a55428a8d7
more HSAIL support in the C++ layer for executing HSAIL code on the simulator
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
144 |
f1a55428a8d7
more HSAIL support in the C++ layer for executing HSAIL code on the simulator
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
145 // Reset the kernel arguments |
f1a55428a8d7
more HSAIL support in the C++ layer for executing HSAIL code on the simulator
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
146 _okra_clearargs(kernel); |
f1a55428a8d7
more HSAIL support in the C++ layer for executing HSAIL code on the simulator
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
147 |
14768
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
148 |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
149 HSAILDeoptimizationInfo* e; |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
150 if (useDeoptInfo) { |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
151 e = new (ResourceObj::C_HEAP, mtInternal) HSAILDeoptimizationInfo(); |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
152 e->set_never_ran_array(NEW_C_HEAP_ARRAY(jboolean, dimX, mtInternal)); |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
153 memset(e->never_ran_array(), 0, dimX * sizeof(jboolean)); |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
154 } |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
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:
diff
changeset
|
156 // This object sets up the kernel arguments |
14768
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
157 HSAILKernelArguments hka((address) kernel, mh->signature(), argsArray, mh->is_static(), e); |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
158 |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
159 // if any object passed was null, throw an exception here |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
160 // doing this means the kernel code can avoid null checks on the object parameters. |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
161 if (hka.getFirstNullParameterIndex() >= 0) { |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
162 char buf[64]; |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
163 sprintf(buf, "Null Kernel Parameter seen, Parameter Index: %d", hka.getFirstNullParameterIndex()); |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
164 JavaThread* thread = (JavaThread*)THREAD; |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
165 thread->set_gpu_exception_bci(0); |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
166 thread->set_gpu_exception_method(mh()); |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
167 THROW_MSG_0(vmSymbols::java_lang_NullPointerException(), buf); |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
168 } |
12743
f1a55428a8d7
more HSAIL support in the C++ layer for executing HSAIL code on the simulator
Doug Simon <doug.simon@oracle.com>
parents:
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:
diff
changeset
|
170 // Run the kernel |
14768
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
171 bool success = _okra_execute_with_range(kernel, dimX); |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
172 // check if any workitem requested a deopt |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
173 // currently we only support at most one such workitem |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
174 |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
175 |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
176 int deoptcode = e->deopt_occurred(); |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
177 if (useDeoptInfo && deoptcode != 0) { |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
178 if (deoptcode != 1) { |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
179 // error condition detected in deopt code |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
180 char msg[200]; |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
181 sprintf(msg, "deopt error detected, slot for workitem %d was not empty", -1*(deoptcode + 1)); |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
182 guarantee(deoptcode == 1, msg); |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
183 } |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
184 if (TraceGPUInteraction) { |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
185 tty->print_cr("deopt happened."); |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
186 HSAILKernelDeoptimization * pdeopt = &e->_deopt_save_states[0]; |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
187 tty->print_cr("first deopter was workitem %d", pdeopt->workitem()); |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
188 } |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
189 |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
190 // Before handling any deopting workitems, save the pointers from |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
191 // the hsail frames in oops_save so they get adjusted by any |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
192 // GC. Need to do this before leaving thread_in_vm mode. |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
193 // resolve handle only needed once here (not exiting vm mode) |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
194 objArrayOop oopsSaveArray = (objArrayOop) JNIHandles::resolve(oops_save_handle); |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
195 |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
196 // since slots are allocated from the beginning, we know how far to look |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
197 assert(e->num_deopts() < MAX_DEOPT_SAVE_STATES_SIZE, "deopt save state overflow"); |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
198 for (int k = 0; k < e->num_deopts(); k++) { |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
199 HSAILKernelDeoptimization * pdeopt = &e->_deopt_save_states[k]; |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
200 jint workitem = pdeopt->workitem(); |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
201 if (workitem != -1) { |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
202 // this is a workitem that deopted |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
203 HSAILFrame *hsailFrame = pdeopt->first_frame(); |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
204 int dregOopMap = hsailFrame->dreg_oops_map(); |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
205 for (int bit = 0; bit < 16; bit++) { |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
206 if ((dregOopMap & (1 << bit)) != 0) { |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
207 // the dregister at this bit is an oop, save it in the array |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
208 int index = k * 16 + bit; |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
209 void* saved_oop = (void*) hsailFrame->get_d_reg(bit); |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
210 oopsSaveArray->obj_at_put(index, (oop) saved_oop); |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
211 } |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
212 } |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
213 } |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
214 } |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
215 |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
216 // Handle any deopting workitems. |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
217 int count_deoptimized = 0; |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
218 for (int k = 0; k < e->num_deopts(); k++) { |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
219 HSAILKernelDeoptimization * pdeopt = &e->_deopt_save_states[k]; |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
220 |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
221 jint workitem = pdeopt->workitem(); |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
222 if (workitem != -1) { |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
223 int deoptId = pdeopt->pc_offset(); |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
224 HSAILFrame *hsailFrame = pdeopt->first_frame(); |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
225 |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
226 // update the hsailFrame from the oopsSaveArray |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
227 // re-resolve the handle |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
228 oopsSaveArray = (objArrayOop) JNIHandles::resolve(oops_save_handle); |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
229 |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
230 int dregOopMap = hsailFrame->dreg_oops_map(); |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
231 for (int bit = 0; bit < 16; bit++) { |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
232 if ((dregOopMap & (1 << bit)) != 0) { |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
233 // the dregister at this bit is an oop, retrieve it from array and put back in frame |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
234 int index = k * 16 + bit; |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
235 void * dregValue = (void *) oopsSaveArray->obj_at(index); |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
236 void * oldDregValue = (void *) hsailFrame->get_d_reg(bit); |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
237 assert((oldDregValue != 0 ? dregValue != 0 : dregValue == 0) , "bad dregValue retrieved"); |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
238 if (TraceGPUInteraction) { |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
239 if (dregValue != oldDregValue) { |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
240 tty->print_cr("oop moved for $d%d, workitem %d, slot %d, old=%p, new=%p", bit, workitem, k, oldDregValue, dregValue); |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
241 } |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
242 } |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
243 hsailFrame->put_d_reg(bit, (jlong) dregValue); |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
244 } |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
245 } |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
246 |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
247 JavaValue result(T_VOID); |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
248 JavaCallArguments javaArgs; |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
249 javaArgs.set_alternative_target(nm); |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
250 javaArgs.push_int(deoptId); |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
251 javaArgs.push_long((jlong) hsailFrame); |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
252 |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
253 // override the deoptimization action with Action_none until we decide |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
254 // how to handle the other actions. |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
255 int myActionReason = Deoptimization::make_trap_request(Deoptimization::trap_request_reason(pdeopt->reason()), Deoptimization::Action_none); |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
256 javaArgs.push_int(myActionReason); |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
257 javaArgs.push_oop((oop)NULL); |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
258 if (TraceGPUInteraction) { |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
259 int dregOopMap = hsailFrame->dreg_oops_map(); |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
260 tty->print_cr("[HSAIL] Deoptimizing to host for workitem=%d (slot=%d) with deoptId=%d, frame=" INTPTR_FORMAT ", actionAndReason=%d, dregOopMap=%04x", workitem, k, deoptId, hsailFrame, myActionReason, dregOopMap); |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
261 // show the registers containing references |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
262 for (int bit = 0; bit < 16; bit++) { |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
263 if ((dregOopMap & (1 << bit)) != 0) { |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
264 tty->print_cr(" oop $d%d = %p", bit, hsailFrame->get_d_reg(bit)); |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
265 } |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
266 } |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
267 } |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
268 JavaCalls::call(&result, mh, &javaArgs, THREAD); |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
269 count_deoptimized++; |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
270 } |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
271 } |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
272 if (TraceGPUInteraction) { |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
273 tty->print_cr("[HSAIL] Deoptimizing to host completed for %d workitems", count_deoptimized); |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
274 } |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
275 |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
276 // Handle any never_ran workitems if there were any |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
277 int count_never_ran = 0; |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
278 bool handleNeverRansHere = true; |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
279 // turn off verbose trace stuff for javacall arg setup |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
280 bool savedTraceGPUInteraction = TraceGPUInteraction; |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
281 TraceGPUInteraction = false; |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
282 jboolean *never_ran_array = e->never_ran_array(); |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
283 if (handleNeverRansHere) { |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
284 for (int k = 0; k < dimX; k++) { |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
285 if (never_ran_array[k]) { |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
286 // run it as a javaCall |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
287 KlassHandle methKlass = mh->method_holder(); |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
288 Thread* THREAD = Thread::current(); |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
289 JavaValue result(T_VOID); |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
290 JavaCallArguments javaArgs; |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
291 // re-resolve the args_handle here |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
292 objArrayOop resolvedArgsArray = (objArrayOop) JNIHandles::resolve(args_handle); |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
293 // This object sets up the javaCall arguments |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
294 // the way argsArray is set up, this should work for instance methods as well |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
295 // (the receiver will be the first oop pushed) |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
296 HSAILJavaCallArguments hjca(&javaArgs, k, mh->signature(), resolvedArgsArray, mh->is_static()); |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
297 if (mh->is_static()) { |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
298 JavaCalls::call_static(&result, methKlass, mh->name(), mh->signature(), &javaArgs, THREAD); |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
299 } else { |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
300 JavaCalls::call_virtual(&result, methKlass, mh->name(), mh->signature(), &javaArgs, THREAD); |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
301 } |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
302 count_never_ran++; |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
303 } |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
304 } |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
305 TraceGPUInteraction = savedTraceGPUInteraction; |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
306 if (TraceGPUInteraction) { |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
307 tty->print_cr("%d workitems never ran, have been run via JavaCall", count_never_ran); |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
308 showRanges(never_ran_array, dimX); |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
309 } |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
310 } // end of never-ran handling |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
311 |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
312 } |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
313 |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
314 if (useDeoptInfo) { |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
315 FREE_C_HEAP_ARRAY(jboolean, e->never_ran_array(), mtInternal); |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
316 delete e; |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
317 } |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
318 return success; |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
319 } |
12743
f1a55428a8d7
more HSAIL support in the C++ layer for executing HSAIL code on the simulator
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
320 |
13888
51584f76462d
pulled Ptx and Hsail classes out of gpu class namespace
Doug Simon <doug.simon@oracle.com>
parents:
13826
diff
changeset
|
321 GPU_ENTRY(jlong, Hsail::generate_kernel, (JNIEnv *env, jclass, jbyteArray code_handle, jstring name_handle)) |
13819
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13740
diff
changeset
|
322 guarantee(_okra_create_kernel != NULL, "[HSAIL] Okra not linked"); |
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13740
diff
changeset
|
323 ResourceMark rm; |
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13740
diff
changeset
|
324 jsize name_len = env->GetStringLength(name_handle); |
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13740
diff
changeset
|
325 jsize code_len = env->GetArrayLength(code_handle); |
12743
f1a55428a8d7
more HSAIL support in the C++ layer for executing HSAIL code on the simulator
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
326 |
13819
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13740
diff
changeset
|
327 char* name = NEW_RESOURCE_ARRAY(char, name_len + 1); |
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13740
diff
changeset
|
328 unsigned char *code = NEW_RESOURCE_ARRAY(unsigned char, code_len + 1); |
13740
bfd61161d752
HSAIL: support for using Okra simulator without needing to configure PATH and LD_LIBRARY_PATH
Doug Simon <doug.simon@oracle.com>
parents:
13112
diff
changeset
|
329 |
13819
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13740
diff
changeset
|
330 code[code_len] = 0; |
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13740
diff
changeset
|
331 name[name_len] = 0; |
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13740
diff
changeset
|
332 |
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13740
diff
changeset
|
333 env->GetByteArrayRegion(code_handle, 0, code_len, (jbyte*) code); |
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13740
diff
changeset
|
334 env->GetStringUTFRegion(name_handle, 0, name_len, name); |
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13740
diff
changeset
|
335 |
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13740
diff
changeset
|
336 register_heap(); |
12743
f1a55428a8d7
more HSAIL support in the C++ layer for executing HSAIL code on the simulator
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
337 |
f1a55428a8d7
more HSAIL support in the C++ layer for executing HSAIL code on the simulator
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
338 // The kernel entrypoint is always run for the time being |
f1a55428a8d7
more HSAIL support in the C++ layer for executing HSAIL code on the simulator
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
339 const char* entryPointName = "&run"; |
f1a55428a8d7
more HSAIL support in the C++ layer for executing HSAIL code on the simulator
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
340 |
13112
166ed1584f30
HSAIL: null checks when loading Okra library functions
Doug Simon <doug.simon@oracle.com>
parents:
13097
diff
changeset
|
341 _device_context = _okra_create_context(); |
12743
f1a55428a8d7
more HSAIL support in the C++ layer for executing HSAIL code on the simulator
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
342 |
13819
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13740
diff
changeset
|
343 return (jlong) _okra_create_kernel(_device_context, code, entryPointName); |
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13740
diff
changeset
|
344 GPU_END |
12743
f1a55428a8d7
more HSAIL support in the C++ layer for executing HSAIL code on the simulator
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
345 |
f1a55428a8d7
more HSAIL support in the C++ layer for executing HSAIL code on the simulator
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
346 #if defined(LINUX) |
13822
35fc64972250
fixed Linux compile error and removed name of not-yet-existing Windows Okra dll
Doug Simon <doug.simon@oracle.com>
parents:
13819
diff
changeset
|
347 static const char* okra_library_name = "libokra_x86_64.so"; |
13826
62bd4705894c
reverted removal of Okra Windows DLL name
Doug Simon <doug.simon@oracle.com>
parents:
13822
diff
changeset
|
348 #elif defined(_WINDOWS) |
62bd4705894c
reverted removal of Okra Windows DLL name
Doug Simon <doug.simon@oracle.com>
parents:
13822
diff
changeset
|
349 static char const* okra_library_name = "okra_x86_64.dll"; |
12743
f1a55428a8d7
more HSAIL support in the C++ layer for executing HSAIL code on the simulator
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
350 #else |
13822
35fc64972250
fixed Linux compile error and removed name of not-yet-existing Windows Okra dll
Doug Simon <doug.simon@oracle.com>
parents:
13819
diff
changeset
|
351 static char const* okra_library_name = NULL; |
12743
f1a55428a8d7
more HSAIL support in the C++ layer for executing HSAIL code on the simulator
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
352 #endif |
f1a55428a8d7
more HSAIL support in the C++ layer for executing HSAIL code on the simulator
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
353 |
13112
166ed1584f30
HSAIL: null checks when loading Okra library functions
Doug Simon <doug.simon@oracle.com>
parents:
13097
diff
changeset
|
354 #define STRINGIFY(x) #x |
166ed1584f30
HSAIL: null checks when loading Okra library functions
Doug Simon <doug.simon@oracle.com>
parents:
13097
diff
changeset
|
355 |
166ed1584f30
HSAIL: null checks when loading Okra library functions
Doug Simon <doug.simon@oracle.com>
parents:
13097
diff
changeset
|
356 #define LOOKUP_OKRA_FUNCTION(name, alias) \ |
166ed1584f30
HSAIL: null checks when loading Okra library functions
Doug Simon <doug.simon@oracle.com>
parents:
13097
diff
changeset
|
357 _##alias = \ |
166ed1584f30
HSAIL: null checks when loading Okra library functions
Doug Simon <doug.simon@oracle.com>
parents:
13097
diff
changeset
|
358 CAST_TO_FN_PTR(alias##_func_t, os::dll_lookup(handle, STRINGIFY(name))); \ |
166ed1584f30
HSAIL: null checks when loading Okra library functions
Doug Simon <doug.simon@oracle.com>
parents:
13097
diff
changeset
|
359 if (_##alias == NULL) { \ |
166ed1584f30
HSAIL: null checks when loading Okra library functions
Doug Simon <doug.simon@oracle.com>
parents:
13097
diff
changeset
|
360 tty->print_cr("[HSAIL] ***** Error: Failed to lookup %s in %s, wrong version of OKRA?", STRINGIFY(name), okra_library_name); \ |
13819
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13740
diff
changeset
|
361 return false; \ |
13112
166ed1584f30
HSAIL: null checks when loading Okra library functions
Doug Simon <doug.simon@oracle.com>
parents:
13097
diff
changeset
|
362 } \ |
166ed1584f30
HSAIL: null checks when loading Okra library functions
Doug Simon <doug.simon@oracle.com>
parents:
13097
diff
changeset
|
363 |
13888
51584f76462d
pulled Ptx and Hsail classes out of gpu class namespace
Doug Simon <doug.simon@oracle.com>
parents:
13826
diff
changeset
|
364 GPU_ENTRY(jboolean, Hsail::initialize, (JNIEnv *env, jclass)) |
13740
bfd61161d752
HSAIL: support for using Okra simulator without needing to configure PATH and LD_LIBRARY_PATH
Doug Simon <doug.simon@oracle.com>
parents:
13112
diff
changeset
|
365 if (okra_library_name == NULL) { |
13097 | 366 if (TraceGPUInteraction) { |
367 tty->print_cr("Unsupported HSAIL platform"); | |
368 } | |
12743
f1a55428a8d7
more HSAIL support in the C++ layer for executing HSAIL code on the simulator
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
369 return false; |
f1a55428a8d7
more HSAIL support in the C++ layer for executing HSAIL code on the simulator
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
370 } |
13740
bfd61161d752
HSAIL: support for using Okra simulator without needing to configure PATH and LD_LIBRARY_PATH
Doug Simon <doug.simon@oracle.com>
parents:
13112
diff
changeset
|
371 |
bfd61161d752
HSAIL: support for using Okra simulator without needing to configure PATH and LD_LIBRARY_PATH
Doug Simon <doug.simon@oracle.com>
parents:
13112
diff
changeset
|
372 // here we know we have a valid okra_library_name to try to load |
13819
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13740
diff
changeset
|
373 char ebuf[O_BUFLEN]; |
13097 | 374 if (TraceGPUInteraction) { |
13740
bfd61161d752
HSAIL: support for using Okra simulator without needing to configure PATH and LD_LIBRARY_PATH
Doug Simon <doug.simon@oracle.com>
parents:
13112
diff
changeset
|
375 tty->print_cr("[HSAIL] library is %s", okra_library_name); |
bfd61161d752
HSAIL: support for using Okra simulator without needing to configure PATH and LD_LIBRARY_PATH
Doug Simon <doug.simon@oracle.com>
parents:
13112
diff
changeset
|
376 } |
14768
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
377 |
13819
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13740
diff
changeset
|
378 void *handle = os::dll_load(okra_library_name, ebuf, O_BUFLEN); |
13740
bfd61161d752
HSAIL: support for using Okra simulator without needing to configure PATH and LD_LIBRARY_PATH
Doug Simon <doug.simon@oracle.com>
parents:
13112
diff
changeset
|
379 // try alternate location if env variable set |
bfd61161d752
HSAIL: support for using Okra simulator without needing to configure PATH and LD_LIBRARY_PATH
Doug Simon <doug.simon@oracle.com>
parents:
13112
diff
changeset
|
380 char *okra_lib_name_from_env_var = getenv("_OKRA_SIM_LIB_PATH_"); |
bfd61161d752
HSAIL: support for using Okra simulator without needing to configure PATH and LD_LIBRARY_PATH
Doug Simon <doug.simon@oracle.com>
parents:
13112
diff
changeset
|
381 if ((handle == NULL) && (okra_lib_name_from_env_var != NULL)) { |
13819
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13740
diff
changeset
|
382 handle = os::dll_load(okra_lib_name_from_env_var, ebuf, O_BUFLEN); |
13740
bfd61161d752
HSAIL: support for using Okra simulator without needing to configure PATH and LD_LIBRARY_PATH
Doug Simon <doug.simon@oracle.com>
parents:
13112
diff
changeset
|
383 if ((handle != NULL) && TraceGPUInteraction) { |
bfd61161d752
HSAIL: support for using Okra simulator without needing to configure PATH and LD_LIBRARY_PATH
Doug Simon <doug.simon@oracle.com>
parents:
13112
diff
changeset
|
384 tty->print_cr("[HSAIL] using _OKRA_SIM_LIB_PATH_=%s", getenv("_OKRA_SIM_LIB_PATH_")); |
bfd61161d752
HSAIL: support for using Okra simulator without needing to configure PATH and LD_LIBRARY_PATH
Doug Simon <doug.simon@oracle.com>
parents:
13112
diff
changeset
|
385 } |
bfd61161d752
HSAIL: support for using Okra simulator without needing to configure PATH and LD_LIBRARY_PATH
Doug Simon <doug.simon@oracle.com>
parents:
13112
diff
changeset
|
386 } |
bfd61161d752
HSAIL: support for using Okra simulator without needing to configure PATH and LD_LIBRARY_PATH
Doug Simon <doug.simon@oracle.com>
parents:
13112
diff
changeset
|
387 |
13819
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13740
diff
changeset
|
388 if (handle == NULL) { |
13740
bfd61161d752
HSAIL: support for using Okra simulator without needing to configure PATH and LD_LIBRARY_PATH
Doug Simon <doug.simon@oracle.com>
parents:
13112
diff
changeset
|
389 // Unable to dlopen okra |
bfd61161d752
HSAIL: support for using Okra simulator without needing to configure PATH and LD_LIBRARY_PATH
Doug Simon <doug.simon@oracle.com>
parents:
13112
diff
changeset
|
390 if (TraceGPUInteraction) { |
bfd61161d752
HSAIL: support for using Okra simulator without needing to configure PATH and LD_LIBRARY_PATH
Doug Simon <doug.simon@oracle.com>
parents:
13112
diff
changeset
|
391 tty->print_cr("[HSAIL] library load failed."); |
bfd61161d752
HSAIL: support for using Okra simulator without needing to configure PATH and LD_LIBRARY_PATH
Doug Simon <doug.simon@oracle.com>
parents:
13112
diff
changeset
|
392 } |
bfd61161d752
HSAIL: support for using Okra simulator without needing to configure PATH and LD_LIBRARY_PATH
Doug Simon <doug.simon@oracle.com>
parents:
13112
diff
changeset
|
393 return false; |
bfd61161d752
HSAIL: support for using Okra simulator without needing to configure PATH and LD_LIBRARY_PATH
Doug Simon <doug.simon@oracle.com>
parents:
13112
diff
changeset
|
394 } |
bfd61161d752
HSAIL: support for using Okra simulator without needing to configure PATH and LD_LIBRARY_PATH
Doug Simon <doug.simon@oracle.com>
parents:
13112
diff
changeset
|
395 |
13819
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13740
diff
changeset
|
396 guarantee(_okra_create_context == NULL, "cannot repeat GPU initialization"); |
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13740
diff
changeset
|
397 |
13740
bfd61161d752
HSAIL: support for using Okra simulator without needing to configure PATH and LD_LIBRARY_PATH
Doug Simon <doug.simon@oracle.com>
parents:
13112
diff
changeset
|
398 // at this point we know handle is valid and we can lookup the functions |
bfd61161d752
HSAIL: support for using Okra simulator without needing to configure PATH and LD_LIBRARY_PATH
Doug Simon <doug.simon@oracle.com>
parents:
13112
diff
changeset
|
399 LOOKUP_OKRA_FUNCTION(okra_create_context, okra_create_context); |
bfd61161d752
HSAIL: support for using Okra simulator without needing to configure PATH and LD_LIBRARY_PATH
Doug Simon <doug.simon@oracle.com>
parents:
13112
diff
changeset
|
400 LOOKUP_OKRA_FUNCTION(okra_create_kernel, okra_create_kernel); |
bfd61161d752
HSAIL: support for using Okra simulator without needing to configure PATH and LD_LIBRARY_PATH
Doug Simon <doug.simon@oracle.com>
parents:
13112
diff
changeset
|
401 LOOKUP_OKRA_FUNCTION(okra_push_object, okra_push_object); |
bfd61161d752
HSAIL: support for using Okra simulator without needing to configure PATH and LD_LIBRARY_PATH
Doug Simon <doug.simon@oracle.com>
parents:
13112
diff
changeset
|
402 LOOKUP_OKRA_FUNCTION(okra_push_boolean, okra_push_boolean); |
bfd61161d752
HSAIL: support for using Okra simulator without needing to configure PATH and LD_LIBRARY_PATH
Doug Simon <doug.simon@oracle.com>
parents:
13112
diff
changeset
|
403 LOOKUP_OKRA_FUNCTION(okra_push_byte, okra_push_byte); |
bfd61161d752
HSAIL: support for using Okra simulator without needing to configure PATH and LD_LIBRARY_PATH
Doug Simon <doug.simon@oracle.com>
parents:
13112
diff
changeset
|
404 LOOKUP_OKRA_FUNCTION(okra_push_double, okra_push_double); |
bfd61161d752
HSAIL: support for using Okra simulator without needing to configure PATH and LD_LIBRARY_PATH
Doug Simon <doug.simon@oracle.com>
parents:
13112
diff
changeset
|
405 LOOKUP_OKRA_FUNCTION(okra_push_float, okra_push_float); |
bfd61161d752
HSAIL: support for using Okra simulator without needing to configure PATH and LD_LIBRARY_PATH
Doug Simon <doug.simon@oracle.com>
parents:
13112
diff
changeset
|
406 LOOKUP_OKRA_FUNCTION(okra_push_int, okra_push_int); |
bfd61161d752
HSAIL: support for using Okra simulator without needing to configure PATH and LD_LIBRARY_PATH
Doug Simon <doug.simon@oracle.com>
parents:
13112
diff
changeset
|
407 LOOKUP_OKRA_FUNCTION(okra_push_long, okra_push_long); |
bfd61161d752
HSAIL: support for using Okra simulator without needing to configure PATH and LD_LIBRARY_PATH
Doug Simon <doug.simon@oracle.com>
parents:
13112
diff
changeset
|
408 LOOKUP_OKRA_FUNCTION(okra_execute_with_range, okra_execute_with_range); |
bfd61161d752
HSAIL: support for using Okra simulator without needing to configure PATH and LD_LIBRARY_PATH
Doug Simon <doug.simon@oracle.com>
parents:
13112
diff
changeset
|
409 LOOKUP_OKRA_FUNCTION(okra_clearargs, okra_clearargs); |
bfd61161d752
HSAIL: support for using Okra simulator without needing to configure PATH and LD_LIBRARY_PATH
Doug Simon <doug.simon@oracle.com>
parents:
13112
diff
changeset
|
410 LOOKUP_OKRA_FUNCTION(okra_register_heap, okra_register_heap); |
bfd61161d752
HSAIL: support for using Okra simulator without needing to configure PATH and LD_LIBRARY_PATH
Doug Simon <doug.simon@oracle.com>
parents:
13112
diff
changeset
|
411 // if we made it this far, real success |
13819
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13740
diff
changeset
|
412 |
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13740
diff
changeset
|
413 gpu::initialized_gpu("Okra"); |
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13740
diff
changeset
|
414 |
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13740
diff
changeset
|
415 return true; |
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13740
diff
changeset
|
416 GPU_END |
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13740
diff
changeset
|
417 |
14768
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
418 |
13888
51584f76462d
pulled Ptx and Hsail classes out of gpu class namespace
Doug Simon <doug.simon@oracle.com>
parents:
13826
diff
changeset
|
419 bool Hsail::register_natives(JNIEnv* env) { |
13819
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13740
diff
changeset
|
420 jclass klass = env->FindClass("com/oracle/graal/hotspot/hsail/HSAILHotSpotBackend"); |
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13740
diff
changeset
|
421 if (klass == NULL) { |
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13740
diff
changeset
|
422 if (TraceGPUInteraction) { |
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13740
diff
changeset
|
423 tty->print_cr("HSAILHotSpotBackend class not found"); |
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13740
diff
changeset
|
424 } |
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13740
diff
changeset
|
425 return false; |
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13740
diff
changeset
|
426 } |
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13740
diff
changeset
|
427 jint status = env->RegisterNatives(klass, HSAIL_methods, sizeof(HSAIL_methods) / sizeof(JNINativeMethod)); |
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13740
diff
changeset
|
428 if (status != JNI_OK) { |
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13740
diff
changeset
|
429 if (TraceGPUInteraction) { |
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13740
diff
changeset
|
430 tty->print_cr("Error registering natives for HSAILHotSpotBackend: %d", status); |
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13740
diff
changeset
|
431 } |
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13740
diff
changeset
|
432 return false; |
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13740
diff
changeset
|
433 } |
13740
bfd61161d752
HSAIL: support for using Okra simulator without needing to configure PATH and LD_LIBRARY_PATH
Doug Simon <doug.simon@oracle.com>
parents:
13112
diff
changeset
|
434 return true; |
12743
f1a55428a8d7
more HSAIL support in the C++ layer for executing HSAIL code on the simulator
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
435 } |