Mercurial > hg > truffle
annotate src/gpu/hsail/vm/gpu_hsail.cpp @ 13790:9f730a04ba38
add partial evaluation test for a ControlFlowException catch block that follows a SlowPathException catch block
author | Andreas Woess <andreas.woess@jku.at> |
---|---|
date | Tue, 28 Jan 2014 21:48:50 +0100 |
parents | bfd61161d752 |
children | 49db2c1e3bee |
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" |
f1a55428a8d7
more HSAIL support in the C++ layer for executing HSAIL code on the simulator
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
28 #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
|
29 #include "utilities/ostream.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
|
30 #include "memory/allocation.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
|
31 #include "memory/allocation.inline.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
|
32 #include "hsailKernelArguments.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
|
33 |
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 void * gpu::Hsail::_device_context; |
f1a55428a8d7
more HSAIL support in the C++ layer for executing HSAIL code on the simulator
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
35 |
13115
166ed1584f30
HSAIL: null checks when loading Okra library functions
Doug Simon <doug.simon@oracle.com>
parents:
13097
diff
changeset
|
36 gpu::Hsail::okra_create_context_func_t gpu::Hsail::_okra_create_context; |
166ed1584f30
HSAIL: null checks when loading Okra library functions
Doug Simon <doug.simon@oracle.com>
parents:
13097
diff
changeset
|
37 gpu::Hsail::okra_create_kernel_func_t gpu::Hsail::_okra_create_kernel; |
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 gpu::Hsail::okra_push_object_func_t gpu::Hsail::_okra_push_object; |
f1a55428a8d7
more HSAIL support in the C++ layer for executing HSAIL code on the simulator
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
39 gpu::Hsail::okra_push_boolean_func_t gpu::Hsail::_okra_push_boolean; |
f1a55428a8d7
more HSAIL support in the C++ layer for executing HSAIL code on the simulator
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
40 gpu::Hsail::okra_push_byte_func_t gpu::Hsail::_okra_push_byte; |
f1a55428a8d7
more HSAIL support in the C++ layer for executing HSAIL code on the simulator
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
41 gpu::Hsail::okra_push_double_func_t gpu::Hsail::_okra_push_double; |
f1a55428a8d7
more HSAIL support in the C++ layer for executing HSAIL code on the simulator
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
42 gpu::Hsail::okra_push_float_func_t gpu::Hsail::_okra_push_float; |
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 gpu::Hsail::okra_push_int_func_t gpu::Hsail::_okra_push_int; |
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 gpu::Hsail::okra_push_long_func_t gpu::Hsail::_okra_push_long; |
f1a55428a8d7
more HSAIL support in the C++ layer for executing HSAIL code on the simulator
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
45 gpu::Hsail::okra_execute_with_range_func_t gpu::Hsail::_okra_execute_with_range; |
f1a55428a8d7
more HSAIL support in the C++ layer for executing HSAIL code on the simulator
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
46 gpu::Hsail::okra_clearargs_func_t gpu::Hsail::_okra_clearargs; |
f1a55428a8d7
more HSAIL support in the C++ layer for executing HSAIL code on the simulator
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
47 gpu::Hsail::okra_register_heap_func_t gpu::Hsail::_okra_register_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
|
48 |
f1a55428a8d7
more HSAIL support in the C++ layer for executing HSAIL code on the simulator
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
49 |
f1a55428a8d7
more HSAIL support in the C++ layer for executing HSAIL code on the simulator
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
50 bool gpu::Hsail::initialize_gpu() { |
f1a55428a8d7
more HSAIL support in the C++ layer for executing HSAIL code on the simulator
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
51 // All the initialization is done in the okra library so |
f1a55428a8d7
more HSAIL support in the C++ layer for executing HSAIL code on the simulator
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
52 // nothing to do here. |
f1a55428a8d7
more HSAIL support in the C++ layer for executing HSAIL code on the simulator
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
53 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
|
54 tty->print_cr("[HSAIL] Simulator: initialize_gpu"); |
f1a55428a8d7
more HSAIL support in the C++ layer for executing HSAIL code on the simulator
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
55 } |
f1a55428a8d7
more HSAIL support in the C++ layer for executing HSAIL code on the simulator
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
56 return true; |
f1a55428a8d7
more HSAIL support in the C++ layer for executing HSAIL code on the simulator
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
57 } |
f1a55428a8d7
more HSAIL support in the C++ layer for executing HSAIL code on the simulator
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
58 |
f1a55428a8d7
more HSAIL support in the C++ layer for executing HSAIL code on the simulator
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
59 unsigned int gpu::Hsail::total_cores() { |
f1a55428a8d7
more HSAIL support in the C++ layer for executing HSAIL code on the simulator
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
60 // This is not important with simulator |
f1a55428a8d7
more HSAIL support in the C++ layer for executing HSAIL code on the simulator
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
61 return 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
|
62 } |
f1a55428a8d7
more HSAIL support in the C++ layer for executing HSAIL code on the simulator
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
63 |
f1a55428a8d7
more HSAIL support in the C++ layer for executing HSAIL code on the simulator
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
64 void gpu::Hsail::register_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
|
65 // 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
|
66 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
|
67 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
|
68 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
|
69 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
|
70 } |
f1a55428a8d7
more HSAIL support in the C++ layer for executing HSAIL code on the simulator
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
71 _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
|
72 } |
f1a55428a8d7
more HSAIL support in the C++ layer for executing HSAIL code on the simulator
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
73 |
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 bool gpu::Hsail::execute_kernel_void_1d(address kernel, int dimX, jobject args, methodHandle& mh) { |
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 objArrayOop argsArray = (objArrayOop) JNIHandles::resolve(args); |
f1a55428a8d7
more HSAIL support in the C++ layer for executing HSAIL code on the simulator
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
76 |
f1a55428a8d7
more HSAIL support in the C++ layer for executing HSAIL code on the simulator
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
77 // 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
|
78 _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
|
79 |
f1a55428a8d7
more HSAIL support in the C++ layer for executing HSAIL code on the simulator
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
80 // This object sets up 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
|
81 HSAILKernelArguments hka(kernel, mh->signature(), argsArray, mh->is_static()); |
f1a55428a8d7
more HSAIL support in the C++ layer for executing HSAIL code on the simulator
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
82 |
f1a55428a8d7
more HSAIL support in the C++ layer for executing HSAIL code on the simulator
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
83 // Run the 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
|
84 bool success = _okra_execute_with_range(kernel, dimX); |
f1a55428a8d7
more HSAIL support in the C++ layer for executing HSAIL code on the simulator
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
85 return success; |
f1a55428a8d7
more HSAIL support in the C++ layer for executing HSAIL code on the simulator
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
86 } |
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 |
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 void *gpu::Hsail::generate_kernel(unsigned char *code, int code_len, const char *name) { |
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 |
13740
bfd61161d752
HSAIL: support for using Okra simulator without needing to configure PATH and LD_LIBRARY_PATH
Doug Simon <doug.simon@oracle.com>
parents:
13115
diff
changeset
|
90 if (_okra_create_kernel == NULL) { |
bfd61161d752
HSAIL: support for using Okra simulator without needing to configure PATH and LD_LIBRARY_PATH
Doug Simon <doug.simon@oracle.com>
parents:
13115
diff
changeset
|
91 // probe linkage and we really need it to work this time |
bfd61161d752
HSAIL: support for using Okra simulator without needing to configure PATH and LD_LIBRARY_PATH
Doug Simon <doug.simon@oracle.com>
parents:
13115
diff
changeset
|
92 bool success = probe_linkage_internal(true); |
bfd61161d752
HSAIL: support for using Okra simulator without needing to configure PATH and LD_LIBRARY_PATH
Doug Simon <doug.simon@oracle.com>
parents:
13115
diff
changeset
|
93 guarantee(success, "[HSAIL] loading okra library"); |
bfd61161d752
HSAIL: support for using Okra simulator without needing to configure PATH and LD_LIBRARY_PATH
Doug Simon <doug.simon@oracle.com>
parents:
13115
diff
changeset
|
94 } |
bfd61161d752
HSAIL: support for using Okra simulator without needing to configure PATH and LD_LIBRARY_PATH
Doug Simon <doug.simon@oracle.com>
parents:
13115
diff
changeset
|
95 |
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
|
96 gpu::Hsail::register_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
|
97 |
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 // 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
|
99 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
|
100 |
13115
166ed1584f30
HSAIL: null checks when loading Okra library functions
Doug Simon <doug.simon@oracle.com>
parents:
13097
diff
changeset
|
101 _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
|
102 |
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 // code is not null terminated, must be a better way to do this |
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 unsigned char* nullTerminatedCodeBuffer = (unsigned char*) malloc(code_len + 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
|
105 memcpy(nullTerminatedCodeBuffer, code, code_len); |
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 nullTerminatedCodeBuffer[code_len] = 0; |
13115
166ed1584f30
HSAIL: null checks when loading Okra library functions
Doug Simon <doug.simon@oracle.com>
parents:
13097
diff
changeset
|
107 void* kernel = _okra_create_kernel(_device_context, nullTerminatedCodeBuffer, entryPointName); |
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
|
108 free(nullTerminatedCodeBuffer); |
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 return 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
|
110 } |
f1a55428a8d7
more HSAIL support in the C++ layer for executing HSAIL code on the simulator
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
111 |
f1a55428a8d7
more HSAIL support in the C++ layer for executing HSAIL code on the simulator
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
112 #if defined(LINUX) |
f1a55428a8d7
more HSAIL support in the C++ layer for executing HSAIL code on the simulator
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
113 static const char okra_library_name[] = "libokra_x86_64.so"; |
f1a55428a8d7
more HSAIL support in the C++ layer for executing HSAIL code on the simulator
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
114 #elif defined (_WINDOWS) |
f1a55428a8d7
more HSAIL support in the C++ layer for executing HSAIL code on the simulator
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
115 static char const okra_library_name[] = "okra_x86_64.dll"; |
f1a55428a8d7
more HSAIL support in the C++ layer for executing HSAIL code on the simulator
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
116 #else |
f1a55428a8d7
more HSAIL support in the C++ layer for executing HSAIL code on the simulator
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
117 static char const okra_library_name[] = ""; |
f1a55428a8d7
more HSAIL support in the C++ layer for executing HSAIL code on the simulator
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
118 #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
|
119 |
f1a55428a8d7
more HSAIL support in the C++ layer for executing HSAIL code on the simulator
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
120 #define STD_BUFFER_SIZE 1024 |
f1a55428a8d7
more HSAIL support in the C++ layer for executing HSAIL code on the simulator
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
121 |
13115
166ed1584f30
HSAIL: null checks when loading Okra library functions
Doug Simon <doug.simon@oracle.com>
parents:
13097
diff
changeset
|
122 #define STRINGIFY(x) #x |
166ed1584f30
HSAIL: null checks when loading Okra library functions
Doug Simon <doug.simon@oracle.com>
parents:
13097
diff
changeset
|
123 |
166ed1584f30
HSAIL: null checks when loading Okra library functions
Doug Simon <doug.simon@oracle.com>
parents:
13097
diff
changeset
|
124 #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
|
125 _##alias = \ |
166ed1584f30
HSAIL: null checks when loading Okra library functions
Doug Simon <doug.simon@oracle.com>
parents:
13097
diff
changeset
|
126 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
|
127 if (_##alias == NULL) { \ |
166ed1584f30
HSAIL: null checks when loading Okra library functions
Doug Simon <doug.simon@oracle.com>
parents:
13097
diff
changeset
|
128 tty->print_cr("[HSAIL] ***** Error: Failed to lookup %s in %s, wrong version of OKRA?", STRINGIFY(name), okra_library_name); \ |
166ed1584f30
HSAIL: null checks when loading Okra library functions
Doug Simon <doug.simon@oracle.com>
parents:
13097
diff
changeset
|
129 return 0; \ |
166ed1584f30
HSAIL: null checks when loading Okra library functions
Doug Simon <doug.simon@oracle.com>
parents:
13097
diff
changeset
|
130 } \ |
166ed1584f30
HSAIL: null checks when loading Okra library functions
Doug Simon <doug.simon@oracle.com>
parents:
13097
diff
changeset
|
131 |
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
|
132 bool gpu::Hsail::probe_linkage() { |
13740
bfd61161d752
HSAIL: support for using Okra simulator without needing to configure PATH and LD_LIBRARY_PATH
Doug Simon <doug.simon@oracle.com>
parents:
13115
diff
changeset
|
133 return probe_linkage_internal(false); |
bfd61161d752
HSAIL: support for using Okra simulator without needing to configure PATH and LD_LIBRARY_PATH
Doug Simon <doug.simon@oracle.com>
parents:
13115
diff
changeset
|
134 } |
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
|
135 |
f1a55428a8d7
more HSAIL support in the C++ layer for executing HSAIL code on the simulator
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
136 |
13740
bfd61161d752
HSAIL: support for using Okra simulator without needing to configure PATH and LD_LIBRARY_PATH
Doug Simon <doug.simon@oracle.com>
parents:
13115
diff
changeset
|
137 bool gpu::Hsail::probe_linkage_internal(bool isRequired) { |
bfd61161d752
HSAIL: support for using Okra simulator without needing to configure PATH and LD_LIBRARY_PATH
Doug Simon <doug.simon@oracle.com>
parents:
13115
diff
changeset
|
138 if (okra_library_name == NULL) { |
13097 | 139 if (TraceGPUInteraction) { |
140 tty->print_cr("Unsupported HSAIL platform"); | |
141 } | |
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
|
142 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
|
143 } |
13740
bfd61161d752
HSAIL: support for using Okra simulator without needing to configure PATH and LD_LIBRARY_PATH
Doug Simon <doug.simon@oracle.com>
parents:
13115
diff
changeset
|
144 |
bfd61161d752
HSAIL: support for using Okra simulator without needing to configure PATH and LD_LIBRARY_PATH
Doug Simon <doug.simon@oracle.com>
parents:
13115
diff
changeset
|
145 // here we know we have a valid okra_library_name to try to load |
bfd61161d752
HSAIL: support for using Okra simulator without needing to configure PATH and LD_LIBRARY_PATH
Doug Simon <doug.simon@oracle.com>
parents:
13115
diff
changeset
|
146 // the isRequired boolean specifies whether it is an error if the |
bfd61161d752
HSAIL: support for using Okra simulator without needing to configure PATH and LD_LIBRARY_PATH
Doug Simon <doug.simon@oracle.com>
parents:
13115
diff
changeset
|
147 // probe does not find the okra library |
bfd61161d752
HSAIL: support for using Okra simulator without needing to configure PATH and LD_LIBRARY_PATH
Doug Simon <doug.simon@oracle.com>
parents:
13115
diff
changeset
|
148 char *buffer = (char*)malloc(STD_BUFFER_SIZE); |
13097 | 149 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:
13115
diff
changeset
|
150 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:
13115
diff
changeset
|
151 } |
bfd61161d752
HSAIL: support for using Okra simulator without needing to configure PATH and LD_LIBRARY_PATH
Doug Simon <doug.simon@oracle.com>
parents:
13115
diff
changeset
|
152 void *handle = os::dll_load(okra_library_name, buffer, STD_BUFFER_SIZE); |
bfd61161d752
HSAIL: support for using Okra simulator without needing to configure PATH and LD_LIBRARY_PATH
Doug Simon <doug.simon@oracle.com>
parents:
13115
diff
changeset
|
153 // 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:
13115
diff
changeset
|
154 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:
13115
diff
changeset
|
155 if ((handle == NULL) && (okra_lib_name_from_env_var != NULL)) { |
bfd61161d752
HSAIL: support for using Okra simulator without needing to configure PATH and LD_LIBRARY_PATH
Doug Simon <doug.simon@oracle.com>
parents:
13115
diff
changeset
|
156 handle = os::dll_load(okra_lib_name_from_env_var, buffer, STD_BUFFER_SIZE); |
bfd61161d752
HSAIL: support for using Okra simulator without needing to configure PATH and LD_LIBRARY_PATH
Doug Simon <doug.simon@oracle.com>
parents:
13115
diff
changeset
|
157 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:
13115
diff
changeset
|
158 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:
13115
diff
changeset
|
159 } |
bfd61161d752
HSAIL: support for using Okra simulator without needing to configure PATH and LD_LIBRARY_PATH
Doug Simon <doug.simon@oracle.com>
parents:
13115
diff
changeset
|
160 } |
bfd61161d752
HSAIL: support for using Okra simulator without needing to configure PATH and LD_LIBRARY_PATH
Doug Simon <doug.simon@oracle.com>
parents:
13115
diff
changeset
|
161 free(buffer); |
bfd61161d752
HSAIL: support for using Okra simulator without needing to configure PATH and LD_LIBRARY_PATH
Doug Simon <doug.simon@oracle.com>
parents:
13115
diff
changeset
|
162 |
bfd61161d752
HSAIL: support for using Okra simulator without needing to configure PATH and LD_LIBRARY_PATH
Doug Simon <doug.simon@oracle.com>
parents:
13115
diff
changeset
|
163 if ((handle == NULL) && !isRequired) { |
bfd61161d752
HSAIL: support for using Okra simulator without needing to configure PATH and LD_LIBRARY_PATH
Doug Simon <doug.simon@oracle.com>
parents:
13115
diff
changeset
|
164 // return true for now but we will probe again later |
bfd61161d752
HSAIL: support for using Okra simulator without needing to configure PATH and LD_LIBRARY_PATH
Doug Simon <doug.simon@oracle.com>
parents:
13115
diff
changeset
|
165 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:
13115
diff
changeset
|
166 tty->print_cr("[HSAIL] library load not in PATH, waiting for Java to put in tmpdir."); |
bfd61161d752
HSAIL: support for using Okra simulator without needing to configure PATH and LD_LIBRARY_PATH
Doug Simon <doug.simon@oracle.com>
parents:
13115
diff
changeset
|
167 } |
bfd61161d752
HSAIL: support for using Okra simulator without needing to configure PATH and LD_LIBRARY_PATH
Doug Simon <doug.simon@oracle.com>
parents:
13115
diff
changeset
|
168 return true; |
13097 | 169 } |
13740
bfd61161d752
HSAIL: support for using Okra simulator without needing to configure PATH and LD_LIBRARY_PATH
Doug Simon <doug.simon@oracle.com>
parents:
13115
diff
changeset
|
170 |
bfd61161d752
HSAIL: support for using Okra simulator without needing to configure PATH and LD_LIBRARY_PATH
Doug Simon <doug.simon@oracle.com>
parents:
13115
diff
changeset
|
171 if ((handle == NULL) && isRequired) { |
bfd61161d752
HSAIL: support for using Okra simulator without needing to configure PATH and LD_LIBRARY_PATH
Doug Simon <doug.simon@oracle.com>
parents:
13115
diff
changeset
|
172 // 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:
13115
diff
changeset
|
173 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:
13115
diff
changeset
|
174 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:
13115
diff
changeset
|
175 } |
bfd61161d752
HSAIL: support for using Okra simulator without needing to configure PATH and LD_LIBRARY_PATH
Doug Simon <doug.simon@oracle.com>
parents:
13115
diff
changeset
|
176 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:
13115
diff
changeset
|
177 } |
bfd61161d752
HSAIL: support for using Okra simulator without needing to configure PATH and LD_LIBRARY_PATH
Doug Simon <doug.simon@oracle.com>
parents:
13115
diff
changeset
|
178 |
bfd61161d752
HSAIL: support for using Okra simulator without needing to configure PATH and LD_LIBRARY_PATH
Doug Simon <doug.simon@oracle.com>
parents:
13115
diff
changeset
|
179 // 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:
13115
diff
changeset
|
180 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:
13115
diff
changeset
|
181 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:
13115
diff
changeset
|
182 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:
13115
diff
changeset
|
183 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:
13115
diff
changeset
|
184 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:
13115
diff
changeset
|
185 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:
13115
diff
changeset
|
186 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:
13115
diff
changeset
|
187 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:
13115
diff
changeset
|
188 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:
13115
diff
changeset
|
189 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:
13115
diff
changeset
|
190 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:
13115
diff
changeset
|
191 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:
13115
diff
changeset
|
192 |
bfd61161d752
HSAIL: support for using Okra simulator without needing to configure PATH and LD_LIBRARY_PATH
Doug Simon <doug.simon@oracle.com>
parents:
13115
diff
changeset
|
193 // if we made it this far, real success |
bfd61161d752
HSAIL: support for using Okra simulator without needing to configure PATH and LD_LIBRARY_PATH
Doug Simon <doug.simon@oracle.com>
parents:
13115
diff
changeset
|
194 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
|
195 } |