Mercurial > hg > graal-compiler
annotate src/gpu/hsail/vm/gpu_hsail.cpp @ 16242:e9998e2be7f5
use oops_do to modify saved hsail state
Contributed-by: Tom Deneau <tom.deneau@amd.com>
author | Gilles Duboscq <duboscq@ssw.jku.at> |
---|---|
date | Thu, 26 Jun 2014 18:25:35 +0200 |
parents | 06eedda53e14 |
children | d5c4bb0039d8 |
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" |
15582
063ec2920d21
made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents:
15488
diff
changeset
|
36 #include "graal/graalRuntime.hpp" |
13819
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 "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
|
43 |
13819
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13740
diff
changeset
|
44 // 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
|
45 #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
|
46 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
|
47 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
|
48 |
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13740
diff
changeset
|
49 // 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
|
50 // 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
|
51 #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
|
52 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
|
53 |
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13740
diff
changeset
|
54 #define GPU_END } |
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13740
diff
changeset
|
55 |
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13740
diff
changeset
|
56 #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
|
57 #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
|
58 |
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13740
diff
changeset
|
59 #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
|
60 #define STRING "Ljava/lang/String;" |
15066
2cae21d9f122
HSAIL: initial support for object allocation in HSAIL kernels
Doug Simon <doug.simon@oracle.com>
parents:
14969
diff
changeset
|
61 #define JLTHREAD "Ljava/lang/Thread;" |
13819
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 |
13888
51584f76462d
pulled Ptx and Hsail classes out of gpu class namespace
Doug Simon <doug.simon@oracle.com>
parents:
13826
diff
changeset
|
66 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
|
67 {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
|
68 {CC"generateKernel", CC"([B" STRING ")J", FN_PTR(Hsail::generate_kernel)}, |
16242
e9998e2be7f5
use oops_do to modify saved hsail state
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
16076
diff
changeset
|
69 {CC"executeKernel0", CC"("HS_INSTALLED_CODE"I["OBJECT"["JLTHREAD"I[I)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
|
70 }; |
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13740
diff
changeset
|
71 |
16076
06eedda53e14
HSAIL: add support to allocate new TLAB from GPU
Doug Simon <doug.simon@oracle.com>
parents:
16006
diff
changeset
|
72 void* Hsail::_device_context = NULL; |
06eedda53e14
HSAIL: add support to allocate new TLAB from GPU
Doug Simon <doug.simon@oracle.com>
parents:
16006
diff
changeset
|
73 jint Hsail::_notice_safepoints = false; |
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
|
74 |
13888
51584f76462d
pulled Ptx and Hsail classes out of gpu class namespace
Doug Simon <doug.simon@oracle.com>
parents:
13826
diff
changeset
|
75 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
|
76 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
|
77 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
|
78 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
|
79 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
|
80 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
|
81 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
|
82 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
|
83 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
|
84 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
|
85 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
|
86 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
|
87 |
15177
66e3af78ea96
HSAIL: added safepoint support
Doug Simon <doug.simon@oracle.com>
parents:
15161
diff
changeset
|
88 //static jint in_kernel = 0; |
66e3af78ea96
HSAIL: added safepoint support
Doug Simon <doug.simon@oracle.com>
parents:
15161
diff
changeset
|
89 |
66e3af78ea96
HSAIL: added safepoint support
Doug Simon <doug.simon@oracle.com>
parents:
15161
diff
changeset
|
90 void Hsail::notice_safepoints() { |
66e3af78ea96
HSAIL: added safepoint support
Doug Simon <doug.simon@oracle.com>
parents:
15161
diff
changeset
|
91 _notice_safepoints = true; |
66e3af78ea96
HSAIL: added safepoint support
Doug Simon <doug.simon@oracle.com>
parents:
15161
diff
changeset
|
92 // if (TraceGPUInteraction) { |
66e3af78ea96
HSAIL: added safepoint support
Doug Simon <doug.simon@oracle.com>
parents:
15161
diff
changeset
|
93 // tty->print_cr("[HSAIL] Notice safepoint in_kernel=%d", in_kernel); |
66e3af78ea96
HSAIL: added safepoint support
Doug Simon <doug.simon@oracle.com>
parents:
15161
diff
changeset
|
94 // } |
66e3af78ea96
HSAIL: added safepoint support
Doug Simon <doug.simon@oracle.com>
parents:
15161
diff
changeset
|
95 } |
66e3af78ea96
HSAIL: added safepoint support
Doug Simon <doug.simon@oracle.com>
parents:
15161
diff
changeset
|
96 |
66e3af78ea96
HSAIL: added safepoint support
Doug Simon <doug.simon@oracle.com>
parents:
15161
diff
changeset
|
97 void Hsail::ignore_safepoints() { |
66e3af78ea96
HSAIL: added safepoint support
Doug Simon <doug.simon@oracle.com>
parents:
15161
diff
changeset
|
98 _notice_safepoints = false; |
66e3af78ea96
HSAIL: added safepoint support
Doug Simon <doug.simon@oracle.com>
parents:
15161
diff
changeset
|
99 } |
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
|
100 |
13888
51584f76462d
pulled Ptx and Hsail classes out of gpu class namespace
Doug Simon <doug.simon@oracle.com>
parents:
13826
diff
changeset
|
101 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
|
102 // 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
|
103 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
|
104 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
|
105 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
|
106 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
|
107 } |
f1a55428a8d7
more HSAIL support in the C++ layer for executing HSAIL code on the simulator
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
108 _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
|
109 } |
f1a55428a8d7
more HSAIL support in the C++ layer for executing HSAIL code on the simulator
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
110 |
16242
e9998e2be7f5
use oops_do to modify saved hsail state
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
16076
diff
changeset
|
111 GPU_VMENTRY(jboolean, Hsail::execute_kernel_void_1d, (JNIEnv* env, jclass, jobject kernel_handle, jint dimX, jobject args, |
15482
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15177
diff
changeset
|
112 jobject donor_threads, jint allocBytesPerWorkitem, jobject oop_map_array)) |
13819
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13740
diff
changeset
|
113 |
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13740
diff
changeset
|
114 ResourceMark rm; |
15161
2c940b1a48d8
Convert InstalledCode from an interface into an abstract class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15067
diff
changeset
|
115 jlong nmethodValue = InstalledCode::address(kernel_handle); |
13819
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13740
diff
changeset
|
116 if (nmethodValue == 0) { |
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13740
diff
changeset
|
117 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
|
118 } |
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13740
diff
changeset
|
119 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
|
120 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
|
121 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
|
122 |
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13740
diff
changeset
|
123 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
|
124 if (kernel == NULL) { |
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13740
diff
changeset
|
125 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
|
126 } |
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13740
diff
changeset
|
127 |
16242
e9998e2be7f5
use oops_do to modify saved hsail state
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
16076
diff
changeset
|
128 return execute_kernel_void_1d_internal((address) kernel, dimX, args, mh, nm, donor_threads, allocBytesPerWorkitem, oop_map_array, CHECK_0); |
14768
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
129 GPU_END |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
130 |
16076
06eedda53e14
HSAIL: add support to allocate new TLAB from GPU
Doug Simon <doug.simon@oracle.com>
parents:
16006
diff
changeset
|
131 static void showRanges(jboolean* a, int len) { |
14768
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
132 // show ranges |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
133 bool lookFor = true; |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
134 for (int i = 0; i < len; i++) { |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
135 if ((lookFor == true) && (a[i] != 0)) { |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
136 tty->print("%d", i); |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
137 lookFor = false; |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
138 } else if ((lookFor == false) && (a[i] == 0)) { |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
139 tty->print_cr("-%d", i-1); |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
140 lookFor = true; |
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 } |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
143 if (lookFor == false) { |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
144 tty->print_cr("-%d", len-1); |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
145 } |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
146 } |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
147 |
16242
e9998e2be7f5
use oops_do to modify saved hsail state
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
16076
diff
changeset
|
148 jboolean Hsail::execute_kernel_void_1d_internal(address kernel, int dimX, jobject args, methodHandle& mh, nmethod* nm, |
15482
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15177
diff
changeset
|
149 jobject donor_threads, int allocBytesPerWorkitem, jobject oop_map_array, TRAPS) { |
14768
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
150 ResourceMark rm(THREAD); |
15066
2cae21d9f122
HSAIL: initial support for object allocation in HSAIL kernels
Doug Simon <doug.simon@oracle.com>
parents:
14969
diff
changeset
|
151 objArrayOop argsArray = (objArrayOop) JNIHandles::resolve(args); |
16242
e9998e2be7f5
use oops_do to modify saved hsail state
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
16076
diff
changeset
|
152 assert(THREAD->is_Java_thread(), "must be a JavaThread"); |
15066
2cae21d9f122
HSAIL: initial support for object allocation in HSAIL kernels
Doug Simon <doug.simon@oracle.com>
parents:
14969
diff
changeset
|
153 |
16076
06eedda53e14
HSAIL: add support to allocate new TLAB from GPU
Doug Simon <doug.simon@oracle.com>
parents:
16006
diff
changeset
|
154 // We avoid HSAILAllocationInfo logic if kernel does not allocate |
06eedda53e14
HSAIL: add support to allocate new TLAB from GPU
Doug Simon <doug.simon@oracle.com>
parents:
16006
diff
changeset
|
155 // in which case the donor_thread array passed in will be null |
06eedda53e14
HSAIL: add support to allocate new TLAB from GPU
Doug Simon <doug.simon@oracle.com>
parents:
16006
diff
changeset
|
156 HSAILAllocationInfo* allocInfo = (donor_threads == NULL ? NULL : new HSAILAllocationInfo(donor_threads, dimX, allocBytesPerWorkitem)); |
06eedda53e14
HSAIL: add support to allocate new TLAB from GPU
Doug Simon <doug.simon@oracle.com>
parents:
16006
diff
changeset
|
157 |
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
|
158 // 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
|
159 _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
|
160 |
16242
e9998e2be7f5
use oops_do to modify saved hsail state
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
16076
diff
changeset
|
161 JavaThread* thread = (JavaThread*)THREAD; |
14768
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
162 HSAILDeoptimizationInfo* e; |
14969
a6c144380ce7
HSAIL: added UseHSAILDeoptimization VM option for disabling HSAIL deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14768
diff
changeset
|
163 if (UseHSAILDeoptimization) { |
15609
66d31e70bd79
HSAIL: fixed deopt bug; cleaned up C++ code
Doug Simon <doug.simon@oracle.com>
parents:
15582
diff
changeset
|
164 // get how many bytes per deopt save area are required |
16242
e9998e2be7f5
use oops_do to modify saved hsail state
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
16076
diff
changeset
|
165 int saveAreaCounts = HSAILOopMapHelper::get_save_area_counts(oop_map_array); |
15609
66d31e70bd79
HSAIL: fixed deopt bug; cleaned up C++ code
Doug Simon <doug.simon@oracle.com>
parents:
15582
diff
changeset
|
166 int numSRegs = saveAreaCounts & 0xff; |
66d31e70bd79
HSAIL: fixed deopt bug; cleaned up C++ code
Doug Simon <doug.simon@oracle.com>
parents:
15582
diff
changeset
|
167 int numDRegs = (saveAreaCounts >> 8) & 0xff; |
66d31e70bd79
HSAIL: fixed deopt bug; cleaned up C++ code
Doug Simon <doug.simon@oracle.com>
parents:
15582
diff
changeset
|
168 int numStackSlots = (saveAreaCounts >> 16); |
66d31e70bd79
HSAIL: fixed deopt bug; cleaned up C++ code
Doug Simon <doug.simon@oracle.com>
parents:
15582
diff
changeset
|
169 int bytesPerSaveArea = numSRegs * 4 + (numDRegs + numStackSlots) * 8; |
66d31e70bd79
HSAIL: fixed deopt bug; cleaned up C++ code
Doug Simon <doug.simon@oracle.com>
parents:
15582
diff
changeset
|
170 |
16242
e9998e2be7f5
use oops_do to modify saved hsail state
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
16076
diff
changeset
|
171 e = new (MAX_DEOPT_SLOTS, bytesPerSaveArea) HSAILDeoptimizationInfo(MAX_DEOPT_SLOTS, bytesPerSaveArea, dimX, allocInfo, oop_map_array); |
16076
06eedda53e14
HSAIL: add support to allocate new TLAB from GPU
Doug Simon <doug.simon@oracle.com>
parents:
16006
diff
changeset
|
172 // copy cur_tlab_infos |
06eedda53e14
HSAIL: add support to allocate new TLAB from GPU
Doug Simon <doug.simon@oracle.com>
parents:
16006
diff
changeset
|
173 if (allocInfo != NULL) { |
16242
e9998e2be7f5
use oops_do to modify saved hsail state
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
16076
diff
changeset
|
174 e->set_cur_tlabInfos(allocInfo->getCurTlabInfos()); |
16076
06eedda53e14
HSAIL: add support to allocate new TLAB from GPU
Doug Simon <doug.simon@oracle.com>
parents:
16006
diff
changeset
|
175 } |
16242
e9998e2be7f5
use oops_do to modify saved hsail state
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
16076
diff
changeset
|
176 // set deopt info in thread so gc oops_do processing can find it |
e9998e2be7f5
use oops_do to modify saved hsail state
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
16076
diff
changeset
|
177 thread->set_gpu_hsail_deopt_info(e); |
14768
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
178 } |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
179 |
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
|
180 // This object sets up the kernel arguments |
14768
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
181 HSAILKernelArguments hka((address) kernel, mh->signature(), argsArray, mh->is_static(), e); |
15177
66e3af78ea96
HSAIL: added safepoint support
Doug Simon <doug.simon@oracle.com>
parents:
15161
diff
changeset
|
182 if (TraceGPUInteraction) { |
66e3af78ea96
HSAIL: added safepoint support
Doug Simon <doug.simon@oracle.com>
parents:
15161
diff
changeset
|
183 tty->print_cr("[HSAIL] range=%d", dimX); |
66e3af78ea96
HSAIL: added safepoint support
Doug Simon <doug.simon@oracle.com>
parents:
15161
diff
changeset
|
184 } |
14768
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
185 |
16076
06eedda53e14
HSAIL: add support to allocate new TLAB from GPU
Doug Simon <doug.simon@oracle.com>
parents:
16006
diff
changeset
|
186 // If any object passed was null, throw an exception here. Doing this |
06eedda53e14
HSAIL: add support to allocate new TLAB from GPU
Doug Simon <doug.simon@oracle.com>
parents:
16006
diff
changeset
|
187 // means the kernel code can avoid null checks on the object parameters. |
14768
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
188 if (hka.getFirstNullParameterIndex() >= 0) { |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
189 char buf[64]; |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
190 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
|
191 thread->set_gpu_exception_bci(0); |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
192 thread->set_gpu_exception_method(mh()); |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
193 THROW_MSG_0(vmSymbols::java_lang_NullPointerException(), buf); |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
194 } |
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
|
195 |
f1a55428a8d7
more HSAIL support in the C++ layer for executing HSAIL code on the simulator
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
196 // Run the kernel |
14969
a6c144380ce7
HSAIL: added UseHSAILDeoptimization VM option for disabling HSAIL deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14768
diff
changeset
|
197 bool success = false; |
a6c144380ce7
HSAIL: added UseHSAILDeoptimization VM option for disabling HSAIL deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14768
diff
changeset
|
198 { |
15177
66e3af78ea96
HSAIL: added safepoint support
Doug Simon <doug.simon@oracle.com>
parents:
15161
diff
changeset
|
199 TraceTime t("execute kernel", TraceGPUInteraction); |
66e3af78ea96
HSAIL: added safepoint support
Doug Simon <doug.simon@oracle.com>
parents:
15161
diff
changeset
|
200 |
66e3af78ea96
HSAIL: added safepoint support
Doug Simon <doug.simon@oracle.com>
parents:
15161
diff
changeset
|
201 //in_kernel = 1; |
66e3af78ea96
HSAIL: added safepoint support
Doug Simon <doug.simon@oracle.com>
parents:
15161
diff
changeset
|
202 // Run the kernel |
14969
a6c144380ce7
HSAIL: added UseHSAILDeoptimization VM option for disabling HSAIL deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14768
diff
changeset
|
203 success = _okra_execute_with_range(kernel, dimX); |
15177
66e3af78ea96
HSAIL: added safepoint support
Doug Simon <doug.simon@oracle.com>
parents:
15161
diff
changeset
|
204 //in_kernel = 0; |
14969
a6c144380ce7
HSAIL: added UseHSAILDeoptimization VM option for disabling HSAIL deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14768
diff
changeset
|
205 } |
14768
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
206 |
16076
06eedda53e14
HSAIL: add support to allocate new TLAB from GPU
Doug Simon <doug.simon@oracle.com>
parents:
16006
diff
changeset
|
207 // avoid HSAILAllocationInfo logic if kernel does not allocate |
06eedda53e14
HSAIL: add support to allocate new TLAB from GPU
Doug Simon <doug.simon@oracle.com>
parents:
16006
diff
changeset
|
208 if (allocInfo != NULL) { |
06eedda53e14
HSAIL: add support to allocate new TLAB from GPU
Doug Simon <doug.simon@oracle.com>
parents:
16006
diff
changeset
|
209 allocInfo->postKernelCleanup(); |
15066
2cae21d9f122
HSAIL: initial support for object allocation in HSAIL kernels
Doug Simon <doug.simon@oracle.com>
parents:
14969
diff
changeset
|
210 } |
2cae21d9f122
HSAIL: initial support for object allocation in HSAIL kernels
Doug Simon <doug.simon@oracle.com>
parents:
14969
diff
changeset
|
211 |
14969
a6c144380ce7
HSAIL: added UseHSAILDeoptimization VM option for disabling HSAIL deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14768
diff
changeset
|
212 if (UseHSAILDeoptimization) { |
a6c144380ce7
HSAIL: added UseHSAILDeoptimization VM option for disabling HSAIL deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14768
diff
changeset
|
213 // check if any workitem requested a deopt |
a6c144380ce7
HSAIL: added UseHSAILDeoptimization VM option for disabling HSAIL deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14768
diff
changeset
|
214 int deoptcode = e->deopt_occurred(); |
15177
66e3af78ea96
HSAIL: added safepoint support
Doug Simon <doug.simon@oracle.com>
parents:
15161
diff
changeset
|
215 if (deoptcode != 1) { |
66e3af78ea96
HSAIL: added safepoint support
Doug Simon <doug.simon@oracle.com>
parents:
15161
diff
changeset
|
216 if (deoptcode == 0) { |
66e3af78ea96
HSAIL: added safepoint support
Doug Simon <doug.simon@oracle.com>
parents:
15161
diff
changeset
|
217 if (TraceGPUInteraction && _notice_safepoints != 0) { |
66e3af78ea96
HSAIL: added safepoint support
Doug Simon <doug.simon@oracle.com>
parents:
15161
diff
changeset
|
218 tty->print_cr("[HSAIL] observed safepoint during kernel"); |
66e3af78ea96
HSAIL: added safepoint support
Doug Simon <doug.simon@oracle.com>
parents:
15161
diff
changeset
|
219 } |
66e3af78ea96
HSAIL: added safepoint support
Doug Simon <doug.simon@oracle.com>
parents:
15161
diff
changeset
|
220 } else { |
14969
a6c144380ce7
HSAIL: added UseHSAILDeoptimization VM option for disabling HSAIL deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14768
diff
changeset
|
221 // error condition detected in deopt code |
a6c144380ce7
HSAIL: added UseHSAILDeoptimization VM option for disabling HSAIL deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14768
diff
changeset
|
222 char msg[200]; |
a6c144380ce7
HSAIL: added UseHSAILDeoptimization VM option for disabling HSAIL deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14768
diff
changeset
|
223 sprintf(msg, "deopt error detected, slot for workitem %d was not empty", -1 * (deoptcode + 1)); |
a6c144380ce7
HSAIL: added UseHSAILDeoptimization VM option for disabling HSAIL deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14768
diff
changeset
|
224 guarantee(deoptcode == 1, msg); |
a6c144380ce7
HSAIL: added UseHSAILDeoptimization VM option for disabling HSAIL deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14768
diff
changeset
|
225 } |
15177
66e3af78ea96
HSAIL: added safepoint support
Doug Simon <doug.simon@oracle.com>
parents:
15161
diff
changeset
|
226 } else { |
14969
a6c144380ce7
HSAIL: added UseHSAILDeoptimization VM option for disabling HSAIL deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14768
diff
changeset
|
227 { |
a6c144380ce7
HSAIL: added UseHSAILDeoptimization VM option for disabling HSAIL deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14768
diff
changeset
|
228 TraceTime t3("handle deoptimizing workitems", TraceGPUInteraction); |
a6c144380ce7
HSAIL: added UseHSAILDeoptimization VM option for disabling HSAIL deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14768
diff
changeset
|
229 if (TraceGPUInteraction) { |
a6c144380ce7
HSAIL: added UseHSAILDeoptimization VM option for disabling HSAIL deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14768
diff
changeset
|
230 tty->print_cr("deopt happened."); |
16076
06eedda53e14
HSAIL: add support to allocate new TLAB from GPU
Doug Simon <doug.simon@oracle.com>
parents:
16006
diff
changeset
|
231 HSAILKernelDeoptimization* pdeopt = e->get_deopt_save_state(0); |
14969
a6c144380ce7
HSAIL: added UseHSAILDeoptimization VM option for disabling HSAIL deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14768
diff
changeset
|
232 tty->print_cr("first deopter was workitem %d", pdeopt->workitem()); |
a6c144380ce7
HSAIL: added UseHSAILDeoptimization VM option for disabling HSAIL deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14768
diff
changeset
|
233 } |
14768
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
234 |
14969
a6c144380ce7
HSAIL: added UseHSAILDeoptimization VM option for disabling HSAIL deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14768
diff
changeset
|
235 // Handle any deopting workitems. |
a6c144380ce7
HSAIL: added UseHSAILDeoptimization VM option for disabling HSAIL deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14768
diff
changeset
|
236 int count_deoptimized = 0; |
a6c144380ce7
HSAIL: added UseHSAILDeoptimization VM option for disabling HSAIL deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14768
diff
changeset
|
237 for (int k = 0; k < e->num_deopts(); k++) { |
16076
06eedda53e14
HSAIL: add support to allocate new TLAB from GPU
Doug Simon <doug.simon@oracle.com>
parents:
16006
diff
changeset
|
238 HSAILKernelDeoptimization* pdeopt = e->get_deopt_save_state(k); |
14969
a6c144380ce7
HSAIL: added UseHSAILDeoptimization VM option for disabling HSAIL deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14768
diff
changeset
|
239 |
a6c144380ce7
HSAIL: added UseHSAILDeoptimization VM option for disabling HSAIL deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14768
diff
changeset
|
240 jint workitem = pdeopt->workitem(); |
a6c144380ce7
HSAIL: added UseHSAILDeoptimization VM option for disabling HSAIL deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14768
diff
changeset
|
241 if (workitem != -1) { |
a6c144380ce7
HSAIL: added UseHSAILDeoptimization VM option for disabling HSAIL deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14768
diff
changeset
|
242 int deoptId = pdeopt->pc_offset(); |
16076
06eedda53e14
HSAIL: add support to allocate new TLAB from GPU
Doug Simon <doug.simon@oracle.com>
parents:
16006
diff
changeset
|
243 HSAILFrame* hsailFrame = pdeopt->first_frame(); |
14969
a6c144380ce7
HSAIL: added UseHSAILDeoptimization VM option for disabling HSAIL deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14768
diff
changeset
|
244 |
a6c144380ce7
HSAIL: added UseHSAILDeoptimization VM option for disabling HSAIL deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14768
diff
changeset
|
245 JavaValue result(T_VOID); |
a6c144380ce7
HSAIL: added UseHSAILDeoptimization VM option for disabling HSAIL deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14768
diff
changeset
|
246 JavaCallArguments javaArgs; |
a6c144380ce7
HSAIL: added UseHSAILDeoptimization VM option for disabling HSAIL deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14768
diff
changeset
|
247 javaArgs.set_alternative_target(nm); |
a6c144380ce7
HSAIL: added UseHSAILDeoptimization VM option for disabling HSAIL deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14768
diff
changeset
|
248 javaArgs.push_int(deoptId); |
a6c144380ce7
HSAIL: added UseHSAILDeoptimization VM option for disabling HSAIL deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14768
diff
changeset
|
249 javaArgs.push_long((jlong) hsailFrame); |
a6c144380ce7
HSAIL: added UseHSAILDeoptimization VM option for disabling HSAIL deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14768
diff
changeset
|
250 |
16076
06eedda53e14
HSAIL: add support to allocate new TLAB from GPU
Doug Simon <doug.simon@oracle.com>
parents:
16006
diff
changeset
|
251 // Override the deoptimization action with Action_none until we decide |
14969
a6c144380ce7
HSAIL: added UseHSAILDeoptimization VM option for disabling HSAIL deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14768
diff
changeset
|
252 // how to handle the other actions. |
a6c144380ce7
HSAIL: added UseHSAILDeoptimization VM option for disabling HSAIL deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14768
diff
changeset
|
253 int myActionReason = Deoptimization::make_trap_request(Deoptimization::trap_request_reason(pdeopt->reason()), Deoptimization::Action_none); |
a6c144380ce7
HSAIL: added UseHSAILDeoptimization VM option for disabling HSAIL deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14768
diff
changeset
|
254 javaArgs.push_int(myActionReason); |
a6c144380ce7
HSAIL: added UseHSAILDeoptimization VM option for disabling HSAIL deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14768
diff
changeset
|
255 javaArgs.push_oop((oop) NULL); |
a6c144380ce7
HSAIL: added UseHSAILDeoptimization VM option for disabling HSAIL deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14768
diff
changeset
|
256 if (TraceGPUInteraction) { |
15482
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15177
diff
changeset
|
257 tty->print_cr("[HSAIL] Deoptimizing to host for workitem=%d (slot=%d) with deoptId=%d, frame=" INTPTR_FORMAT ", actionAndReason=%d", workitem, k, deoptId, hsailFrame, myActionReason); |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15177
diff
changeset
|
258 // show the $d registers or stack slots containing references |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15177
diff
changeset
|
259 int maxOopBits = hsailFrame->num_d_regs() + hsailFrame->num_stack_slots(); |
16242
e9998e2be7f5
use oops_do to modify saved hsail state
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
16076
diff
changeset
|
260 HSAILOopMapHelper oopMapHelper(oop_map_array); |
e9998e2be7f5
use oops_do to modify saved hsail state
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
16076
diff
changeset
|
261 int pc_offset = hsailFrame->pc_offset(); |
15482
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15177
diff
changeset
|
262 for (int bit = 0; bit < maxOopBits; bit++) { |
16242
e9998e2be7f5
use oops_do to modify saved hsail state
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
16076
diff
changeset
|
263 if (oopMapHelper.is_oop(pc_offset, bit)) { |
15482
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15177
diff
changeset
|
264 if (bit < hsailFrame->num_d_regs()) { |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15177
diff
changeset
|
265 // show $d reg oop |
16242
e9998e2be7f5
use oops_do to modify saved hsail state
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
16076
diff
changeset
|
266 tty->print_cr(" oop $d%d = %p", bit, hsailFrame->get_oop_for_bit(bit)); |
15482
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15177
diff
changeset
|
267 } else { |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15177
diff
changeset
|
268 // show stack slot oop |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15177
diff
changeset
|
269 int stackOffset = (bit - hsailFrame->num_d_regs()) * 8; // 8 bytes per stack slot |
16242
e9998e2be7f5
use oops_do to modify saved hsail state
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
16076
diff
changeset
|
270 tty->print_cr(" oop stk:%d = %p", stackOffset, hsailFrame->get_oop_for_bit(bit)); |
15482
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15177
diff
changeset
|
271 } |
14969
a6c144380ce7
HSAIL: added UseHSAILDeoptimization VM option for disabling HSAIL deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14768
diff
changeset
|
272 } |
a6c144380ce7
HSAIL: added UseHSAILDeoptimization VM option for disabling HSAIL deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14768
diff
changeset
|
273 } |
a6c144380ce7
HSAIL: added UseHSAILDeoptimization VM option for disabling HSAIL deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14768
diff
changeset
|
274 } |
a6c144380ce7
HSAIL: added UseHSAILDeoptimization VM option for disabling HSAIL deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14768
diff
changeset
|
275 JavaCalls::call(&result, mh, &javaArgs, THREAD); |
a6c144380ce7
HSAIL: added UseHSAILDeoptimization VM option for disabling HSAIL deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14768
diff
changeset
|
276 count_deoptimized++; |
16242
e9998e2be7f5
use oops_do to modify saved hsail state
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
16076
diff
changeset
|
277 e->set_deopt_work_index(k + 1); |
14969
a6c144380ce7
HSAIL: added UseHSAILDeoptimization VM option for disabling HSAIL deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14768
diff
changeset
|
278 } |
a6c144380ce7
HSAIL: added UseHSAILDeoptimization VM option for disabling HSAIL deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14768
diff
changeset
|
279 } |
a6c144380ce7
HSAIL: added UseHSAILDeoptimization VM option for disabling HSAIL deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14768
diff
changeset
|
280 if (TraceGPUInteraction) { |
a6c144380ce7
HSAIL: added UseHSAILDeoptimization VM option for disabling HSAIL deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14768
diff
changeset
|
281 tty->print_cr("[HSAIL] Deoptimizing to host completed for %d workitems", count_deoptimized); |
a6c144380ce7
HSAIL: added UseHSAILDeoptimization VM option for disabling HSAIL deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14768
diff
changeset
|
282 } |
14768
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
283 } |
15177
66e3af78ea96
HSAIL: added safepoint support
Doug Simon <doug.simon@oracle.com>
parents:
15161
diff
changeset
|
284 } |
16242
e9998e2be7f5
use oops_do to modify saved hsail state
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
16076
diff
changeset
|
285 // when we are done with the deopts, we don't need to oops_do anything |
e9998e2be7f5
use oops_do to modify saved hsail state
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
16076
diff
changeset
|
286 // in the saved state anymore |
e9998e2be7f5
use oops_do to modify saved hsail state
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
16076
diff
changeset
|
287 thread->set_gpu_hsail_deopt_info(NULL); |
14969
a6c144380ce7
HSAIL: added UseHSAILDeoptimization VM option for disabling HSAIL deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14768
diff
changeset
|
288 |
15177
66e3af78ea96
HSAIL: added safepoint support
Doug Simon <doug.simon@oracle.com>
parents:
15161
diff
changeset
|
289 // Handle any never_ran workitems if there were any |
66e3af78ea96
HSAIL: added safepoint support
Doug Simon <doug.simon@oracle.com>
parents:
15161
diff
changeset
|
290 { |
66e3af78ea96
HSAIL: added safepoint support
Doug Simon <doug.simon@oracle.com>
parents:
15161
diff
changeset
|
291 TraceTime t("handle never-rans ", TraceGPUInteraction); |
66e3af78ea96
HSAIL: added safepoint support
Doug Simon <doug.simon@oracle.com>
parents:
15161
diff
changeset
|
292 int count_never_ran = 0; |
66e3af78ea96
HSAIL: added safepoint support
Doug Simon <doug.simon@oracle.com>
parents:
15161
diff
changeset
|
293 bool handleNeverRansHere = true; |
66e3af78ea96
HSAIL: added safepoint support
Doug Simon <doug.simon@oracle.com>
parents:
15161
diff
changeset
|
294 // turn off verbose trace stuff for javacall arg setup |
66e3af78ea96
HSAIL: added safepoint support
Doug Simon <doug.simon@oracle.com>
parents:
15161
diff
changeset
|
295 bool savedTraceGPUInteraction = TraceGPUInteraction; |
66e3af78ea96
HSAIL: added safepoint support
Doug Simon <doug.simon@oracle.com>
parents:
15161
diff
changeset
|
296 TraceGPUInteraction = false; |
16076
06eedda53e14
HSAIL: add support to allocate new TLAB from GPU
Doug Simon <doug.simon@oracle.com>
parents:
16006
diff
changeset
|
297 jboolean* never_ran_array = e->never_ran_array(); |
15177
66e3af78ea96
HSAIL: added safepoint support
Doug Simon <doug.simon@oracle.com>
parents:
15161
diff
changeset
|
298 if (handleNeverRansHere) { |
66e3af78ea96
HSAIL: added safepoint support
Doug Simon <doug.simon@oracle.com>
parents:
15161
diff
changeset
|
299 for (int k = 0; k < dimX; k++) { |
66e3af78ea96
HSAIL: added safepoint support
Doug Simon <doug.simon@oracle.com>
parents:
15161
diff
changeset
|
300 if (never_ran_array[k]) { |
66e3af78ea96
HSAIL: added safepoint support
Doug Simon <doug.simon@oracle.com>
parents:
15161
diff
changeset
|
301 // run it as a javaCall |
66e3af78ea96
HSAIL: added safepoint support
Doug Simon <doug.simon@oracle.com>
parents:
15161
diff
changeset
|
302 KlassHandle methKlass = mh->method_holder(); |
66e3af78ea96
HSAIL: added safepoint support
Doug Simon <doug.simon@oracle.com>
parents:
15161
diff
changeset
|
303 Thread* THREAD = Thread::current(); |
66e3af78ea96
HSAIL: added safepoint support
Doug Simon <doug.simon@oracle.com>
parents:
15161
diff
changeset
|
304 JavaValue result(T_VOID); |
66e3af78ea96
HSAIL: added safepoint support
Doug Simon <doug.simon@oracle.com>
parents:
15161
diff
changeset
|
305 JavaCallArguments javaArgs; |
66e3af78ea96
HSAIL: added safepoint support
Doug Simon <doug.simon@oracle.com>
parents:
15161
diff
changeset
|
306 // re-resolve the args_handle here |
66e3af78ea96
HSAIL: added safepoint support
Doug Simon <doug.simon@oracle.com>
parents:
15161
diff
changeset
|
307 objArrayOop resolvedArgsArray = (objArrayOop) JNIHandles::resolve(args); |
16076
06eedda53e14
HSAIL: add support to allocate new TLAB from GPU
Doug Simon <doug.simon@oracle.com>
parents:
16006
diff
changeset
|
308 |
06eedda53e14
HSAIL: add support to allocate new TLAB from GPU
Doug Simon <doug.simon@oracle.com>
parents:
16006
diff
changeset
|
309 // This object sets up the javaCall arguments. The way |
06eedda53e14
HSAIL: add support to allocate new TLAB from GPU
Doug Simon <doug.simon@oracle.com>
parents:
16006
diff
changeset
|
310 // argsArray is set up, this should work for instance |
06eedda53e14
HSAIL: add support to allocate new TLAB from GPU
Doug Simon <doug.simon@oracle.com>
parents:
16006
diff
changeset
|
311 // methods as well (the receiver will be the first oop pushed) |
15177
66e3af78ea96
HSAIL: added safepoint support
Doug Simon <doug.simon@oracle.com>
parents:
15161
diff
changeset
|
312 HSAILJavaCallArguments hjca(&javaArgs, k, mh->signature(), resolvedArgsArray, mh->is_static()); |
66e3af78ea96
HSAIL: added safepoint support
Doug Simon <doug.simon@oracle.com>
parents:
15161
diff
changeset
|
313 if (mh->is_static()) { |
66e3af78ea96
HSAIL: added safepoint support
Doug Simon <doug.simon@oracle.com>
parents:
15161
diff
changeset
|
314 JavaCalls::call_static(&result, methKlass, mh->name(), mh->signature(), &javaArgs, THREAD); |
66e3af78ea96
HSAIL: added safepoint support
Doug Simon <doug.simon@oracle.com>
parents:
15161
diff
changeset
|
315 } else { |
66e3af78ea96
HSAIL: added safepoint support
Doug Simon <doug.simon@oracle.com>
parents:
15161
diff
changeset
|
316 JavaCalls::call_virtual(&result, methKlass, mh->name(), mh->signature(), &javaArgs, THREAD); |
14969
a6c144380ce7
HSAIL: added UseHSAILDeoptimization VM option for disabling HSAIL deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14768
diff
changeset
|
317 } |
15177
66e3af78ea96
HSAIL: added safepoint support
Doug Simon <doug.simon@oracle.com>
parents:
15161
diff
changeset
|
318 count_never_ran++; |
14969
a6c144380ce7
HSAIL: added UseHSAILDeoptimization VM option for disabling HSAIL deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14768
diff
changeset
|
319 } |
15177
66e3af78ea96
HSAIL: added safepoint support
Doug Simon <doug.simon@oracle.com>
parents:
15161
diff
changeset
|
320 } |
66e3af78ea96
HSAIL: added safepoint support
Doug Simon <doug.simon@oracle.com>
parents:
15161
diff
changeset
|
321 TraceGPUInteraction = savedTraceGPUInteraction; |
15482
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15177
diff
changeset
|
322 if (TraceGPUInteraction && (count_never_ran > 0)) { |
15177
66e3af78ea96
HSAIL: added safepoint support
Doug Simon <doug.simon@oracle.com>
parents:
15161
diff
changeset
|
323 tty->print_cr("%d workitems never ran, have been run via JavaCall", count_never_ran); |
66e3af78ea96
HSAIL: added safepoint support
Doug Simon <doug.simon@oracle.com>
parents:
15161
diff
changeset
|
324 showRanges(never_ran_array, dimX); |
66e3af78ea96
HSAIL: added safepoint support
Doug Simon <doug.simon@oracle.com>
parents:
15161
diff
changeset
|
325 } |
66e3af78ea96
HSAIL: added safepoint support
Doug Simon <doug.simon@oracle.com>
parents:
15161
diff
changeset
|
326 } // end of never-ran handling |
14768
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
327 } |
15177
66e3af78ea96
HSAIL: added safepoint support
Doug Simon <doug.simon@oracle.com>
parents:
15161
diff
changeset
|
328 |
14768
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
329 delete e; |
16076
06eedda53e14
HSAIL: add support to allocate new TLAB from GPU
Doug Simon <doug.simon@oracle.com>
parents:
16006
diff
changeset
|
330 delete allocInfo; |
14768
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
331 } |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
332 return success; |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
333 } |
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
|
334 |
16076
06eedda53e14
HSAIL: add support to allocate new TLAB from GPU
Doug Simon <doug.simon@oracle.com>
parents:
16006
diff
changeset
|
335 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
|
336 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
|
337 ResourceMark rm; |
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13740
diff
changeset
|
338 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
|
339 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
|
340 |
13819
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13740
diff
changeset
|
341 char* name = NEW_RESOURCE_ARRAY(char, name_len + 1); |
16076
06eedda53e14
HSAIL: add support to allocate new TLAB from GPU
Doug Simon <doug.simon@oracle.com>
parents:
16006
diff
changeset
|
342 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
|
343 |
13819
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13740
diff
changeset
|
344 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
|
345 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
|
346 |
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13740
diff
changeset
|
347 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
|
348 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
|
349 |
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13740
diff
changeset
|
350 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
|
351 |
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 // 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
|
353 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
|
354 |
13112
166ed1584f30
HSAIL: null checks when loading Okra library functions
Doug Simon <doug.simon@oracle.com>
parents:
13097
diff
changeset
|
355 _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
|
356 |
13819
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13740
diff
changeset
|
357 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
|
358 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
|
359 |
f1a55428a8d7
more HSAIL support in the C++ layer for executing HSAIL code on the simulator
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
360 #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
|
361 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
|
362 #elif defined(_WINDOWS) |
62bd4705894c
reverted removal of Okra Windows DLL name
Doug Simon <doug.simon@oracle.com>
parents:
13822
diff
changeset
|
363 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
|
364 #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
|
365 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
|
366 #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
|
367 |
13112
166ed1584f30
HSAIL: null checks when loading Okra library functions
Doug Simon <doug.simon@oracle.com>
parents:
13097
diff
changeset
|
368 #define STRINGIFY(x) #x |
166ed1584f30
HSAIL: null checks when loading Okra library functions
Doug Simon <doug.simon@oracle.com>
parents:
13097
diff
changeset
|
369 |
166ed1584f30
HSAIL: null checks when loading Okra library functions
Doug Simon <doug.simon@oracle.com>
parents:
13097
diff
changeset
|
370 #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
|
371 _##alias = \ |
15067
0e689f20706e
HSAIL: avoid loading native Okra library twice
Doug Simon <doug.simon@oracle.com>
parents:
15066
diff
changeset
|
372 CAST_TO_FN_PTR(alias##_func_t, os::dll_lookup(okra_lib_handle, STRINGIFY(name))); \ |
13112
166ed1584f30
HSAIL: null checks when loading Okra library functions
Doug Simon <doug.simon@oracle.com>
parents:
13097
diff
changeset
|
373 if (_##alias == NULL) { \ |
166ed1584f30
HSAIL: null checks when loading Okra library functions
Doug Simon <doug.simon@oracle.com>
parents:
13097
diff
changeset
|
374 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
|
375 return false; \ |
13112
166ed1584f30
HSAIL: null checks when loading Okra library functions
Doug Simon <doug.simon@oracle.com>
parents:
13097
diff
changeset
|
376 } \ |
166ed1584f30
HSAIL: null checks when loading Okra library functions
Doug Simon <doug.simon@oracle.com>
parents:
13097
diff
changeset
|
377 |
16076
06eedda53e14
HSAIL: add support to allocate new TLAB from GPU
Doug Simon <doug.simon@oracle.com>
parents:
16006
diff
changeset
|
378 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
|
379 if (okra_library_name == NULL) { |
13097 | 380 if (TraceGPUInteraction) { |
381 tty->print_cr("Unsupported HSAIL platform"); | |
382 } | |
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
|
383 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
|
384 } |
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
|
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 // 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
|
387 char ebuf[O_BUFLEN]; |
16076
06eedda53e14
HSAIL: add support to allocate new TLAB from GPU
Doug Simon <doug.simon@oracle.com>
parents:
16006
diff
changeset
|
388 char* okra_lib_name_from_env_var = getenv("_OKRA_SIM_LIB_PATH_"); |
15067
0e689f20706e
HSAIL: avoid loading native Okra library twice
Doug Simon <doug.simon@oracle.com>
parents:
15066
diff
changeset
|
389 if (okra_lib_name_from_env_var != NULL) { |
0e689f20706e
HSAIL: avoid loading native Okra library twice
Doug Simon <doug.simon@oracle.com>
parents:
15066
diff
changeset
|
390 okra_library_name = okra_lib_name_from_env_var; |
0e689f20706e
HSAIL: avoid loading native Okra library twice
Doug Simon <doug.simon@oracle.com>
parents:
15066
diff
changeset
|
391 } |
13097 | 392 if (TraceGPUInteraction) { |
15067
0e689f20706e
HSAIL: avoid loading native Okra library twice
Doug Simon <doug.simon@oracle.com>
parents:
15066
diff
changeset
|
393 tty->print_cr("[HSAIL] library is %s", okra_library_name); |
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
|
394 } |
16076
06eedda53e14
HSAIL: add support to allocate new TLAB from GPU
Doug Simon <doug.simon@oracle.com>
parents:
16006
diff
changeset
|
395 void* okra_lib_handle = NULL; |
15067
0e689f20706e
HSAIL: avoid loading native Okra library twice
Doug Simon <doug.simon@oracle.com>
parents:
15066
diff
changeset
|
396 #if defined(LINUX) |
0e689f20706e
HSAIL: avoid loading native Okra library twice
Doug Simon <doug.simon@oracle.com>
parents:
15066
diff
changeset
|
397 // Check first if the Okra library is already loaded. |
0e689f20706e
HSAIL: avoid loading native Okra library twice
Doug Simon <doug.simon@oracle.com>
parents:
15066
diff
changeset
|
398 // TODO: Figure out how to do this on other OSes. |
0e689f20706e
HSAIL: avoid loading native Okra library twice
Doug Simon <doug.simon@oracle.com>
parents:
15066
diff
changeset
|
399 okra_lib_handle = ::dlopen(okra_library_name, RTLD_LAZY | RTLD_NOLOAD); |
0e689f20706e
HSAIL: avoid loading native Okra library twice
Doug Simon <doug.simon@oracle.com>
parents:
15066
diff
changeset
|
400 #endif |
0e689f20706e
HSAIL: avoid loading native Okra library twice
Doug Simon <doug.simon@oracle.com>
parents:
15066
diff
changeset
|
401 // If Okra library is not already loaded, load it here |
0e689f20706e
HSAIL: avoid loading native Okra library twice
Doug Simon <doug.simon@oracle.com>
parents:
15066
diff
changeset
|
402 if (okra_lib_handle == NULL) { |
0e689f20706e
HSAIL: avoid loading native Okra library twice
Doug Simon <doug.simon@oracle.com>
parents:
15066
diff
changeset
|
403 okra_lib_handle = os::dll_load(okra_library_name, ebuf, O_BUFLEN); |
0e689f20706e
HSAIL: avoid loading native Okra library twice
Doug Simon <doug.simon@oracle.com>
parents:
15066
diff
changeset
|
404 } |
0e689f20706e
HSAIL: avoid loading native Okra library twice
Doug Simon <doug.simon@oracle.com>
parents:
15066
diff
changeset
|
405 if (okra_lib_handle == NULL) { |
0e689f20706e
HSAIL: avoid loading native Okra library twice
Doug Simon <doug.simon@oracle.com>
parents:
15066
diff
changeset
|
406 // Unable to open Okra library |
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
|
407 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
|
408 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
|
409 } |
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 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
|
411 } |
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
|
412 |
13819
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13740
diff
changeset
|
413 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
|
414 |
16076
06eedda53e14
HSAIL: add support to allocate new TLAB from GPU
Doug Simon <doug.simon@oracle.com>
parents:
16006
diff
changeset
|
415 // At this point we know okra_lib_handle is valid whether we loaded |
06eedda53e14
HSAIL: add support to allocate new TLAB from GPU
Doug Simon <doug.simon@oracle.com>
parents:
16006
diff
changeset
|
416 // here or earlier. In either case, we can lookup the functions. |
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
|
417 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
|
418 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
|
419 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
|
420 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
|
421 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
|
422 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
|
423 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
|
424 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
|
425 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
|
426 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
|
427 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
|
428 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
|
429 // 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
|
430 |
15177
66e3af78ea96
HSAIL: added safepoint support
Doug Simon <doug.simon@oracle.com>
parents:
15161
diff
changeset
|
431 Gpu::initialized_gpu(new Hsail()); |
13819
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13740
diff
changeset
|
432 |
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13740
diff
changeset
|
433 return true; |
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13740
diff
changeset
|
434 GPU_END |
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13740
diff
changeset
|
435 |
14768
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
13888
diff
changeset
|
436 |
13888
51584f76462d
pulled Ptx and Hsail classes out of gpu class namespace
Doug Simon <doug.simon@oracle.com>
parents:
13826
diff
changeset
|
437 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
|
438 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
|
439 if (klass == NULL) { |
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13740
diff
changeset
|
440 if (TraceGPUInteraction) { |
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13740
diff
changeset
|
441 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
|
442 } |
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13740
diff
changeset
|
443 return false; |
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13740
diff
changeset
|
444 } |
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13740
diff
changeset
|
445 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
|
446 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
|
447 if (TraceGPUInteraction) { |
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13740
diff
changeset
|
448 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
|
449 } |
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13740
diff
changeset
|
450 return false; |
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13740
diff
changeset
|
451 } |
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
|
452 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
|
453 } |
16242
e9998e2be7f5
use oops_do to modify saved hsail state
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
16076
diff
changeset
|
454 |
e9998e2be7f5
use oops_do to modify saved hsail state
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
16076
diff
changeset
|
455 |
e9998e2be7f5
use oops_do to modify saved hsail state
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
16076
diff
changeset
|
456 void Hsail::HSAILDeoptimizationInfo::oops_do(OopClosure* f) { |
e9998e2be7f5
use oops_do to modify saved hsail state
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
16076
diff
changeset
|
457 int unprocessed_deopts = num_deopts() - deopt_work_index(); |
e9998e2be7f5
use oops_do to modify saved hsail state
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
16076
diff
changeset
|
458 if (TraceGPUInteraction) { |
e9998e2be7f5
use oops_do to modify saved hsail state
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
16076
diff
changeset
|
459 tty->print_cr("HSAILDeoptimizationInfo::oops_do deopt_occurred=%d, total_deopts=%d, unprocessed_deopts=%d, oop_map_array=%p", _deopt_occurred, num_deopts(), unprocessed_deopts, _oop_map_array); |
e9998e2be7f5
use oops_do to modify saved hsail state
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
16076
diff
changeset
|
460 } |
e9998e2be7f5
use oops_do to modify saved hsail state
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
16076
diff
changeset
|
461 if (num_deopts() == 0 || unprocessed_deopts <= 0) { |
e9998e2be7f5
use oops_do to modify saved hsail state
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
16076
diff
changeset
|
462 return; // nothing to do |
e9998e2be7f5
use oops_do to modify saved hsail state
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
16076
diff
changeset
|
463 } |
e9998e2be7f5
use oops_do to modify saved hsail state
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
16076
diff
changeset
|
464 HSAILOopMapHelper oopMapHelper(_oop_map_array); |
e9998e2be7f5
use oops_do to modify saved hsail state
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
16076
diff
changeset
|
465 oopMapHelper.resolve_arrays(); // resolve once before processing |
e9998e2be7f5
use oops_do to modify saved hsail state
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
16076
diff
changeset
|
466 |
e9998e2be7f5
use oops_do to modify saved hsail state
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
16076
diff
changeset
|
467 // go thru the unprocessed deopt frames, finding each oop and applying the closre |
e9998e2be7f5
use oops_do to modify saved hsail state
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
16076
diff
changeset
|
468 for (int k = deopt_work_index(); k < num_deopts(); k++) { |
e9998e2be7f5
use oops_do to modify saved hsail state
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
16076
diff
changeset
|
469 HSAILKernelDeoptimization* pdeopt = get_deopt_save_state(k); |
e9998e2be7f5
use oops_do to modify saved hsail state
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
16076
diff
changeset
|
470 assert (pdeopt->workitem() >= 0, "bad workitem in deopt"); |
e9998e2be7f5
use oops_do to modify saved hsail state
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
16076
diff
changeset
|
471 if (TraceGPUInteraction) { |
e9998e2be7f5
use oops_do to modify saved hsail state
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
16076
diff
changeset
|
472 tty->print_cr(" deopt %d, workitem %d, pc %d", k, pdeopt->workitem(), pdeopt->pc_offset()); |
e9998e2be7f5
use oops_do to modify saved hsail state
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
16076
diff
changeset
|
473 } |
e9998e2be7f5
use oops_do to modify saved hsail state
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
16076
diff
changeset
|
474 HSAILFrame* hsailFrame = pdeopt->first_frame(); |
e9998e2be7f5
use oops_do to modify saved hsail state
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
16076
diff
changeset
|
475 hsailFrame->oops_do(f, &oopMapHelper); |
e9998e2be7f5
use oops_do to modify saved hsail state
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
16076
diff
changeset
|
476 } |
e9998e2be7f5
use oops_do to modify saved hsail state
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
16076
diff
changeset
|
477 } |