Mercurial > hg > truffle
annotate src/gpu/ptx/vm/gpu_ptx.cpp @ 18477:7b5106be0f18
Use correct LIRKind in HSAIL metaspace pointer compression/uncompression op.
author | Roland Schatz <roland.schatz@oracle.com> |
---|---|
date | Thu, 20 Nov 2014 14:00:51 +0100 |
parents | f55f2d400797 |
children |
rev | line source |
---|---|
10879 | 1 /* |
2 * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. | |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | |
4 * | |
5 * This code is free software; you can redistribute it and/or modify it | |
6 * under the terms of the GNU General Public License version 2 only, as | |
7 * published by the Free Software Foundation. | |
8 * | |
9 * This code is distributed in the hope that it will be useful, but WITHOUT | |
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
12 * version 2 for more details (a copy is included in the LICENSE file that | |
13 * accompanied this code). | |
14 * | |
15 * You should have received a copy of the GNU General Public License version | |
16 * 2 along with this work; if not, write to the Free Software Foundation, | |
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
18 * | |
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | |
20 * or visit www.oracle.com if you need additional information or have any | |
21 * questions. | |
22 * | |
23 */ | |
24 | |
25 #include "precompiled.hpp" | |
11284
d876002b98e6
ptx: fix include for non-precompiledheader build in gpu_ptx.cpp
Bernhard Urban <bernhard.urban@jku.at>
parents:
11283
diff
changeset
|
26 #include "runtime/javaCalls.hpp" |
10879 | 27 #include "runtime/gpu.hpp" |
13888
51584f76462d
pulled Ptx and Hsail classes out of gpu class namespace
Doug Simon <doug.simon@oracle.com>
parents:
13851
diff
changeset
|
28 #include "ptx/vm/gpu_ptx.hpp" |
10879 | 29 #include "utilities/globalDefinitions.hpp" |
30 #include "utilities/ostream.hpp" | |
10883
5fcb30bcb90a
Fix compilation without precompiled headers.
Roland Schatz <roland.schatz@oracle.com>
parents:
10882
diff
changeset
|
31 #include "memory/allocation.hpp" |
5fcb30bcb90a
Fix compilation without precompiled headers.
Roland Schatz <roland.schatz@oracle.com>
parents:
10882
diff
changeset
|
32 #include "memory/allocation.inline.hpp" |
13832
ab370d74a8eb
implemented GC locking for duration of a PTX kernel call
Doug Simon <doug.simon@oracle.com>
parents:
13819
diff
changeset
|
33 #include "memory/gcLocker.inline.hpp" |
13624
220ed109bf77
initial code for calling PTX kernel code from Java with parameter marshaling and return value unmarshaling performed by a wrapper specified via manual graph construction
Doug Simon <doug.simon@oracle.com>
parents:
12653
diff
changeset
|
34 #include "runtime/interfaceSupport.hpp" |
13848
b97e2515d392
removed PTXKernelArguments; added mechanism for printing incoming kernel arguments
Doug Simon <doug.simon@oracle.com>
parents:
13834
diff
changeset
|
35 #include "runtime/vframe.hpp" |
13819
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13753
diff
changeset
|
36 #include "graal/graalEnv.hpp" |
15582
063ec2920d21
made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents:
15177
diff
changeset
|
37 #include "graal/graalRuntime.hpp" |
13848
b97e2515d392
removed PTXKernelArguments; added mechanism for printing incoming kernel arguments
Doug Simon <doug.simon@oracle.com>
parents:
13834
diff
changeset
|
38 |
b97e2515d392
removed PTXKernelArguments; added mechanism for printing incoming kernel arguments
Doug Simon <doug.simon@oracle.com>
parents:
13834
diff
changeset
|
39 #define T_BYTE_SIZE 1 |
b97e2515d392
removed PTXKernelArguments; added mechanism for printing incoming kernel arguments
Doug Simon <doug.simon@oracle.com>
parents:
13834
diff
changeset
|
40 #define T_BOOLEAN_SIZE 4 |
b97e2515d392
removed PTXKernelArguments; added mechanism for printing incoming kernel arguments
Doug Simon <doug.simon@oracle.com>
parents:
13834
diff
changeset
|
41 #define T_INT_BYTE_SIZE 4 |
b97e2515d392
removed PTXKernelArguments; added mechanism for printing incoming kernel arguments
Doug Simon <doug.simon@oracle.com>
parents:
13834
diff
changeset
|
42 #define T_FLOAT_BYTE_SIZE 4 |
b97e2515d392
removed PTXKernelArguments; added mechanism for printing incoming kernel arguments
Doug Simon <doug.simon@oracle.com>
parents:
13834
diff
changeset
|
43 #define T_DOUBLE_BYTE_SIZE 8 |
b97e2515d392
removed PTXKernelArguments; added mechanism for printing incoming kernel arguments
Doug Simon <doug.simon@oracle.com>
parents:
13834
diff
changeset
|
44 #define T_LONG_BYTE_SIZE 8 |
b97e2515d392
removed PTXKernelArguments; added mechanism for printing incoming kernel arguments
Doug Simon <doug.simon@oracle.com>
parents:
13834
diff
changeset
|
45 #define T_OBJECT_BYTE_SIZE sizeof(intptr_t) |
b97e2515d392
removed PTXKernelArguments; added mechanism for printing incoming kernel arguments
Doug Simon <doug.simon@oracle.com>
parents:
13834
diff
changeset
|
46 #define T_ARRAY_BYTE_SIZE sizeof(intptr_t) |
10879 | 47 |
13819
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13753
diff
changeset
|
48 // 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:
13753
diff
changeset
|
49 #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:
13753
diff
changeset
|
50 JNIEXPORT result_type JNICALL name signature { \ |
13922
0995dcbd6dd8
Change CUDA context management to support multiple executions of a kernel. Exclude GPU offloading of lambdas from java.* library code.
S.Bharadwaj Yadavalli <bharadwaj.yadavalli@oracle.com>
parents:
13888
diff
changeset
|
51 if (TraceGPUInteraction) tty->print_cr("[CUDA] " #name); \ |
13819
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13753
diff
changeset
|
52 GRAAL_VM_ENTRY_MARK; \ |
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13753
diff
changeset
|
53 |
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13753
diff
changeset
|
54 // 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:
13753
diff
changeset
|
55 // 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:
13753
diff
changeset
|
56 #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:
13753
diff
changeset
|
57 JNIEXPORT result_type JNICALL name signature { \ |
13888
51584f76462d
pulled Ptx and Hsail classes out of gpu class namespace
Doug Simon <doug.simon@oracle.com>
parents:
13851
diff
changeset
|
58 if (TraceGPUInteraction) tty->print_cr("[CUDA] Ptx::" #name); \ |
13819
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13753
diff
changeset
|
59 |
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13753
diff
changeset
|
60 #define GPU_END } |
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13753
diff
changeset
|
61 |
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13753
diff
changeset
|
62 #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:
13753
diff
changeset
|
63 #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:
13753
diff
changeset
|
64 |
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13753
diff
changeset
|
65 #define STRING "Ljava/lang/String;" |
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13753
diff
changeset
|
66 |
13888
51584f76462d
pulled Ptx and Hsail classes out of gpu class namespace
Doug Simon <doug.simon@oracle.com>
parents:
13851
diff
changeset
|
67 JNINativeMethod Ptx::PTX_methods[] = { |
51584f76462d
pulled Ptx and Hsail classes out of gpu class namespace
Doug Simon <doug.simon@oracle.com>
parents:
13851
diff
changeset
|
68 {CC"initialize", CC"()Z", FN_PTR(Ptx::initialize)}, |
51584f76462d
pulled Ptx and Hsail classes out of gpu class namespace
Doug Simon <doug.simon@oracle.com>
parents:
13851
diff
changeset
|
69 {CC"generateKernel", CC"([B" STRING ")J", FN_PTR(Ptx::generate_kernel)}, |
51584f76462d
pulled Ptx and Hsail classes out of gpu class namespace
Doug Simon <doug.simon@oracle.com>
parents:
13851
diff
changeset
|
70 {CC"getLaunchKernelAddress", CC"()J", FN_PTR(Ptx::get_execute_kernel_from_vm_address)}, |
51584f76462d
pulled Ptx and Hsail classes out of gpu class namespace
Doug Simon <doug.simon@oracle.com>
parents:
13851
diff
changeset
|
71 {CC"getAvailableProcessors0", CC"()I", FN_PTR(Ptx::get_total_cores)}, |
13922
0995dcbd6dd8
Change CUDA context management to support multiple executions of a kernel. Exclude GPU offloading of lambdas from java.* library code.
S.Bharadwaj Yadavalli <bharadwaj.yadavalli@oracle.com>
parents:
13888
diff
changeset
|
72 {CC"destroyContext", CC"()V", FN_PTR(Ptx::destroy_ptx_context)}, |
13819
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13753
diff
changeset
|
73 }; |
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13753
diff
changeset
|
74 |
13922
0995dcbd6dd8
Change CUDA context management to support multiple executions of a kernel. Exclude GPU offloading of lambdas from java.* library code.
S.Bharadwaj Yadavalli <bharadwaj.yadavalli@oracle.com>
parents:
13888
diff
changeset
|
75 void * Ptx::_device_context = 0; |
13888
51584f76462d
pulled Ptx and Hsail classes out of gpu class namespace
Doug Simon <doug.simon@oracle.com>
parents:
13851
diff
changeset
|
76 int Ptx::_cu_device = 0; |
10879 | 77 |
13888
51584f76462d
pulled Ptx and Hsail classes out of gpu class namespace
Doug Simon <doug.simon@oracle.com>
parents:
13851
diff
changeset
|
78 Ptx::cuda_cu_init_func_t Ptx::_cuda_cu_init; |
51584f76462d
pulled Ptx and Hsail classes out of gpu class namespace
Doug Simon <doug.simon@oracle.com>
parents:
13851
diff
changeset
|
79 Ptx::cuda_cu_ctx_create_func_t Ptx::_cuda_cu_ctx_create; |
51584f76462d
pulled Ptx and Hsail classes out of gpu class namespace
Doug Simon <doug.simon@oracle.com>
parents:
13851
diff
changeset
|
80 Ptx::cuda_cu_ctx_destroy_func_t Ptx::_cuda_cu_ctx_destroy; |
51584f76462d
pulled Ptx and Hsail classes out of gpu class namespace
Doug Simon <doug.simon@oracle.com>
parents:
13851
diff
changeset
|
81 Ptx::cuda_cu_ctx_synchronize_func_t Ptx::_cuda_cu_ctx_synchronize; |
51584f76462d
pulled Ptx and Hsail classes out of gpu class namespace
Doug Simon <doug.simon@oracle.com>
parents:
13851
diff
changeset
|
82 Ptx::cuda_cu_ctx_get_current_func_t Ptx::_cuda_cu_ctx_get_current; |
51584f76462d
pulled Ptx and Hsail classes out of gpu class namespace
Doug Simon <doug.simon@oracle.com>
parents:
13851
diff
changeset
|
83 Ptx::cuda_cu_ctx_set_current_func_t Ptx::_cuda_cu_ctx_set_current; |
51584f76462d
pulled Ptx and Hsail classes out of gpu class namespace
Doug Simon <doug.simon@oracle.com>
parents:
13851
diff
changeset
|
84 Ptx::cuda_cu_device_get_count_func_t Ptx::_cuda_cu_device_get_count; |
51584f76462d
pulled Ptx and Hsail classes out of gpu class namespace
Doug Simon <doug.simon@oracle.com>
parents:
13851
diff
changeset
|
85 Ptx::cuda_cu_device_get_name_func_t Ptx::_cuda_cu_device_get_name; |
51584f76462d
pulled Ptx and Hsail classes out of gpu class namespace
Doug Simon <doug.simon@oracle.com>
parents:
13851
diff
changeset
|
86 Ptx::cuda_cu_device_get_func_t Ptx::_cuda_cu_device_get; |
51584f76462d
pulled Ptx and Hsail classes out of gpu class namespace
Doug Simon <doug.simon@oracle.com>
parents:
13851
diff
changeset
|
87 Ptx::cuda_cu_device_compute_capability_func_t Ptx::_cuda_cu_device_compute_capability; |
51584f76462d
pulled Ptx and Hsail classes out of gpu class namespace
Doug Simon <doug.simon@oracle.com>
parents:
13851
diff
changeset
|
88 Ptx::cuda_cu_device_get_attribute_func_t Ptx::_cuda_cu_device_get_attribute; |
51584f76462d
pulled Ptx and Hsail classes out of gpu class namespace
Doug Simon <doug.simon@oracle.com>
parents:
13851
diff
changeset
|
89 Ptx::cuda_cu_launch_kernel_func_t Ptx::_cuda_cu_launch_kernel; |
51584f76462d
pulled Ptx and Hsail classes out of gpu class namespace
Doug Simon <doug.simon@oracle.com>
parents:
13851
diff
changeset
|
90 Ptx::cuda_cu_module_get_function_func_t Ptx::_cuda_cu_module_get_function; |
51584f76462d
pulled Ptx and Hsail classes out of gpu class namespace
Doug Simon <doug.simon@oracle.com>
parents:
13851
diff
changeset
|
91 Ptx::cuda_cu_module_load_data_ex_func_t Ptx::_cuda_cu_module_load_data_ex; |
51584f76462d
pulled Ptx and Hsail classes out of gpu class namespace
Doug Simon <doug.simon@oracle.com>
parents:
13851
diff
changeset
|
92 Ptx::cuda_cu_memcpy_htod_func_t Ptx::_cuda_cu_memcpy_htod; |
51584f76462d
pulled Ptx and Hsail classes out of gpu class namespace
Doug Simon <doug.simon@oracle.com>
parents:
13851
diff
changeset
|
93 Ptx::cuda_cu_memcpy_dtoh_func_t Ptx::_cuda_cu_memcpy_dtoh; |
51584f76462d
pulled Ptx and Hsail classes out of gpu class namespace
Doug Simon <doug.simon@oracle.com>
parents:
13851
diff
changeset
|
94 Ptx::cuda_cu_memalloc_func_t Ptx::_cuda_cu_memalloc; |
51584f76462d
pulled Ptx and Hsail classes out of gpu class namespace
Doug Simon <doug.simon@oracle.com>
parents:
13851
diff
changeset
|
95 Ptx::cuda_cu_memfree_func_t Ptx::_cuda_cu_memfree; |
51584f76462d
pulled Ptx and Hsail classes out of gpu class namespace
Doug Simon <doug.simon@oracle.com>
parents:
13851
diff
changeset
|
96 Ptx::cuda_cu_mem_host_register_func_t Ptx::_cuda_cu_mem_host_register; |
51584f76462d
pulled Ptx and Hsail classes out of gpu class namespace
Doug Simon <doug.simon@oracle.com>
parents:
13851
diff
changeset
|
97 Ptx::cuda_cu_mem_host_get_device_pointer_func_t Ptx::_cuda_cu_mem_host_get_device_pointer; |
51584f76462d
pulled Ptx and Hsail classes out of gpu class namespace
Doug Simon <doug.simon@oracle.com>
parents:
13851
diff
changeset
|
98 Ptx::cuda_cu_mem_host_unregister_func_t Ptx::_cuda_cu_mem_host_unregister; |
10879 | 99 |
12653
1a7e7011a341
* PTX kernel argument buffer now has naturally aligned arguments as required by PTX JIT compiler.
S.Bharadwaj Yadavalli <bharadwaj.yadavalli@oracle.com>
parents:
12519
diff
changeset
|
100 #define STRINGIFY(x) #x |
1a7e7011a341
* PTX kernel argument buffer now has naturally aligned arguments as required by PTX JIT compiler.
S.Bharadwaj Yadavalli <bharadwaj.yadavalli@oracle.com>
parents:
12519
diff
changeset
|
101 |
1a7e7011a341
* PTX kernel argument buffer now has naturally aligned arguments as required by PTX JIT compiler.
S.Bharadwaj Yadavalli <bharadwaj.yadavalli@oracle.com>
parents:
12519
diff
changeset
|
102 #define LOOKUP_CUDA_FUNCTION(name, alias) \ |
1a7e7011a341
* PTX kernel argument buffer now has naturally aligned arguments as required by PTX JIT compiler.
S.Bharadwaj Yadavalli <bharadwaj.yadavalli@oracle.com>
parents:
12519
diff
changeset
|
103 _##alias = \ |
1a7e7011a341
* PTX kernel argument buffer now has naturally aligned arguments as required by PTX JIT compiler.
S.Bharadwaj Yadavalli <bharadwaj.yadavalli@oracle.com>
parents:
12519
diff
changeset
|
104 CAST_TO_FN_PTR(alias##_func_t, os::dll_lookup(handle, STRINGIFY(name))); \ |
1a7e7011a341
* PTX kernel argument buffer now has naturally aligned arguments as required by PTX JIT compiler.
S.Bharadwaj Yadavalli <bharadwaj.yadavalli@oracle.com>
parents:
12519
diff
changeset
|
105 if (_##alias == NULL) { \ |
1a7e7011a341
* PTX kernel argument buffer now has naturally aligned arguments as required by PTX JIT compiler.
S.Bharadwaj Yadavalli <bharadwaj.yadavalli@oracle.com>
parents:
12519
diff
changeset
|
106 tty->print_cr("[CUDA] ***** Error: Failed to lookup %s", STRINGIFY(name)); \ |
13819
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13753
diff
changeset
|
107 return false; \ |
12653
1a7e7011a341
* PTX kernel argument buffer now has naturally aligned arguments as required by PTX JIT compiler.
S.Bharadwaj Yadavalli <bharadwaj.yadavalli@oracle.com>
parents:
12519
diff
changeset
|
108 } \ |
1a7e7011a341
* PTX kernel argument buffer now has naturally aligned arguments as required by PTX JIT compiler.
S.Bharadwaj Yadavalli <bharadwaj.yadavalli@oracle.com>
parents:
12519
diff
changeset
|
109 |
1a7e7011a341
* PTX kernel argument buffer now has naturally aligned arguments as required by PTX JIT compiler.
S.Bharadwaj Yadavalli <bharadwaj.yadavalli@oracle.com>
parents:
12519
diff
changeset
|
110 #define LOOKUP_CUDA_V2_FUNCTION(name, alias) LOOKUP_CUDA_FUNCTION(name##_v2, alias) |
11842
8d8f63069f58
PTX warp limiter to available GPU processors
Morris Meyer <morris.meyer@oracle.com>
parents:
11822
diff
changeset
|
111 |
8d8f63069f58
PTX warp limiter to available GPU processors
Morris Meyer <morris.meyer@oracle.com>
parents:
11822
diff
changeset
|
112 /* |
8d8f63069f58
PTX warp limiter to available GPU processors
Morris Meyer <morris.meyer@oracle.com>
parents:
11822
diff
changeset
|
113 * see http://en.wikipedia.org/wiki/CUDA#Supported_GPUs |
8d8f63069f58
PTX warp limiter to available GPU processors
Morris Meyer <morris.meyer@oracle.com>
parents:
11822
diff
changeset
|
114 */ |
13888
51584f76462d
pulled Ptx and Hsail classes out of gpu class namespace
Doug Simon <doug.simon@oracle.com>
parents:
13851
diff
changeset
|
115 int Ptx::ncores(int major, int minor) { |
11843
372bacc13022
gtx_ptx.cpp: fix switch default label and operator precedence in ncores().
Andreas Woess <andreas.woess@jku.at>
parents:
11842
diff
changeset
|
116 int device_type = (major << 4) + minor; |
11842
8d8f63069f58
PTX warp limiter to available GPU processors
Morris Meyer <morris.meyer@oracle.com>
parents:
11822
diff
changeset
|
117 |
8d8f63069f58
PTX warp limiter to available GPU processors
Morris Meyer <morris.meyer@oracle.com>
parents:
11822
diff
changeset
|
118 switch (device_type) { |
8d8f63069f58
PTX warp limiter to available GPU processors
Morris Meyer <morris.meyer@oracle.com>
parents:
11822
diff
changeset
|
119 case 0x10: return 8; |
8d8f63069f58
PTX warp limiter to available GPU processors
Morris Meyer <morris.meyer@oracle.com>
parents:
11822
diff
changeset
|
120 case 0x11: return 8; |
8d8f63069f58
PTX warp limiter to available GPU processors
Morris Meyer <morris.meyer@oracle.com>
parents:
11822
diff
changeset
|
121 case 0x12: return 8; |
8d8f63069f58
PTX warp limiter to available GPU processors
Morris Meyer <morris.meyer@oracle.com>
parents:
11822
diff
changeset
|
122 case 0x13: return 8; |
8d8f63069f58
PTX warp limiter to available GPU processors
Morris Meyer <morris.meyer@oracle.com>
parents:
11822
diff
changeset
|
123 case 0x20: return 32; |
8d8f63069f58
PTX warp limiter to available GPU processors
Morris Meyer <morris.meyer@oracle.com>
parents:
11822
diff
changeset
|
124 case 0x21: return 48; |
8d8f63069f58
PTX warp limiter to available GPU processors
Morris Meyer <morris.meyer@oracle.com>
parents:
11822
diff
changeset
|
125 case 0x30: return 192; |
8d8f63069f58
PTX warp limiter to available GPU processors
Morris Meyer <morris.meyer@oracle.com>
parents:
11822
diff
changeset
|
126 case 0x35: return 192; |
11843
372bacc13022
gtx_ptx.cpp: fix switch default label and operator precedence in ncores().
Andreas Woess <andreas.woess@jku.at>
parents:
11842
diff
changeset
|
127 default: |
11842
8d8f63069f58
PTX warp limiter to available GPU processors
Morris Meyer <morris.meyer@oracle.com>
parents:
11822
diff
changeset
|
128 tty->print_cr("[CUDA] Warning: Unhandled device %x", device_type); |
8d8f63069f58
PTX warp limiter to available GPU processors
Morris Meyer <morris.meyer@oracle.com>
parents:
11822
diff
changeset
|
129 return 0; |
8d8f63069f58
PTX warp limiter to available GPU processors
Morris Meyer <morris.meyer@oracle.com>
parents:
11822
diff
changeset
|
130 } |
8d8f63069f58
PTX warp limiter to available GPU processors
Morris Meyer <morris.meyer@oracle.com>
parents:
11822
diff
changeset
|
131 } |
8d8f63069f58
PTX warp limiter to available GPU processors
Morris Meyer <morris.meyer@oracle.com>
parents:
11822
diff
changeset
|
132 |
13888
51584f76462d
pulled Ptx and Hsail classes out of gpu class namespace
Doug Simon <doug.simon@oracle.com>
parents:
13851
diff
changeset
|
133 bool Ptx::register_natives(JNIEnv* env) { |
13819
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13753
diff
changeset
|
134 jclass klass = env->FindClass("com/oracle/graal/hotspot/ptx/PTXHotSpotBackend"); |
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13753
diff
changeset
|
135 if (klass == NULL) { |
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13753
diff
changeset
|
136 if (TraceGPUInteraction) { |
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13753
diff
changeset
|
137 tty->print_cr("PTXHotSpotBackend class not found"); |
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13753
diff
changeset
|
138 } |
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13753
diff
changeset
|
139 return false; |
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13753
diff
changeset
|
140 } |
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13753
diff
changeset
|
141 jint status = env->RegisterNatives(klass, PTX_methods, sizeof(PTX_methods) / sizeof(JNINativeMethod)); |
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13753
diff
changeset
|
142 if (status != JNI_OK) { |
13888
51584f76462d
pulled Ptx and Hsail classes out of gpu class namespace
Doug Simon <doug.simon@oracle.com>
parents:
13851
diff
changeset
|
143 if (true || TraceGPUInteraction) { |
13819
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13753
diff
changeset
|
144 tty->print_cr("Error registering natives for PTXHotSpotBackend: %d", status); |
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13753
diff
changeset
|
145 } |
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13753
diff
changeset
|
146 return false; |
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13753
diff
changeset
|
147 } |
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13753
diff
changeset
|
148 return true; |
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13753
diff
changeset
|
149 } |
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13753
diff
changeset
|
150 |
13888
51584f76462d
pulled Ptx and Hsail classes out of gpu class namespace
Doug Simon <doug.simon@oracle.com>
parents:
13851
diff
changeset
|
151 GPU_ENTRY(jboolean, Ptx::initialize, (JNIEnv *env, jclass)) |
13819
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13753
diff
changeset
|
152 |
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13753
diff
changeset
|
153 if (!link()) { |
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13753
diff
changeset
|
154 return false; |
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13753
diff
changeset
|
155 } |
10879 | 156 |
157 /* Initialize CUDA driver API */ | |
158 int status = _cuda_cu_init(0); | |
159 if (status != GRAAL_CUDA_SUCCESS) { | |
13819
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13753
diff
changeset
|
160 if (TraceGPUInteraction) { |
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13753
diff
changeset
|
161 tty->print_cr("Failed to initialize CUDA device: %d", status); |
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13753
diff
changeset
|
162 } |
10879 | 163 return false; |
164 } | |
11527
c99e65785936
Improvements to PTX codegen; allows more PTX tests that run on the device to pass.
bharadwaj
parents:
11485
diff
changeset
|
165 |
10879 | 166 if (TraceGPUInteraction) { |
167 tty->print_cr("CUDA driver initialization: Success"); | |
168 } | |
169 | |
170 /* Get the number of compute-capable device count */ | |
171 int device_count = 0; | |
172 status = _cuda_cu_device_get_count(&device_count); | |
173 if (status != GRAAL_CUDA_SUCCESS) { | |
174 tty->print_cr("[CUDA] Failed to get compute-capable device count"); | |
175 return false; | |
176 } | |
177 | |
178 if (device_count == 0) { | |
179 tty->print_cr("[CUDA] Found no device supporting CUDA"); | |
180 return false; | |
181 } | |
182 | |
183 if (TraceGPUInteraction) { | |
184 tty->print_cr("[CUDA] Number of compute-capable devices found: %d", device_count); | |
185 } | |
11527
c99e65785936
Improvements to PTX codegen; allows more PTX tests that run on the device to pass.
bharadwaj
parents:
11485
diff
changeset
|
186 |
10879 | 187 /* Get the handle to the first compute device */ |
188 int device_id = 0; | |
189 /* Compute-capable device handle */ | |
11485
49bb1bc983c6
Implement several missing PTX codegen features; return value capture and method args passing of java method executed on GPU.
bharadwaj
parents:
11284
diff
changeset
|
190 status = _cuda_cu_device_get(&_cu_device, device_id); |
10879 | 191 |
192 if (status != GRAAL_CUDA_SUCCESS) { | |
193 tty->print_cr("[CUDA] Failed to get handle of first compute-capable device i.e., the one at ordinal: %d", device_id); | |
194 return false; | |
195 } | |
196 | |
197 if (TraceGPUInteraction) { | |
198 tty->print_cr("[CUDA] Got the handle of first compute-device"); | |
199 } | |
200 | |
201 /* Get device attributes */ | |
13828
5c8a3c09397b
Add additional device checks and compute capability checks for CUDA devices found on Linux.
S.Bharadwaj Yadavalli <bharadwaj.yadavalli@oracle.com>
parents:
13819
diff
changeset
|
202 int minor, major; |
11842
8d8f63069f58
PTX warp limiter to available GPU processors
Morris Meyer <morris.meyer@oracle.com>
parents:
11822
diff
changeset
|
203 int unified_addressing; |
13828
5c8a3c09397b
Add additional device checks and compute capability checks for CUDA devices found on Linux.
S.Bharadwaj Yadavalli <bharadwaj.yadavalli@oracle.com>
parents:
13819
diff
changeset
|
204 float version = 0.0; |
5c8a3c09397b
Add additional device checks and compute capability checks for CUDA devices found on Linux.
S.Bharadwaj Yadavalli <bharadwaj.yadavalli@oracle.com>
parents:
13819
diff
changeset
|
205 |
5c8a3c09397b
Add additional device checks and compute capability checks for CUDA devices found on Linux.
S.Bharadwaj Yadavalli <bharadwaj.yadavalli@oracle.com>
parents:
13819
diff
changeset
|
206 /* Get the compute capability of the device found */ |
5c8a3c09397b
Add additional device checks and compute capability checks for CUDA devices found on Linux.
S.Bharadwaj Yadavalli <bharadwaj.yadavalli@oracle.com>
parents:
13819
diff
changeset
|
207 status = _cuda_cu_device_get_attribute(&minor, GRAAL_CU_DEVICE_ATTRIBUTE_COMPUTE_CAPABILITY_MINOR, _cu_device); |
5c8a3c09397b
Add additional device checks and compute capability checks for CUDA devices found on Linux.
S.Bharadwaj Yadavalli <bharadwaj.yadavalli@oracle.com>
parents:
13819
diff
changeset
|
208 if (status != GRAAL_CUDA_SUCCESS) { |
5c8a3c09397b
Add additional device checks and compute capability checks for CUDA devices found on Linux.
S.Bharadwaj Yadavalli <bharadwaj.yadavalli@oracle.com>
parents:
13819
diff
changeset
|
209 tty->print_cr("[CUDA] Failed to get minor attribute of device: %d", _cu_device); |
5c8a3c09397b
Add additional device checks and compute capability checks for CUDA devices found on Linux.
S.Bharadwaj Yadavalli <bharadwaj.yadavalli@oracle.com>
parents:
13819
diff
changeset
|
210 return false; |
5c8a3c09397b
Add additional device checks and compute capability checks for CUDA devices found on Linux.
S.Bharadwaj Yadavalli <bharadwaj.yadavalli@oracle.com>
parents:
13819
diff
changeset
|
211 } |
5c8a3c09397b
Add additional device checks and compute capability checks for CUDA devices found on Linux.
S.Bharadwaj Yadavalli <bharadwaj.yadavalli@oracle.com>
parents:
13819
diff
changeset
|
212 status = _cuda_cu_device_get_attribute(&major, GRAAL_CU_DEVICE_ATTRIBUTE_COMPUTE_CAPABILITY_MAJOR, _cu_device); |
5c8a3c09397b
Add additional device checks and compute capability checks for CUDA devices found on Linux.
S.Bharadwaj Yadavalli <bharadwaj.yadavalli@oracle.com>
parents:
13819
diff
changeset
|
213 if (status != GRAAL_CUDA_SUCCESS) { |
5c8a3c09397b
Add additional device checks and compute capability checks for CUDA devices found on Linux.
S.Bharadwaj Yadavalli <bharadwaj.yadavalli@oracle.com>
parents:
13819
diff
changeset
|
214 tty->print_cr("[CUDA] Failed to get major attribute of device: %d", _cu_device); |
5c8a3c09397b
Add additional device checks and compute capability checks for CUDA devices found on Linux.
S.Bharadwaj Yadavalli <bharadwaj.yadavalli@oracle.com>
parents:
13819
diff
changeset
|
215 return false; |
5c8a3c09397b
Add additional device checks and compute capability checks for CUDA devices found on Linux.
S.Bharadwaj Yadavalli <bharadwaj.yadavalli@oracle.com>
parents:
13819
diff
changeset
|
216 } |
5c8a3c09397b
Add additional device checks and compute capability checks for CUDA devices found on Linux.
S.Bharadwaj Yadavalli <bharadwaj.yadavalli@oracle.com>
parents:
13819
diff
changeset
|
217 |
5c8a3c09397b
Add additional device checks and compute capability checks for CUDA devices found on Linux.
S.Bharadwaj Yadavalli <bharadwaj.yadavalli@oracle.com>
parents:
13819
diff
changeset
|
218 /* Check if the device supports atleast GRAAL_SUPPORTED_COMPUTE_CAPABILITY_VERSION */ |
5c8a3c09397b
Add additional device checks and compute capability checks for CUDA devices found on Linux.
S.Bharadwaj Yadavalli <bharadwaj.yadavalli@oracle.com>
parents:
13819
diff
changeset
|
219 version = (float) major + ((float) minor)/10; |
5c8a3c09397b
Add additional device checks and compute capability checks for CUDA devices found on Linux.
S.Bharadwaj Yadavalli <bharadwaj.yadavalli@oracle.com>
parents:
13819
diff
changeset
|
220 |
5c8a3c09397b
Add additional device checks and compute capability checks for CUDA devices found on Linux.
S.Bharadwaj Yadavalli <bharadwaj.yadavalli@oracle.com>
parents:
13819
diff
changeset
|
221 if (version < GRAAL_SUPPORTED_COMPUTE_CAPABILITY_VERSION) { |
13922
0995dcbd6dd8
Change CUDA context management to support multiple executions of a kernel. Exclude GPU offloading of lambdas from java.* library code.
S.Bharadwaj Yadavalli <bharadwaj.yadavalli@oracle.com>
parents:
13888
diff
changeset
|
222 tty->print_cr("[CUDA] Only cuda compute capability %.1f and later supported. Device %d supports %.1f", |
0995dcbd6dd8
Change CUDA context management to support multiple executions of a kernel. Exclude GPU offloading of lambdas from java.* library code.
S.Bharadwaj Yadavalli <bharadwaj.yadavalli@oracle.com>
parents:
13888
diff
changeset
|
223 (float) GRAAL_SUPPORTED_COMPUTE_CAPABILITY_VERSION, _cu_device, version); |
13828
5c8a3c09397b
Add additional device checks and compute capability checks for CUDA devices found on Linux.
S.Bharadwaj Yadavalli <bharadwaj.yadavalli@oracle.com>
parents:
13819
diff
changeset
|
224 return false; |
5c8a3c09397b
Add additional device checks and compute capability checks for CUDA devices found on Linux.
S.Bharadwaj Yadavalli <bharadwaj.yadavalli@oracle.com>
parents:
13819
diff
changeset
|
225 } |
5c8a3c09397b
Add additional device checks and compute capability checks for CUDA devices found on Linux.
S.Bharadwaj Yadavalli <bharadwaj.yadavalli@oracle.com>
parents:
13819
diff
changeset
|
226 |
5c8a3c09397b
Add additional device checks and compute capability checks for CUDA devices found on Linux.
S.Bharadwaj Yadavalli <bharadwaj.yadavalli@oracle.com>
parents:
13819
diff
changeset
|
227 if (TraceGPUInteraction) { |
5c8a3c09397b
Add additional device checks and compute capability checks for CUDA devices found on Linux.
S.Bharadwaj Yadavalli <bharadwaj.yadavalli@oracle.com>
parents:
13819
diff
changeset
|
228 tty->print_cr("[CUDA] Device %d supports cuda compute capability %.1f", _cu_device, version); |
5c8a3c09397b
Add additional device checks and compute capability checks for CUDA devices found on Linux.
S.Bharadwaj Yadavalli <bharadwaj.yadavalli@oracle.com>
parents:
13819
diff
changeset
|
229 } |
10879 | 230 |
11485
49bb1bc983c6
Implement several missing PTX codegen features; return value capture and method args passing of java method executed on GPU.
bharadwaj
parents:
11284
diff
changeset
|
231 status = _cuda_cu_device_get_attribute(&unified_addressing, GRAAL_CU_DEVICE_ATTRIBUTE_UNIFIED_ADDRESSING, _cu_device); |
11283
1cd1f8ff70a1
CR-20: PTX kernel invocation with arguments - from Bharadwaj
Morris Meyer <morris.meyer@oracle.com>
parents:
10884
diff
changeset
|
232 |
1cd1f8ff70a1
CR-20: PTX kernel invocation with arguments - from Bharadwaj
Morris Meyer <morris.meyer@oracle.com>
parents:
10884
diff
changeset
|
233 if (status != GRAAL_CUDA_SUCCESS) { |
11485
49bb1bc983c6
Implement several missing PTX codegen features; return value capture and method args passing of java method executed on GPU.
bharadwaj
parents:
11284
diff
changeset
|
234 tty->print_cr("[CUDA] Failed to query unified addressing mode of device: %d", _cu_device); |
11283
1cd1f8ff70a1
CR-20: PTX kernel invocation with arguments - from Bharadwaj
Morris Meyer <morris.meyer@oracle.com>
parents:
10884
diff
changeset
|
235 return false; |
1cd1f8ff70a1
CR-20: PTX kernel invocation with arguments - from Bharadwaj
Morris Meyer <morris.meyer@oracle.com>
parents:
10884
diff
changeset
|
236 } |
14040
2d95cf7a29c8
Fixes PTX test failure and a crash when TraceGPUInteraction flag is specified.
S.Bharadwaj Yadavalli <bharadwaj.yadavalli@oracle.com>
parents:
13922
diff
changeset
|
237 /* The CUDA driver runtime interaction and generated code as implemented requires |
2d95cf7a29c8
Fixes PTX test failure and a crash when TraceGPUInteraction flag is specified.
S.Bharadwaj Yadavalli <bharadwaj.yadavalli@oracle.com>
parents:
13922
diff
changeset
|
238 that the device supports Unified Addressing. |
2d95cf7a29c8
Fixes PTX test failure and a crash when TraceGPUInteraction flag is specified.
S.Bharadwaj Yadavalli <bharadwaj.yadavalli@oracle.com>
parents:
13922
diff
changeset
|
239 */ |
2d95cf7a29c8
Fixes PTX test failure and a crash when TraceGPUInteraction flag is specified.
S.Bharadwaj Yadavalli <bharadwaj.yadavalli@oracle.com>
parents:
13922
diff
changeset
|
240 if (unified_addressing == 0) { |
2d95cf7a29c8
Fixes PTX test failure and a crash when TraceGPUInteraction flag is specified.
S.Bharadwaj Yadavalli <bharadwaj.yadavalli@oracle.com>
parents:
13922
diff
changeset
|
241 tty->print_cr("[CUDA] CUDA device %d does NOT have required Unified Addressing support.", _cu_device); |
2d95cf7a29c8
Fixes PTX test failure and a crash when TraceGPUInteraction flag is specified.
S.Bharadwaj Yadavalli <bharadwaj.yadavalli@oracle.com>
parents:
13922
diff
changeset
|
242 return false; |
2d95cf7a29c8
Fixes PTX test failure and a crash when TraceGPUInteraction flag is specified.
S.Bharadwaj Yadavalli <bharadwaj.yadavalli@oracle.com>
parents:
13922
diff
changeset
|
243 } |
11283
1cd1f8ff70a1
CR-20: PTX kernel invocation with arguments - from Bharadwaj
Morris Meyer <morris.meyer@oracle.com>
parents:
10884
diff
changeset
|
244 |
1cd1f8ff70a1
CR-20: PTX kernel invocation with arguments - from Bharadwaj
Morris Meyer <morris.meyer@oracle.com>
parents:
10884
diff
changeset
|
245 if (TraceGPUInteraction) { |
14040
2d95cf7a29c8
Fixes PTX test failure and a crash when TraceGPUInteraction flag is specified.
S.Bharadwaj Yadavalli <bharadwaj.yadavalli@oracle.com>
parents:
13922
diff
changeset
|
246 tty->print_cr("[CUDA] Device %d has Unified Addressing support", _cu_device); |
11283
1cd1f8ff70a1
CR-20: PTX kernel invocation with arguments - from Bharadwaj
Morris Meyer <morris.meyer@oracle.com>
parents:
10884
diff
changeset
|
247 } |
1cd1f8ff70a1
CR-20: PTX kernel invocation with arguments - from Bharadwaj
Morris Meyer <morris.meyer@oracle.com>
parents:
10884
diff
changeset
|
248 |
10879 | 249 /* Get device name */ |
250 char device_name[256]; | |
11485
49bb1bc983c6
Implement several missing PTX codegen features; return value capture and method args passing of java method executed on GPU.
bharadwaj
parents:
11284
diff
changeset
|
251 status = _cuda_cu_device_get_name(device_name, 256, _cu_device); |
10879 | 252 |
253 if (status != GRAAL_CUDA_SUCCESS) { | |
11485
49bb1bc983c6
Implement several missing PTX codegen features; return value capture and method args passing of java method executed on GPU.
bharadwaj
parents:
11284
diff
changeset
|
254 tty->print_cr("[CUDA] Failed to get name of device: %d", _cu_device); |
10879 | 255 return false; |
256 } | |
257 | |
258 if (TraceGPUInteraction) { | |
259 tty->print_cr("[CUDA] Using %s", device_name); | |
260 } | |
261 | |
13922
0995dcbd6dd8
Change CUDA context management to support multiple executions of a kernel. Exclude GPU offloading of lambdas from java.* library code.
S.Bharadwaj Yadavalli <bharadwaj.yadavalli@oracle.com>
parents:
13888
diff
changeset
|
262 // Create CUDA context to compile and execute the kernel |
0995dcbd6dd8
Change CUDA context management to support multiple executions of a kernel. Exclude GPU offloading of lambdas from java.* library code.
S.Bharadwaj Yadavalli <bharadwaj.yadavalli@oracle.com>
parents:
13888
diff
changeset
|
263 |
0995dcbd6dd8
Change CUDA context management to support multiple executions of a kernel. Exclude GPU offloading of lambdas from java.* library code.
S.Bharadwaj Yadavalli <bharadwaj.yadavalli@oracle.com>
parents:
13888
diff
changeset
|
264 status = _cuda_cu_ctx_create(&_device_context, GRAAL_CU_CTX_MAP_HOST, _cu_device); |
0995dcbd6dd8
Change CUDA context management to support multiple executions of a kernel. Exclude GPU offloading of lambdas from java.* library code.
S.Bharadwaj Yadavalli <bharadwaj.yadavalli@oracle.com>
parents:
13888
diff
changeset
|
265 |
0995dcbd6dd8
Change CUDA context management to support multiple executions of a kernel. Exclude GPU offloading of lambdas from java.* library code.
S.Bharadwaj Yadavalli <bharadwaj.yadavalli@oracle.com>
parents:
13888
diff
changeset
|
266 if (status != GRAAL_CUDA_SUCCESS) { |
0995dcbd6dd8
Change CUDA context management to support multiple executions of a kernel. Exclude GPU offloading of lambdas from java.* library code.
S.Bharadwaj Yadavalli <bharadwaj.yadavalli@oracle.com>
parents:
13888
diff
changeset
|
267 tty->print_cr("[CUDA] Failed to create CUDA context for device(%d): %d", _cu_device, status); |
0995dcbd6dd8
Change CUDA context management to support multiple executions of a kernel. Exclude GPU offloading of lambdas from java.* library code.
S.Bharadwaj Yadavalli <bharadwaj.yadavalli@oracle.com>
parents:
13888
diff
changeset
|
268 return false; |
0995dcbd6dd8
Change CUDA context management to support multiple executions of a kernel. Exclude GPU offloading of lambdas from java.* library code.
S.Bharadwaj Yadavalli <bharadwaj.yadavalli@oracle.com>
parents:
13888
diff
changeset
|
269 } |
0995dcbd6dd8
Change CUDA context management to support multiple executions of a kernel. Exclude GPU offloading of lambdas from java.* library code.
S.Bharadwaj Yadavalli <bharadwaj.yadavalli@oracle.com>
parents:
13888
diff
changeset
|
270 if (TraceGPUInteraction) { |
0995dcbd6dd8
Change CUDA context management to support multiple executions of a kernel. Exclude GPU offloading of lambdas from java.* library code.
S.Bharadwaj Yadavalli <bharadwaj.yadavalli@oracle.com>
parents:
13888
diff
changeset
|
271 tty->print_cr("[CUDA] Success: Created context for device: %d", _cu_device); |
0995dcbd6dd8
Change CUDA context management to support multiple executions of a kernel. Exclude GPU offloading of lambdas from java.* library code.
S.Bharadwaj Yadavalli <bharadwaj.yadavalli@oracle.com>
parents:
13888
diff
changeset
|
272 } |
0995dcbd6dd8
Change CUDA context management to support multiple executions of a kernel. Exclude GPU offloading of lambdas from java.* library code.
S.Bharadwaj Yadavalli <bharadwaj.yadavalli@oracle.com>
parents:
13888
diff
changeset
|
273 |
15177
66e3af78ea96
HSAIL: added safepoint support
Doug Simon <doug.simon@oracle.com>
parents:
14040
diff
changeset
|
274 Gpu::initialized_gpu(new Ptx()); |
11842
8d8f63069f58
PTX warp limiter to available GPU processors
Morris Meyer <morris.meyer@oracle.com>
parents:
11822
diff
changeset
|
275 |
10879 | 276 return true; |
13819
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13753
diff
changeset
|
277 GPU_END |
10879 | 278 |
13888
51584f76462d
pulled Ptx and Hsail classes out of gpu class namespace
Doug Simon <doug.simon@oracle.com>
parents:
13851
diff
changeset
|
279 GPU_ENTRY(jint, Ptx::get_total_cores, (JNIEnv *env, jobject)) |
11842
8d8f63069f58
PTX warp limiter to available GPU processors
Morris Meyer <morris.meyer@oracle.com>
parents:
11822
diff
changeset
|
280 |
8d8f63069f58
PTX warp limiter to available GPU processors
Morris Meyer <morris.meyer@oracle.com>
parents:
11822
diff
changeset
|
281 int minor, major, nmp; |
8d8f63069f58
PTX warp limiter to available GPU processors
Morris Meyer <morris.meyer@oracle.com>
parents:
11822
diff
changeset
|
282 int status = _cuda_cu_device_get_attribute(&minor, |
8d8f63069f58
PTX warp limiter to available GPU processors
Morris Meyer <morris.meyer@oracle.com>
parents:
11822
diff
changeset
|
283 GRAAL_CU_DEVICE_ATTRIBUTE_COMPUTE_CAPABILITY_MINOR, |
8d8f63069f58
PTX warp limiter to available GPU processors
Morris Meyer <morris.meyer@oracle.com>
parents:
11822
diff
changeset
|
284 _cu_device); |
8d8f63069f58
PTX warp limiter to available GPU processors
Morris Meyer <morris.meyer@oracle.com>
parents:
11822
diff
changeset
|
285 |
8d8f63069f58
PTX warp limiter to available GPU processors
Morris Meyer <morris.meyer@oracle.com>
parents:
11822
diff
changeset
|
286 if (status != GRAAL_CUDA_SUCCESS) { |
8d8f63069f58
PTX warp limiter to available GPU processors
Morris Meyer <morris.meyer@oracle.com>
parents:
11822
diff
changeset
|
287 tty->print_cr("[CUDA] Failed to get minor attribute of device: %d", _cu_device); |
8d8f63069f58
PTX warp limiter to available GPU processors
Morris Meyer <morris.meyer@oracle.com>
parents:
11822
diff
changeset
|
288 return 0; |
8d8f63069f58
PTX warp limiter to available GPU processors
Morris Meyer <morris.meyer@oracle.com>
parents:
11822
diff
changeset
|
289 } |
8d8f63069f58
PTX warp limiter to available GPU processors
Morris Meyer <morris.meyer@oracle.com>
parents:
11822
diff
changeset
|
290 |
8d8f63069f58
PTX warp limiter to available GPU processors
Morris Meyer <morris.meyer@oracle.com>
parents:
11822
diff
changeset
|
291 status = _cuda_cu_device_get_attribute(&major, |
8d8f63069f58
PTX warp limiter to available GPU processors
Morris Meyer <morris.meyer@oracle.com>
parents:
11822
diff
changeset
|
292 GRAAL_CU_DEVICE_ATTRIBUTE_COMPUTE_CAPABILITY_MAJOR, |
8d8f63069f58
PTX warp limiter to available GPU processors
Morris Meyer <morris.meyer@oracle.com>
parents:
11822
diff
changeset
|
293 _cu_device); |
8d8f63069f58
PTX warp limiter to available GPU processors
Morris Meyer <morris.meyer@oracle.com>
parents:
11822
diff
changeset
|
294 |
8d8f63069f58
PTX warp limiter to available GPU processors
Morris Meyer <morris.meyer@oracle.com>
parents:
11822
diff
changeset
|
295 if (status != GRAAL_CUDA_SUCCESS) { |
8d8f63069f58
PTX warp limiter to available GPU processors
Morris Meyer <morris.meyer@oracle.com>
parents:
11822
diff
changeset
|
296 tty->print_cr("[CUDA] Failed to get major attribute of device: %d", _cu_device); |
8d8f63069f58
PTX warp limiter to available GPU processors
Morris Meyer <morris.meyer@oracle.com>
parents:
11822
diff
changeset
|
297 return 0; |
8d8f63069f58
PTX warp limiter to available GPU processors
Morris Meyer <morris.meyer@oracle.com>
parents:
11822
diff
changeset
|
298 } |
8d8f63069f58
PTX warp limiter to available GPU processors
Morris Meyer <morris.meyer@oracle.com>
parents:
11822
diff
changeset
|
299 |
8d8f63069f58
PTX warp limiter to available GPU processors
Morris Meyer <morris.meyer@oracle.com>
parents:
11822
diff
changeset
|
300 status = _cuda_cu_device_get_attribute(&nmp, |
8d8f63069f58
PTX warp limiter to available GPU processors
Morris Meyer <morris.meyer@oracle.com>
parents:
11822
diff
changeset
|
301 GRAAL_CU_DEVICE_ATTRIBUTE_MULTIPROCESSOR_COUNT, |
8d8f63069f58
PTX warp limiter to available GPU processors
Morris Meyer <morris.meyer@oracle.com>
parents:
11822
diff
changeset
|
302 _cu_device); |
8d8f63069f58
PTX warp limiter to available GPU processors
Morris Meyer <morris.meyer@oracle.com>
parents:
11822
diff
changeset
|
303 |
8d8f63069f58
PTX warp limiter to available GPU processors
Morris Meyer <morris.meyer@oracle.com>
parents:
11822
diff
changeset
|
304 if (status != GRAAL_CUDA_SUCCESS) { |
13819
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13753
diff
changeset
|
305 tty->print_cr("[CUDA] Failed to get number of MPs on device: %d", _cu_device); |
11842
8d8f63069f58
PTX warp limiter to available GPU processors
Morris Meyer <morris.meyer@oracle.com>
parents:
11822
diff
changeset
|
306 return 0; |
8d8f63069f58
PTX warp limiter to available GPU processors
Morris Meyer <morris.meyer@oracle.com>
parents:
11822
diff
changeset
|
307 } |
8d8f63069f58
PTX warp limiter to available GPU processors
Morris Meyer <morris.meyer@oracle.com>
parents:
11822
diff
changeset
|
308 |
8d8f63069f58
PTX warp limiter to available GPU processors
Morris Meyer <morris.meyer@oracle.com>
parents:
11822
diff
changeset
|
309 int total = nmp * ncores(major, minor); |
8d8f63069f58
PTX warp limiter to available GPU processors
Morris Meyer <morris.meyer@oracle.com>
parents:
11822
diff
changeset
|
310 |
11894
c7abc8411011
Fixed BasicPTXTest and IntegerPTXTest
Morris Meyer <morris.meyer@oracle.com>
parents:
11843
diff
changeset
|
311 int max_threads_per_block, warp_size, async_engines, can_map_host_memory, concurrent_kernels; |
c7abc8411011
Fixed BasicPTXTest and IntegerPTXTest
Morris Meyer <morris.meyer@oracle.com>
parents:
11843
diff
changeset
|
312 |
c7abc8411011
Fixed BasicPTXTest and IntegerPTXTest
Morris Meyer <morris.meyer@oracle.com>
parents:
11843
diff
changeset
|
313 status = _cuda_cu_device_get_attribute(&max_threads_per_block, |
c7abc8411011
Fixed BasicPTXTest and IntegerPTXTest
Morris Meyer <morris.meyer@oracle.com>
parents:
11843
diff
changeset
|
314 GRAAL_CU_DEVICE_ATTRIBUTE_MAX_THREADS_PER_BLOCK, |
c7abc8411011
Fixed BasicPTXTest and IntegerPTXTest
Morris Meyer <morris.meyer@oracle.com>
parents:
11843
diff
changeset
|
315 _cu_device); |
c7abc8411011
Fixed BasicPTXTest and IntegerPTXTest
Morris Meyer <morris.meyer@oracle.com>
parents:
11843
diff
changeset
|
316 |
c7abc8411011
Fixed BasicPTXTest and IntegerPTXTest
Morris Meyer <morris.meyer@oracle.com>
parents:
11843
diff
changeset
|
317 if (status != GRAAL_CUDA_SUCCESS) { |
c7abc8411011
Fixed BasicPTXTest and IntegerPTXTest
Morris Meyer <morris.meyer@oracle.com>
parents:
11843
diff
changeset
|
318 tty->print_cr("[CUDA] Failed to get GRAAL_CU_DEVICE_ATTRIBUTE_MAX_THREADS_PER_BLOCK: %d", _cu_device); |
c7abc8411011
Fixed BasicPTXTest and IntegerPTXTest
Morris Meyer <morris.meyer@oracle.com>
parents:
11843
diff
changeset
|
319 return 0; |
c7abc8411011
Fixed BasicPTXTest and IntegerPTXTest
Morris Meyer <morris.meyer@oracle.com>
parents:
11843
diff
changeset
|
320 } |
c7abc8411011
Fixed BasicPTXTest and IntegerPTXTest
Morris Meyer <morris.meyer@oracle.com>
parents:
11843
diff
changeset
|
321 |
c7abc8411011
Fixed BasicPTXTest and IntegerPTXTest
Morris Meyer <morris.meyer@oracle.com>
parents:
11843
diff
changeset
|
322 status = _cuda_cu_device_get_attribute(&warp_size, |
c7abc8411011
Fixed BasicPTXTest and IntegerPTXTest
Morris Meyer <morris.meyer@oracle.com>
parents:
11843
diff
changeset
|
323 GRAAL_CU_DEVICE_ATTRIBUTE_WARP_SIZE, |
c7abc8411011
Fixed BasicPTXTest and IntegerPTXTest
Morris Meyer <morris.meyer@oracle.com>
parents:
11843
diff
changeset
|
324 _cu_device); |
c7abc8411011
Fixed BasicPTXTest and IntegerPTXTest
Morris Meyer <morris.meyer@oracle.com>
parents:
11843
diff
changeset
|
325 |
c7abc8411011
Fixed BasicPTXTest and IntegerPTXTest
Morris Meyer <morris.meyer@oracle.com>
parents:
11843
diff
changeset
|
326 if (status != GRAAL_CUDA_SUCCESS) { |
c7abc8411011
Fixed BasicPTXTest and IntegerPTXTest
Morris Meyer <morris.meyer@oracle.com>
parents:
11843
diff
changeset
|
327 tty->print_cr("[CUDA] Failed to get GRAAL_CU_DEVICE_ATTRIBUTE_WARP_SIZE: %d", _cu_device); |
c7abc8411011
Fixed BasicPTXTest and IntegerPTXTest
Morris Meyer <morris.meyer@oracle.com>
parents:
11843
diff
changeset
|
328 return 0; |
c7abc8411011
Fixed BasicPTXTest and IntegerPTXTest
Morris Meyer <morris.meyer@oracle.com>
parents:
11843
diff
changeset
|
329 } |
12653
1a7e7011a341
* PTX kernel argument buffer now has naturally aligned arguments as required by PTX JIT compiler.
S.Bharadwaj Yadavalli <bharadwaj.yadavalli@oracle.com>
parents:
12519
diff
changeset
|
330 |
11894
c7abc8411011
Fixed BasicPTXTest and IntegerPTXTest
Morris Meyer <morris.meyer@oracle.com>
parents:
11843
diff
changeset
|
331 status = _cuda_cu_device_get_attribute(&async_engines, |
c7abc8411011
Fixed BasicPTXTest and IntegerPTXTest
Morris Meyer <morris.meyer@oracle.com>
parents:
11843
diff
changeset
|
332 GRAAL_CU_DEVICE_ATTRIBUTE_ASYNC_ENGINE_COUNT, |
c7abc8411011
Fixed BasicPTXTest and IntegerPTXTest
Morris Meyer <morris.meyer@oracle.com>
parents:
11843
diff
changeset
|
333 _cu_device); |
c7abc8411011
Fixed BasicPTXTest and IntegerPTXTest
Morris Meyer <morris.meyer@oracle.com>
parents:
11843
diff
changeset
|
334 |
c7abc8411011
Fixed BasicPTXTest and IntegerPTXTest
Morris Meyer <morris.meyer@oracle.com>
parents:
11843
diff
changeset
|
335 if (status != GRAAL_CUDA_SUCCESS) { |
c7abc8411011
Fixed BasicPTXTest and IntegerPTXTest
Morris Meyer <morris.meyer@oracle.com>
parents:
11843
diff
changeset
|
336 tty->print_cr("[CUDA] Failed to get GRAAL_CU_DEVICE_ATTRIBUTE_WARP_SIZE: %d", _cu_device); |
c7abc8411011
Fixed BasicPTXTest and IntegerPTXTest
Morris Meyer <morris.meyer@oracle.com>
parents:
11843
diff
changeset
|
337 return 0; |
c7abc8411011
Fixed BasicPTXTest and IntegerPTXTest
Morris Meyer <morris.meyer@oracle.com>
parents:
11843
diff
changeset
|
338 } |
c7abc8411011
Fixed BasicPTXTest and IntegerPTXTest
Morris Meyer <morris.meyer@oracle.com>
parents:
11843
diff
changeset
|
339 |
c7abc8411011
Fixed BasicPTXTest and IntegerPTXTest
Morris Meyer <morris.meyer@oracle.com>
parents:
11843
diff
changeset
|
340 status = _cuda_cu_device_get_attribute(&can_map_host_memory, |
c7abc8411011
Fixed BasicPTXTest and IntegerPTXTest
Morris Meyer <morris.meyer@oracle.com>
parents:
11843
diff
changeset
|
341 GRAAL_CU_DEVICE_ATTRIBUTE_CAN_MAP_HOST_MEMORY, |
c7abc8411011
Fixed BasicPTXTest and IntegerPTXTest
Morris Meyer <morris.meyer@oracle.com>
parents:
11843
diff
changeset
|
342 _cu_device); |
c7abc8411011
Fixed BasicPTXTest and IntegerPTXTest
Morris Meyer <morris.meyer@oracle.com>
parents:
11843
diff
changeset
|
343 |
c7abc8411011
Fixed BasicPTXTest and IntegerPTXTest
Morris Meyer <morris.meyer@oracle.com>
parents:
11843
diff
changeset
|
344 if (status != GRAAL_CUDA_SUCCESS) { |
c7abc8411011
Fixed BasicPTXTest and IntegerPTXTest
Morris Meyer <morris.meyer@oracle.com>
parents:
11843
diff
changeset
|
345 tty->print_cr("[CUDA] Failed to get GRAAL_CU_DEVICE_ATTRIBUTE_CAN_MAP_HOST_MEMORY: %d", _cu_device); |
c7abc8411011
Fixed BasicPTXTest and IntegerPTXTest
Morris Meyer <morris.meyer@oracle.com>
parents:
11843
diff
changeset
|
346 return 0; |
c7abc8411011
Fixed BasicPTXTest and IntegerPTXTest
Morris Meyer <morris.meyer@oracle.com>
parents:
11843
diff
changeset
|
347 } |
c7abc8411011
Fixed BasicPTXTest and IntegerPTXTest
Morris Meyer <morris.meyer@oracle.com>
parents:
11843
diff
changeset
|
348 |
c7abc8411011
Fixed BasicPTXTest and IntegerPTXTest
Morris Meyer <morris.meyer@oracle.com>
parents:
11843
diff
changeset
|
349 status = _cuda_cu_device_get_attribute(&concurrent_kernels, |
c7abc8411011
Fixed BasicPTXTest and IntegerPTXTest
Morris Meyer <morris.meyer@oracle.com>
parents:
11843
diff
changeset
|
350 GRAAL_CU_DEVICE_ATTRIBUTE_CONCURRENT_KERNELS, |
c7abc8411011
Fixed BasicPTXTest and IntegerPTXTest
Morris Meyer <morris.meyer@oracle.com>
parents:
11843
diff
changeset
|
351 _cu_device); |
c7abc8411011
Fixed BasicPTXTest and IntegerPTXTest
Morris Meyer <morris.meyer@oracle.com>
parents:
11843
diff
changeset
|
352 |
c7abc8411011
Fixed BasicPTXTest and IntegerPTXTest
Morris Meyer <morris.meyer@oracle.com>
parents:
11843
diff
changeset
|
353 if (status != GRAAL_CUDA_SUCCESS) { |
c7abc8411011
Fixed BasicPTXTest and IntegerPTXTest
Morris Meyer <morris.meyer@oracle.com>
parents:
11843
diff
changeset
|
354 tty->print_cr("[CUDA] Failed to get GRAAL_CU_DEVICE_ATTRIBUTE_CONCURRENT_KERNELS: %d", _cu_device); |
c7abc8411011
Fixed BasicPTXTest and IntegerPTXTest
Morris Meyer <morris.meyer@oracle.com>
parents:
11843
diff
changeset
|
355 return 0; |
c7abc8411011
Fixed BasicPTXTest and IntegerPTXTest
Morris Meyer <morris.meyer@oracle.com>
parents:
11843
diff
changeset
|
356 } |
c7abc8411011
Fixed BasicPTXTest and IntegerPTXTest
Morris Meyer <morris.meyer@oracle.com>
parents:
11843
diff
changeset
|
357 |
11842
8d8f63069f58
PTX warp limiter to available GPU processors
Morris Meyer <morris.meyer@oracle.com>
parents:
11822
diff
changeset
|
358 if (TraceGPUInteraction) { |
11894
c7abc8411011
Fixed BasicPTXTest and IntegerPTXTest
Morris Meyer <morris.meyer@oracle.com>
parents:
11843
diff
changeset
|
359 tty->print_cr("[CUDA] Number of cores: %d async engines: %d can map host mem: %d concurrent kernels: %d", |
c7abc8411011
Fixed BasicPTXTest and IntegerPTXTest
Morris Meyer <morris.meyer@oracle.com>
parents:
11843
diff
changeset
|
360 total, async_engines, can_map_host_memory, concurrent_kernels); |
c7abc8411011
Fixed BasicPTXTest and IntegerPTXTest
Morris Meyer <morris.meyer@oracle.com>
parents:
11843
diff
changeset
|
361 tty->print_cr("[CUDA] Max threads per block: %d warp size: %d", max_threads_per_block, warp_size); |
11842
8d8f63069f58
PTX warp limiter to available GPU processors
Morris Meyer <morris.meyer@oracle.com>
parents:
11822
diff
changeset
|
362 } |
13819
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13753
diff
changeset
|
363 return total; |
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13753
diff
changeset
|
364 GPU_END |
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13753
diff
changeset
|
365 |
13888
51584f76462d
pulled Ptx and Hsail classes out of gpu class namespace
Doug Simon <doug.simon@oracle.com>
parents:
13851
diff
changeset
|
366 GPU_ENTRY(jlong, Ptx::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:
13753
diff
changeset
|
367 ResourceMark rm; |
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13753
diff
changeset
|
368 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:
13753
diff
changeset
|
369 jsize code_len = env->GetArrayLength(code_handle); |
12653
1a7e7011a341
* PTX kernel argument buffer now has naturally aligned arguments as required by PTX JIT compiler.
S.Bharadwaj Yadavalli <bharadwaj.yadavalli@oracle.com>
parents:
12519
diff
changeset
|
370 |
13819
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13753
diff
changeset
|
371 char* name = NEW_RESOURCE_ARRAY(char, name_len + 1); |
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13753
diff
changeset
|
372 unsigned char *code = NEW_RESOURCE_ARRAY(unsigned char, code_len + 1); |
11842
8d8f63069f58
PTX warp limiter to available GPU processors
Morris Meyer <morris.meyer@oracle.com>
parents:
11822
diff
changeset
|
373 |
13819
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13753
diff
changeset
|
374 code[code_len] = 0; |
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13753
diff
changeset
|
375 name[name_len] = 0; |
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13753
diff
changeset
|
376 |
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13753
diff
changeset
|
377 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:
13753
diff
changeset
|
378 env->GetStringUTFRegion(name_handle, 0, name_len, name); |
10879 | 379 |
380 struct CUmod_st * cu_module; | |
381 // Use three JIT compiler options | |
382 const unsigned int jit_num_options = 3; | |
13819
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13753
diff
changeset
|
383 int *jit_options = NEW_RESOURCE_ARRAY(int, jit_num_options); |
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13753
diff
changeset
|
384 void **jit_option_values = NEW_RESOURCE_ARRAY(void *, jit_num_options); |
10879 | 385 |
386 // Set up PTX JIT compiler options | |
387 // 1. set size of compilation log buffer | |
388 int jit_log_buffer_size = 1024; | |
389 jit_options[0] = GRAAL_CU_JIT_INFO_LOG_BUFFER_SIZE_BYTES; | |
390 jit_option_values[0] = (void *)(size_t)jit_log_buffer_size; | |
391 | |
392 // 2. set pointer to compilation log buffer | |
13819
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13753
diff
changeset
|
393 char *jit_log_buffer = NEW_RESOURCE_ARRAY(char, jit_log_buffer_size); |
10879 | 394 jit_options[1] = GRAAL_CU_JIT_INFO_LOG_BUFFER; |
395 jit_option_values[1] = jit_log_buffer; | |
396 | |
13819
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13753
diff
changeset
|
397 // 3. set pointer to set the maximum number of registers (32) for the kernel |
10879 | 398 int jit_register_count = 32; |
399 jit_options[2] = GRAAL_CU_JIT_MAX_REGISTERS; | |
400 jit_option_values[2] = (void *)(size_t)jit_register_count; | |
401 | |
13922
0995dcbd6dd8
Change CUDA context management to support multiple executions of a kernel. Exclude GPU offloading of lambdas from java.* library code.
S.Bharadwaj Yadavalli <bharadwaj.yadavalli@oracle.com>
parents:
13888
diff
changeset
|
402 // Set CUDA context to compile and execute the kernel |
11485
49bb1bc983c6
Implement several missing PTX codegen features; return value capture and method args passing of java method executed on GPU.
bharadwaj
parents:
11284
diff
changeset
|
403 |
13922
0995dcbd6dd8
Change CUDA context management to support multiple executions of a kernel. Exclude GPU offloading of lambdas from java.* library code.
S.Bharadwaj Yadavalli <bharadwaj.yadavalli@oracle.com>
parents:
13888
diff
changeset
|
404 if (_device_context == NULL) { |
0995dcbd6dd8
Change CUDA context management to support multiple executions of a kernel. Exclude GPU offloading of lambdas from java.* library code.
S.Bharadwaj Yadavalli <bharadwaj.yadavalli@oracle.com>
parents:
13888
diff
changeset
|
405 tty->print_cr("[CUDA] Encountered uninitialized CUDA context for device(%d)", _cu_device); |
0995dcbd6dd8
Change CUDA context management to support multiple executions of a kernel. Exclude GPU offloading of lambdas from java.* library code.
S.Bharadwaj Yadavalli <bharadwaj.yadavalli@oracle.com>
parents:
13888
diff
changeset
|
406 return 0L; |
11485
49bb1bc983c6
Implement several missing PTX codegen features; return value capture and method args passing of java method executed on GPU.
bharadwaj
parents:
11284
diff
changeset
|
407 } |
49bb1bc983c6
Implement several missing PTX codegen features; return value capture and method args passing of java method executed on GPU.
bharadwaj
parents:
11284
diff
changeset
|
408 |
13922
0995dcbd6dd8
Change CUDA context management to support multiple executions of a kernel. Exclude GPU offloading of lambdas from java.* library code.
S.Bharadwaj Yadavalli <bharadwaj.yadavalli@oracle.com>
parents:
13888
diff
changeset
|
409 int status = _cuda_cu_ctx_set_current(_device_context); |
11527
c99e65785936
Improvements to PTX codegen; allows more PTX tests that run on the device to pass.
bharadwaj
parents:
11485
diff
changeset
|
410 |
c99e65785936
Improvements to PTX codegen; allows more PTX tests that run on the device to pass.
bharadwaj
parents:
11485
diff
changeset
|
411 if (status != GRAAL_CUDA_SUCCESS) { |
c99e65785936
Improvements to PTX codegen; allows more PTX tests that run on the device to pass.
bharadwaj
parents:
11485
diff
changeset
|
412 tty->print_cr("[CUDA] Failed to set current context for device: %d", _cu_device); |
13819
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13753
diff
changeset
|
413 return 0L; |
11527
c99e65785936
Improvements to PTX codegen; allows more PTX tests that run on the device to pass.
bharadwaj
parents:
11485
diff
changeset
|
414 } |
13922
0995dcbd6dd8
Change CUDA context management to support multiple executions of a kernel. Exclude GPU offloading of lambdas from java.* library code.
S.Bharadwaj Yadavalli <bharadwaj.yadavalli@oracle.com>
parents:
13888
diff
changeset
|
415 |
11527
c99e65785936
Improvements to PTX codegen; allows more PTX tests that run on the device to pass.
bharadwaj
parents:
11485
diff
changeset
|
416 if (TraceGPUInteraction) { |
c99e65785936
Improvements to PTX codegen; allows more PTX tests that run on the device to pass.
bharadwaj
parents:
11485
diff
changeset
|
417 tty->print_cr("[CUDA] Success: Set current context for device: %d", _cu_device); |
c99e65785936
Improvements to PTX codegen; allows more PTX tests that run on the device to pass.
bharadwaj
parents:
11485
diff
changeset
|
418 tty->print_cr("[CUDA] PTX Kernel\n%s", code); |
c99e65785936
Improvements to PTX codegen; allows more PTX tests that run on the device to pass.
bharadwaj
parents:
11485
diff
changeset
|
419 tty->print_cr("[CUDA] Function name : %s", name); |
c99e65785936
Improvements to PTX codegen; allows more PTX tests that run on the device to pass.
bharadwaj
parents:
11485
diff
changeset
|
420 } |
c99e65785936
Improvements to PTX codegen; allows more PTX tests that run on the device to pass.
bharadwaj
parents:
11485
diff
changeset
|
421 |
10879 | 422 /* Load module's data with compiler options */ |
11485
49bb1bc983c6
Implement several missing PTX codegen features; return value capture and method args passing of java method executed on GPU.
bharadwaj
parents:
11284
diff
changeset
|
423 status = _cuda_cu_module_load_data_ex(&cu_module, (void*) code, jit_num_options, |
13819
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13753
diff
changeset
|
424 jit_options, (void **)jit_option_values); |
10879 | 425 if (status != GRAAL_CUDA_SUCCESS) { |
426 if (status == GRAAL_CUDA_ERROR_NO_BINARY_FOR_GPU) { | |
427 tty->print_cr("[CUDA] Check for malformed PTX kernel or incorrect PTX compilation options"); | |
428 } | |
11527
c99e65785936
Improvements to PTX codegen; allows more PTX tests that run on the device to pass.
bharadwaj
parents:
11485
diff
changeset
|
429 tty->print_cr("[CUDA] *** Error (%d) Failed to load module data with online compiler options for method %s", |
10879 | 430 status, name); |
13819
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13753
diff
changeset
|
431 return 0L; |
10879 | 432 } |
433 | |
434 if (TraceGPUInteraction) { | |
435 tty->print_cr("[CUDA] Loaded data for PTX Kernel"); | |
436 } | |
437 | |
13819
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13753
diff
changeset
|
438 struct CUfunc_st* cu_function; |
10879 | 439 status = _cuda_cu_module_get_function(&cu_function, cu_module, name); |
440 | |
441 if (status != GRAAL_CUDA_SUCCESS) { | |
11283
1cd1f8ff70a1
CR-20: PTX kernel invocation with arguments - from Bharadwaj
Morris Meyer <morris.meyer@oracle.com>
parents:
10884
diff
changeset
|
442 tty->print_cr("[CUDA] *** Error: Failed to get function %s", name); |
13819
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13753
diff
changeset
|
443 return 0L; |
10879 | 444 } |
445 | |
446 if (TraceGPUInteraction) { | |
13683
de839ec35cc7
schedule lambda method compilation and execution on GPU (PTX) when possible; fix a couple of bugs.
S.Bharadwaj Yadavalli <bharadwaj.yadavalli@oracle.com>
parents:
13655
diff
changeset
|
447 tty->print_cr("[CUDA] Got function handle for %s kernel address %p", name, cu_function); |
10879 | 448 } |
13819
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13753
diff
changeset
|
449 return (jlong) cu_function; |
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13753
diff
changeset
|
450 GPU_END |
10879 | 451 |
13753
80cd5c3b8827
partially fixed passing of object parameters to PTX kernels; use a C++ object for managing resource allocation and cleanup around a PTX kernel execution
Doug Simon <doug.simon@oracle.com>
parents:
13683
diff
changeset
|
452 // A PtxCall is used to manage executing a GPU kernel. In addition to launching |
80cd5c3b8827
partially fixed passing of object parameters to PTX kernels; use a C++ object for managing resource allocation and cleanup around a PTX kernel execution
Doug Simon <doug.simon@oracle.com>
parents:
13683
diff
changeset
|
453 // the kernel, this class releases resources allocated for the execution. |
80cd5c3b8827
partially fixed passing of object parameters to PTX kernels; use a C++ object for managing resource allocation and cleanup around a PTX kernel execution
Doug Simon <doug.simon@oracle.com>
parents:
13683
diff
changeset
|
454 class PtxCall: StackObj { |
80cd5c3b8827
partially fixed passing of object parameters to PTX kernels; use a C++ object for managing resource allocation and cleanup around a PTX kernel execution
Doug Simon <doug.simon@oracle.com>
parents:
13683
diff
changeset
|
455 private: |
80cd5c3b8827
partially fixed passing of object parameters to PTX kernels; use a C++ object for managing resource allocation and cleanup around a PTX kernel execution
Doug Simon <doug.simon@oracle.com>
parents:
13683
diff
changeset
|
456 JavaThread* _thread; // the thread on which this call is made |
80cd5c3b8827
partially fixed passing of object parameters to PTX kernels; use a C++ object for managing resource allocation and cleanup around a PTX kernel execution
Doug Simon <doug.simon@oracle.com>
parents:
13683
diff
changeset
|
457 address _buffer; // buffer containing parameters and _return_value |
80cd5c3b8827
partially fixed passing of object parameters to PTX kernels; use a C++ object for managing resource allocation and cleanup around a PTX kernel execution
Doug Simon <doug.simon@oracle.com>
parents:
13683
diff
changeset
|
458 int _buffer_size; // size (in bytes) of _buffer |
80cd5c3b8827
partially fixed passing of object parameters to PTX kernels; use a C++ object for managing resource allocation and cleanup around a PTX kernel execution
Doug Simon <doug.simon@oracle.com>
parents:
13683
diff
changeset
|
459 oop* _pinned; // objects that have been pinned with cuMemHostRegister |
80cd5c3b8827
partially fixed passing of object parameters to PTX kernels; use a C++ object for managing resource allocation and cleanup around a PTX kernel execution
Doug Simon <doug.simon@oracle.com>
parents:
13683
diff
changeset
|
460 int _pinned_length; // length of _pinned |
13888
51584f76462d
pulled Ptx and Hsail classes out of gpu class namespace
Doug Simon <doug.simon@oracle.com>
parents:
13851
diff
changeset
|
461 Ptx::CUdeviceptr _ret_value; // pointer to slot in GPU memory holding the return value |
13753
80cd5c3b8827
partially fixed passing of object parameters to PTX kernels; use a C++ object for managing resource allocation and cleanup around a PTX kernel execution
Doug Simon <doug.simon@oracle.com>
parents:
13683
diff
changeset
|
462 int _ret_type_size; // size of the return type value |
80cd5c3b8827
partially fixed passing of object parameters to PTX kernels; use a C++ object for managing resource allocation and cleanup around a PTX kernel execution
Doug Simon <doug.simon@oracle.com>
parents:
13683
diff
changeset
|
463 bool _ret_is_object; // specifies if the return type is Object |
13848
b97e2515d392
removed PTXKernelArguments; added mechanism for printing incoming kernel arguments
Doug Simon <doug.simon@oracle.com>
parents:
13834
diff
changeset
|
464 bool _gc_locked; // denotes when execution has locked GC |
13753
80cd5c3b8827
partially fixed passing of object parameters to PTX kernels; use a C++ object for managing resource allocation and cleanup around a PTX kernel execution
Doug Simon <doug.simon@oracle.com>
parents:
13683
diff
changeset
|
465 |
80cd5c3b8827
partially fixed passing of object parameters to PTX kernels; use a C++ object for managing resource allocation and cleanup around a PTX kernel execution
Doug Simon <doug.simon@oracle.com>
parents:
13683
diff
changeset
|
466 bool check(int status, const char *action) { |
80cd5c3b8827
partially fixed passing of object parameters to PTX kernels; use a C++ object for managing resource allocation and cleanup around a PTX kernel execution
Doug Simon <doug.simon@oracle.com>
parents:
13683
diff
changeset
|
467 if (status != GRAAL_CUDA_SUCCESS) { |
80cd5c3b8827
partially fixed passing of object parameters to PTX kernels; use a C++ object for managing resource allocation and cleanup around a PTX kernel execution
Doug Simon <doug.simon@oracle.com>
parents:
13683
diff
changeset
|
468 Thread* THREAD = _thread; |
14040
2d95cf7a29c8
Fixes PTX test failure and a crash when TraceGPUInteraction flag is specified.
S.Bharadwaj Yadavalli <bharadwaj.yadavalli@oracle.com>
parents:
13922
diff
changeset
|
469 ResourceMark rm(THREAD); |
13753
80cd5c3b8827
partially fixed passing of object parameters to PTX kernels; use a C++ object for managing resource allocation and cleanup around a PTX kernel execution
Doug Simon <doug.simon@oracle.com>
parents:
13683
diff
changeset
|
470 char* message = NEW_RESOURCE_ARRAY_IN_THREAD(THREAD, char, O_BUFLEN + 1); |
80cd5c3b8827
partially fixed passing of object parameters to PTX kernels; use a C++ object for managing resource allocation and cleanup around a PTX kernel execution
Doug Simon <doug.simon@oracle.com>
parents:
13683
diff
changeset
|
471 jio_snprintf(message, O_BUFLEN, "[CUDA] *** Error (status=%d): %s", status, action); |
13833
fe99bfb55626
disable printing of CUDA errors unless TraceGPUInteraction is enabled
Doug Simon <doug.simon@oracle.com>
parents:
13832
diff
changeset
|
472 if (TraceGPUInteraction) { |
18043
f55f2d400797
Fix some format strings
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15582
diff
changeset
|
473 tty->print_raw_cr(message); |
13753
80cd5c3b8827
partially fixed passing of object parameters to PTX kernels; use a C++ object for managing resource allocation and cleanup around a PTX kernel execution
Doug Simon <doug.simon@oracle.com>
parents:
13683
diff
changeset
|
474 } |
80cd5c3b8827
partially fixed passing of object parameters to PTX kernels; use a C++ object for managing resource allocation and cleanup around a PTX kernel execution
Doug Simon <doug.simon@oracle.com>
parents:
13683
diff
changeset
|
475 if (!HAS_PENDING_EXCEPTION) { |
80cd5c3b8827
partially fixed passing of object parameters to PTX kernels; use a C++ object for managing resource allocation and cleanup around a PTX kernel execution
Doug Simon <doug.simon@oracle.com>
parents:
13683
diff
changeset
|
476 SharedRuntime::throw_and_post_jvmti_exception(_thread, vmSymbols::java_lang_RuntimeException(), message); |
80cd5c3b8827
partially fixed passing of object parameters to PTX kernels; use a C++ object for managing resource allocation and cleanup around a PTX kernel execution
Doug Simon <doug.simon@oracle.com>
parents:
13683
diff
changeset
|
477 } |
80cd5c3b8827
partially fixed passing of object parameters to PTX kernels; use a C++ object for managing resource allocation and cleanup around a PTX kernel execution
Doug Simon <doug.simon@oracle.com>
parents:
13683
diff
changeset
|
478 return false; |
80cd5c3b8827
partially fixed passing of object parameters to PTX kernels; use a C++ object for managing resource allocation and cleanup around a PTX kernel execution
Doug Simon <doug.simon@oracle.com>
parents:
13683
diff
changeset
|
479 } |
80cd5c3b8827
partially fixed passing of object parameters to PTX kernels; use a C++ object for managing resource allocation and cleanup around a PTX kernel execution
Doug Simon <doug.simon@oracle.com>
parents:
13683
diff
changeset
|
480 if (TraceGPUInteraction) { |
80cd5c3b8827
partially fixed passing of object parameters to PTX kernels; use a C++ object for managing resource allocation and cleanup around a PTX kernel execution
Doug Simon <doug.simon@oracle.com>
parents:
13683
diff
changeset
|
481 tty->print_cr("[CUDA] Success: %s", action); |
80cd5c3b8827
partially fixed passing of object parameters to PTX kernels; use a C++ object for managing resource allocation and cleanup around a PTX kernel execution
Doug Simon <doug.simon@oracle.com>
parents:
13683
diff
changeset
|
482 } |
80cd5c3b8827
partially fixed passing of object parameters to PTX kernels; use a C++ object for managing resource allocation and cleanup around a PTX kernel execution
Doug Simon <doug.simon@oracle.com>
parents:
13683
diff
changeset
|
483 return true; |
80cd5c3b8827
partially fixed passing of object parameters to PTX kernels; use a C++ object for managing resource allocation and cleanup around a PTX kernel execution
Doug Simon <doug.simon@oracle.com>
parents:
13683
diff
changeset
|
484 } |
80cd5c3b8827
partially fixed passing of object parameters to PTX kernels; use a C++ object for managing resource allocation and cleanup around a PTX kernel execution
Doug Simon <doug.simon@oracle.com>
parents:
13683
diff
changeset
|
485 |
80cd5c3b8827
partially fixed passing of object parameters to PTX kernels; use a C++ object for managing resource allocation and cleanup around a PTX kernel execution
Doug Simon <doug.simon@oracle.com>
parents:
13683
diff
changeset
|
486 public: |
13832
ab370d74a8eb
implemented GC locking for duration of a PTX kernel call
Doug Simon <doug.simon@oracle.com>
parents:
13819
diff
changeset
|
487 PtxCall(JavaThread* thread, address buffer, int buffer_size, oop* pinned, int encodedReturnTypeSize) : _thread(thread), _gc_locked(false), |
13753
80cd5c3b8827
partially fixed passing of object parameters to PTX kernels; use a C++ object for managing resource allocation and cleanup around a PTX kernel execution
Doug Simon <doug.simon@oracle.com>
parents:
13683
diff
changeset
|
488 _buffer(buffer), _buffer_size(buffer_size), _pinned(pinned), _pinned_length(0), _ret_value(0), _ret_is_object(encodedReturnTypeSize < 0) { |
80cd5c3b8827
partially fixed passing of object parameters to PTX kernels; use a C++ object for managing resource allocation and cleanup around a PTX kernel execution
Doug Simon <doug.simon@oracle.com>
parents:
13683
diff
changeset
|
489 _ret_type_size = _ret_is_object ? -encodedReturnTypeSize : encodedReturnTypeSize; |
80cd5c3b8827
partially fixed passing of object parameters to PTX kernels; use a C++ object for managing resource allocation and cleanup around a PTX kernel execution
Doug Simon <doug.simon@oracle.com>
parents:
13683
diff
changeset
|
490 } |
80cd5c3b8827
partially fixed passing of object parameters to PTX kernels; use a C++ object for managing resource allocation and cleanup around a PTX kernel execution
Doug Simon <doug.simon@oracle.com>
parents:
13683
diff
changeset
|
491 |
80cd5c3b8827
partially fixed passing of object parameters to PTX kernels; use a C++ object for managing resource allocation and cleanup around a PTX kernel execution
Doug Simon <doug.simon@oracle.com>
parents:
13683
diff
changeset
|
492 bool is_object_return() { return _ret_is_object; } |
80cd5c3b8827
partially fixed passing of object parameters to PTX kernels; use a C++ object for managing resource allocation and cleanup around a PTX kernel execution
Doug Simon <doug.simon@oracle.com>
parents:
13683
diff
changeset
|
493 |
80cd5c3b8827
partially fixed passing of object parameters to PTX kernels; use a C++ object for managing resource allocation and cleanup around a PTX kernel execution
Doug Simon <doug.simon@oracle.com>
parents:
13683
diff
changeset
|
494 void alloc_return_value() { |
80cd5c3b8827
partially fixed passing of object parameters to PTX kernels; use a C++ object for managing resource allocation and cleanup around a PTX kernel execution
Doug Simon <doug.simon@oracle.com>
parents:
13683
diff
changeset
|
495 if (_ret_type_size != 0) { |
13888
51584f76462d
pulled Ptx and Hsail classes out of gpu class namespace
Doug Simon <doug.simon@oracle.com>
parents:
13851
diff
changeset
|
496 if (check(Ptx::_cuda_cu_memalloc(&_ret_value, _ret_type_size), "Allocate device memory for return value")) { |
51584f76462d
pulled Ptx and Hsail classes out of gpu class namespace
Doug Simon <doug.simon@oracle.com>
parents:
13851
diff
changeset
|
497 Ptx::CUdeviceptr* retValuePtr = (Ptx::CUdeviceptr*) ((_buffer + _buffer_size) - sizeof(_ret_value)); |
13753
80cd5c3b8827
partially fixed passing of object parameters to PTX kernels; use a C++ object for managing resource allocation and cleanup around a PTX kernel execution
Doug Simon <doug.simon@oracle.com>
parents:
13683
diff
changeset
|
498 *retValuePtr = _ret_value; |
80cd5c3b8827
partially fixed passing of object parameters to PTX kernels; use a C++ object for managing resource allocation and cleanup around a PTX kernel execution
Doug Simon <doug.simon@oracle.com>
parents:
13683
diff
changeset
|
499 } |
80cd5c3b8827
partially fixed passing of object parameters to PTX kernels; use a C++ object for managing resource allocation and cleanup around a PTX kernel execution
Doug Simon <doug.simon@oracle.com>
parents:
13683
diff
changeset
|
500 } |
80cd5c3b8827
partially fixed passing of object parameters to PTX kernels; use a C++ object for managing resource allocation and cleanup around a PTX kernel execution
Doug Simon <doug.simon@oracle.com>
parents:
13683
diff
changeset
|
501 } |
80cd5c3b8827
partially fixed passing of object parameters to PTX kernels; use a C++ object for managing resource allocation and cleanup around a PTX kernel execution
Doug Simon <doug.simon@oracle.com>
parents:
13683
diff
changeset
|
502 |
80cd5c3b8827
partially fixed passing of object parameters to PTX kernels; use a C++ object for managing resource allocation and cleanup around a PTX kernel execution
Doug Simon <doug.simon@oracle.com>
parents:
13683
diff
changeset
|
503 void pin_objects(int count, int* objectOffsets) { |
80cd5c3b8827
partially fixed passing of object parameters to PTX kernels; use a C++ object for managing resource allocation and cleanup around a PTX kernel execution
Doug Simon <doug.simon@oracle.com>
parents:
13683
diff
changeset
|
504 if (count == 0) { |
80cd5c3b8827
partially fixed passing of object parameters to PTX kernels; use a C++ object for managing resource allocation and cleanup around a PTX kernel execution
Doug Simon <doug.simon@oracle.com>
parents:
13683
diff
changeset
|
505 return; |
80cd5c3b8827
partially fixed passing of object parameters to PTX kernels; use a C++ object for managing resource allocation and cleanup around a PTX kernel execution
Doug Simon <doug.simon@oracle.com>
parents:
13683
diff
changeset
|
506 } |
13832
ab370d74a8eb
implemented GC locking for duration of a PTX kernel call
Doug Simon <doug.simon@oracle.com>
parents:
13819
diff
changeset
|
507 // Once we start pinning objects, no GC must occur |
ab370d74a8eb
implemented GC locking for duration of a PTX kernel call
Doug Simon <doug.simon@oracle.com>
parents:
13819
diff
changeset
|
508 // until the kernel has completed. This is a big |
ab370d74a8eb
implemented GC locking for duration of a PTX kernel call
Doug Simon <doug.simon@oracle.com>
parents:
13819
diff
changeset
|
509 // hammer for ensuring we can safely pass objects |
ab370d74a8eb
implemented GC locking for duration of a PTX kernel call
Doug Simon <doug.simon@oracle.com>
parents:
13819
diff
changeset
|
510 // to the GPU. |
ab370d74a8eb
implemented GC locking for duration of a PTX kernel call
Doug Simon <doug.simon@oracle.com>
parents:
13819
diff
changeset
|
511 GC_locker::lock_critical(_thread); |
ab370d74a8eb
implemented GC locking for duration of a PTX kernel call
Doug Simon <doug.simon@oracle.com>
parents:
13819
diff
changeset
|
512 _gc_locked = true; |
ab370d74a8eb
implemented GC locking for duration of a PTX kernel call
Doug Simon <doug.simon@oracle.com>
parents:
13819
diff
changeset
|
513 if (TraceGPUInteraction) { |
ab370d74a8eb
implemented GC locking for duration of a PTX kernel call
Doug Simon <doug.simon@oracle.com>
parents:
13819
diff
changeset
|
514 tty->print_cr("[CUDA] Locked GC"); |
ab370d74a8eb
implemented GC locking for duration of a PTX kernel call
Doug Simon <doug.simon@oracle.com>
parents:
13819
diff
changeset
|
515 } |
ab370d74a8eb
implemented GC locking for duration of a PTX kernel call
Doug Simon <doug.simon@oracle.com>
parents:
13819
diff
changeset
|
516 |
13753
80cd5c3b8827
partially fixed passing of object parameters to PTX kernels; use a C++ object for managing resource allocation and cleanup around a PTX kernel execution
Doug Simon <doug.simon@oracle.com>
parents:
13683
diff
changeset
|
517 for (int i = 0; i < count; i++) { |
80cd5c3b8827
partially fixed passing of object parameters to PTX kernels; use a C++ object for managing resource allocation and cleanup around a PTX kernel execution
Doug Simon <doug.simon@oracle.com>
parents:
13683
diff
changeset
|
518 int offset = objectOffsets[i]; |
80cd5c3b8827
partially fixed passing of object parameters to PTX kernels; use a C++ object for managing resource allocation and cleanup around a PTX kernel execution
Doug Simon <doug.simon@oracle.com>
parents:
13683
diff
changeset
|
519 oop* argPtr = (oop*) (_buffer + offset); |
80cd5c3b8827
partially fixed passing of object parameters to PTX kernels; use a C++ object for managing resource allocation and cleanup around a PTX kernel execution
Doug Simon <doug.simon@oracle.com>
parents:
13683
diff
changeset
|
520 oop obj = *argPtr; |
80cd5c3b8827
partially fixed passing of object parameters to PTX kernels; use a C++ object for managing resource allocation and cleanup around a PTX kernel execution
Doug Simon <doug.simon@oracle.com>
parents:
13683
diff
changeset
|
521 if (obj != NULL) { |
80cd5c3b8827
partially fixed passing of object parameters to PTX kernels; use a C++ object for managing resource allocation and cleanup around a PTX kernel execution
Doug Simon <doug.simon@oracle.com>
parents:
13683
diff
changeset
|
522 // Size (in bytes) of object |
80cd5c3b8827
partially fixed passing of object parameters to PTX kernels; use a C++ object for managing resource allocation and cleanup around a PTX kernel execution
Doug Simon <doug.simon@oracle.com>
parents:
13683
diff
changeset
|
523 int objSize = obj->size() * HeapWordSize; |
80cd5c3b8827
partially fixed passing of object parameters to PTX kernels; use a C++ object for managing resource allocation and cleanup around a PTX kernel execution
Doug Simon <doug.simon@oracle.com>
parents:
13683
diff
changeset
|
524 //tty->print_cr("Pinning object %d at offset %d: %p", i, offset, obj); |
13888
51584f76462d
pulled Ptx and Hsail classes out of gpu class namespace
Doug Simon <doug.simon@oracle.com>
parents:
13851
diff
changeset
|
525 if (!check(Ptx::_cuda_cu_mem_host_register(obj, objSize, GRAAL_CU_MEMHOSTREGISTER_DEVICEMAP), "Pin object")) { |
13753
80cd5c3b8827
partially fixed passing of object parameters to PTX kernels; use a C++ object for managing resource allocation and cleanup around a PTX kernel execution
Doug Simon <doug.simon@oracle.com>
parents:
13683
diff
changeset
|
526 return; |
80cd5c3b8827
partially fixed passing of object parameters to PTX kernels; use a C++ object for managing resource allocation and cleanup around a PTX kernel execution
Doug Simon <doug.simon@oracle.com>
parents:
13683
diff
changeset
|
527 } |
80cd5c3b8827
partially fixed passing of object parameters to PTX kernels; use a C++ object for managing resource allocation and cleanup around a PTX kernel execution
Doug Simon <doug.simon@oracle.com>
parents:
13683
diff
changeset
|
528 |
80cd5c3b8827
partially fixed passing of object parameters to PTX kernels; use a C++ object for managing resource allocation and cleanup around a PTX kernel execution
Doug Simon <doug.simon@oracle.com>
parents:
13683
diff
changeset
|
529 // Record original oop so that its memory can be unpinned |
80cd5c3b8827
partially fixed passing of object parameters to PTX kernels; use a C++ object for managing resource allocation and cleanup around a PTX kernel execution
Doug Simon <doug.simon@oracle.com>
parents:
13683
diff
changeset
|
530 _pinned[_pinned_length++] = obj; |
80cd5c3b8827
partially fixed passing of object parameters to PTX kernels; use a C++ object for managing resource allocation and cleanup around a PTX kernel execution
Doug Simon <doug.simon@oracle.com>
parents:
13683
diff
changeset
|
531 |
80cd5c3b8827
partially fixed passing of object parameters to PTX kernels; use a C++ object for managing resource allocation and cleanup around a PTX kernel execution
Doug Simon <doug.simon@oracle.com>
parents:
13683
diff
changeset
|
532 // Replace host pointer to object with device pointer |
80cd5c3b8827
partially fixed passing of object parameters to PTX kernels; use a C++ object for managing resource allocation and cleanup around a PTX kernel execution
Doug Simon <doug.simon@oracle.com>
parents:
13683
diff
changeset
|
533 // to object in kernel parameters buffer |
13888
51584f76462d
pulled Ptx and Hsail classes out of gpu class namespace
Doug Simon <doug.simon@oracle.com>
parents:
13851
diff
changeset
|
534 if (!check(Ptx::_cuda_cu_mem_host_get_device_pointer((Ptx::CUdeviceptr*) argPtr, obj, 0), "Get device pointer for pinned object")) { |
13753
80cd5c3b8827
partially fixed passing of object parameters to PTX kernels; use a C++ object for managing resource allocation and cleanup around a PTX kernel execution
Doug Simon <doug.simon@oracle.com>
parents:
13683
diff
changeset
|
535 return; |
80cd5c3b8827
partially fixed passing of object parameters to PTX kernels; use a C++ object for managing resource allocation and cleanup around a PTX kernel execution
Doug Simon <doug.simon@oracle.com>
parents:
13683
diff
changeset
|
536 } |
80cd5c3b8827
partially fixed passing of object parameters to PTX kernels; use a C++ object for managing resource allocation and cleanup around a PTX kernel execution
Doug Simon <doug.simon@oracle.com>
parents:
13683
diff
changeset
|
537 } |
80cd5c3b8827
partially fixed passing of object parameters to PTX kernels; use a C++ object for managing resource allocation and cleanup around a PTX kernel execution
Doug Simon <doug.simon@oracle.com>
parents:
13683
diff
changeset
|
538 } |
80cd5c3b8827
partially fixed passing of object parameters to PTX kernels; use a C++ object for managing resource allocation and cleanup around a PTX kernel execution
Doug Simon <doug.simon@oracle.com>
parents:
13683
diff
changeset
|
539 } |
80cd5c3b8827
partially fixed passing of object parameters to PTX kernels; use a C++ object for managing resource allocation and cleanup around a PTX kernel execution
Doug Simon <doug.simon@oracle.com>
parents:
13683
diff
changeset
|
540 |
80cd5c3b8827
partially fixed passing of object parameters to PTX kernels; use a C++ object for managing resource allocation and cleanup around a PTX kernel execution
Doug Simon <doug.simon@oracle.com>
parents:
13683
diff
changeset
|
541 void launch(address kernel, jint dimX, jint dimY, jint dimZ) { |
80cd5c3b8827
partially fixed passing of object parameters to PTX kernels; use a C++ object for managing resource allocation and cleanup around a PTX kernel execution
Doug Simon <doug.simon@oracle.com>
parents:
13683
diff
changeset
|
542 // grid dimensionality |
80cd5c3b8827
partially fixed passing of object parameters to PTX kernels; use a C++ object for managing resource allocation and cleanup around a PTX kernel execution
Doug Simon <doug.simon@oracle.com>
parents:
13683
diff
changeset
|
543 unsigned int gridX = 1; |
80cd5c3b8827
partially fixed passing of object parameters to PTX kernels; use a C++ object for managing resource allocation and cleanup around a PTX kernel execution
Doug Simon <doug.simon@oracle.com>
parents:
13683
diff
changeset
|
544 unsigned int gridY = 1; |
80cd5c3b8827
partially fixed passing of object parameters to PTX kernels; use a C++ object for managing resource allocation and cleanup around a PTX kernel execution
Doug Simon <doug.simon@oracle.com>
parents:
13683
diff
changeset
|
545 unsigned int gridZ = 1; |
80cd5c3b8827
partially fixed passing of object parameters to PTX kernels; use a C++ object for managing resource allocation and cleanup around a PTX kernel execution
Doug Simon <doug.simon@oracle.com>
parents:
13683
diff
changeset
|
546 void * config[] = { |
80cd5c3b8827
partially fixed passing of object parameters to PTX kernels; use a C++ object for managing resource allocation and cleanup around a PTX kernel execution
Doug Simon <doug.simon@oracle.com>
parents:
13683
diff
changeset
|
547 GRAAL_CU_LAUNCH_PARAM_BUFFER_POINTER, (char*) (address) _buffer, |
80cd5c3b8827
partially fixed passing of object parameters to PTX kernels; use a C++ object for managing resource allocation and cleanup around a PTX kernel execution
Doug Simon <doug.simon@oracle.com>
parents:
13683
diff
changeset
|
548 GRAAL_CU_LAUNCH_PARAM_BUFFER_SIZE, &_buffer_size, |
80cd5c3b8827
partially fixed passing of object parameters to PTX kernels; use a C++ object for managing resource allocation and cleanup around a PTX kernel execution
Doug Simon <doug.simon@oracle.com>
parents:
13683
diff
changeset
|
549 GRAAL_CU_LAUNCH_PARAM_END |
80cd5c3b8827
partially fixed passing of object parameters to PTX kernels; use a C++ object for managing resource allocation and cleanup around a PTX kernel execution
Doug Simon <doug.simon@oracle.com>
parents:
13683
diff
changeset
|
550 }; |
13888
51584f76462d
pulled Ptx and Hsail classes out of gpu class namespace
Doug Simon <doug.simon@oracle.com>
parents:
13851
diff
changeset
|
551 if (check(Ptx::_cuda_cu_launch_kernel((struct CUfunc_st*) (address) kernel, |
13753
80cd5c3b8827
partially fixed passing of object parameters to PTX kernels; use a C++ object for managing resource allocation and cleanup around a PTX kernel execution
Doug Simon <doug.simon@oracle.com>
parents:
13683
diff
changeset
|
552 gridX, gridY, gridZ, |
80cd5c3b8827
partially fixed passing of object parameters to PTX kernels; use a C++ object for managing resource allocation and cleanup around a PTX kernel execution
Doug Simon <doug.simon@oracle.com>
parents:
13683
diff
changeset
|
553 dimX, dimY, dimZ, |
80cd5c3b8827
partially fixed passing of object parameters to PTX kernels; use a C++ object for managing resource allocation and cleanup around a PTX kernel execution
Doug Simon <doug.simon@oracle.com>
parents:
13683
diff
changeset
|
554 0, NULL, NULL, (void**) &config), "Launch kernel")) { |
80cd5c3b8827
partially fixed passing of object parameters to PTX kernels; use a C++ object for managing resource allocation and cleanup around a PTX kernel execution
Doug Simon <doug.simon@oracle.com>
parents:
13683
diff
changeset
|
555 } |
80cd5c3b8827
partially fixed passing of object parameters to PTX kernels; use a C++ object for managing resource allocation and cleanup around a PTX kernel execution
Doug Simon <doug.simon@oracle.com>
parents:
13683
diff
changeset
|
556 } |
80cd5c3b8827
partially fixed passing of object parameters to PTX kernels; use a C++ object for managing resource allocation and cleanup around a PTX kernel execution
Doug Simon <doug.simon@oracle.com>
parents:
13683
diff
changeset
|
557 |
80cd5c3b8827
partially fixed passing of object parameters to PTX kernels; use a C++ object for managing resource allocation and cleanup around a PTX kernel execution
Doug Simon <doug.simon@oracle.com>
parents:
13683
diff
changeset
|
558 void synchronize() { |
13888
51584f76462d
pulled Ptx and Hsail classes out of gpu class namespace
Doug Simon <doug.simon@oracle.com>
parents:
13851
diff
changeset
|
559 check(Ptx::_cuda_cu_ctx_synchronize(), "Synchronize kernel"); |
13753
80cd5c3b8827
partially fixed passing of object parameters to PTX kernels; use a C++ object for managing resource allocation and cleanup around a PTX kernel execution
Doug Simon <doug.simon@oracle.com>
parents:
13683
diff
changeset
|
560 } |
80cd5c3b8827
partially fixed passing of object parameters to PTX kernels; use a C++ object for managing resource allocation and cleanup around a PTX kernel execution
Doug Simon <doug.simon@oracle.com>
parents:
13683
diff
changeset
|
561 |
80cd5c3b8827
partially fixed passing of object parameters to PTX kernels; use a C++ object for managing resource allocation and cleanup around a PTX kernel execution
Doug Simon <doug.simon@oracle.com>
parents:
13683
diff
changeset
|
562 void unpin_objects() { |
80cd5c3b8827
partially fixed passing of object parameters to PTX kernels; use a C++ object for managing resource allocation and cleanup around a PTX kernel execution
Doug Simon <doug.simon@oracle.com>
parents:
13683
diff
changeset
|
563 while (_pinned_length > 0) { |
80cd5c3b8827
partially fixed passing of object parameters to PTX kernels; use a C++ object for managing resource allocation and cleanup around a PTX kernel execution
Doug Simon <doug.simon@oracle.com>
parents:
13683
diff
changeset
|
564 oop obj = _pinned[--_pinned_length]; |
80cd5c3b8827
partially fixed passing of object parameters to PTX kernels; use a C++ object for managing resource allocation and cleanup around a PTX kernel execution
Doug Simon <doug.simon@oracle.com>
parents:
13683
diff
changeset
|
565 assert(obj != NULL, "npe"); |
80cd5c3b8827
partially fixed passing of object parameters to PTX kernels; use a C++ object for managing resource allocation and cleanup around a PTX kernel execution
Doug Simon <doug.simon@oracle.com>
parents:
13683
diff
changeset
|
566 //tty->print_cr("Unpinning object %d: %p", _pinned_length, obj); |
13888
51584f76462d
pulled Ptx and Hsail classes out of gpu class namespace
Doug Simon <doug.simon@oracle.com>
parents:
13851
diff
changeset
|
567 if (!check(Ptx::_cuda_cu_mem_host_unregister(obj), "Unpin object")) { |
13753
80cd5c3b8827
partially fixed passing of object parameters to PTX kernels; use a C++ object for managing resource allocation and cleanup around a PTX kernel execution
Doug Simon <doug.simon@oracle.com>
parents:
13683
diff
changeset
|
568 return; |
80cd5c3b8827
partially fixed passing of object parameters to PTX kernels; use a C++ object for managing resource allocation and cleanup around a PTX kernel execution
Doug Simon <doug.simon@oracle.com>
parents:
13683
diff
changeset
|
569 } |
80cd5c3b8827
partially fixed passing of object parameters to PTX kernels; use a C++ object for managing resource allocation and cleanup around a PTX kernel execution
Doug Simon <doug.simon@oracle.com>
parents:
13683
diff
changeset
|
570 } |
80cd5c3b8827
partially fixed passing of object parameters to PTX kernels; use a C++ object for managing resource allocation and cleanup around a PTX kernel execution
Doug Simon <doug.simon@oracle.com>
parents:
13683
diff
changeset
|
571 } |
80cd5c3b8827
partially fixed passing of object parameters to PTX kernels; use a C++ object for managing resource allocation and cleanup around a PTX kernel execution
Doug Simon <doug.simon@oracle.com>
parents:
13683
diff
changeset
|
572 |
80cd5c3b8827
partially fixed passing of object parameters to PTX kernels; use a C++ object for managing resource allocation and cleanup around a PTX kernel execution
Doug Simon <doug.simon@oracle.com>
parents:
13683
diff
changeset
|
573 oop get_object_return_value() { |
80cd5c3b8827
partially fixed passing of object parameters to PTX kernels; use a C++ object for managing resource allocation and cleanup around a PTX kernel execution
Doug Simon <doug.simon@oracle.com>
parents:
13683
diff
changeset
|
574 oop return_val; |
13888
51584f76462d
pulled Ptx and Hsail classes out of gpu class namespace
Doug Simon <doug.simon@oracle.com>
parents:
13851
diff
changeset
|
575 check(Ptx::_cuda_cu_memcpy_dtoh(&return_val, _ret_value, T_OBJECT_BYTE_SIZE), "Copy return value from device"); |
13753
80cd5c3b8827
partially fixed passing of object parameters to PTX kernels; use a C++ object for managing resource allocation and cleanup around a PTX kernel execution
Doug Simon <doug.simon@oracle.com>
parents:
13683
diff
changeset
|
576 return return_val; |
80cd5c3b8827
partially fixed passing of object parameters to PTX kernels; use a C++ object for managing resource allocation and cleanup around a PTX kernel execution
Doug Simon <doug.simon@oracle.com>
parents:
13683
diff
changeset
|
577 } |
80cd5c3b8827
partially fixed passing of object parameters to PTX kernels; use a C++ object for managing resource allocation and cleanup around a PTX kernel execution
Doug Simon <doug.simon@oracle.com>
parents:
13683
diff
changeset
|
578 |
80cd5c3b8827
partially fixed passing of object parameters to PTX kernels; use a C++ object for managing resource allocation and cleanup around a PTX kernel execution
Doug Simon <doug.simon@oracle.com>
parents:
13683
diff
changeset
|
579 jlong get_primitive_return_value() { |
80cd5c3b8827
partially fixed passing of object parameters to PTX kernels; use a C++ object for managing resource allocation and cleanup around a PTX kernel execution
Doug Simon <doug.simon@oracle.com>
parents:
13683
diff
changeset
|
580 jlong return_val; |
13888
51584f76462d
pulled Ptx and Hsail classes out of gpu class namespace
Doug Simon <doug.simon@oracle.com>
parents:
13851
diff
changeset
|
581 check(Ptx::_cuda_cu_memcpy_dtoh(&return_val, _ret_value, _ret_type_size), "Copy return value from device"); |
13753
80cd5c3b8827
partially fixed passing of object parameters to PTX kernels; use a C++ object for managing resource allocation and cleanup around a PTX kernel execution
Doug Simon <doug.simon@oracle.com>
parents:
13683
diff
changeset
|
582 return return_val; |
80cd5c3b8827
partially fixed passing of object parameters to PTX kernels; use a C++ object for managing resource allocation and cleanup around a PTX kernel execution
Doug Simon <doug.simon@oracle.com>
parents:
13683
diff
changeset
|
583 } |
80cd5c3b8827
partially fixed passing of object parameters to PTX kernels; use a C++ object for managing resource allocation and cleanup around a PTX kernel execution
Doug Simon <doug.simon@oracle.com>
parents:
13683
diff
changeset
|
584 |
80cd5c3b8827
partially fixed passing of object parameters to PTX kernels; use a C++ object for managing resource allocation and cleanup around a PTX kernel execution
Doug Simon <doug.simon@oracle.com>
parents:
13683
diff
changeset
|
585 void free_return_value() { |
80cd5c3b8827
partially fixed passing of object parameters to PTX kernels; use a C++ object for managing resource allocation and cleanup around a PTX kernel execution
Doug Simon <doug.simon@oracle.com>
parents:
13683
diff
changeset
|
586 if (_ret_value != 0) { |
13888
51584f76462d
pulled Ptx and Hsail classes out of gpu class namespace
Doug Simon <doug.simon@oracle.com>
parents:
13851
diff
changeset
|
587 check(Ptx::_cuda_cu_memfree(_ret_value), "Free device memory"); |
13753
80cd5c3b8827
partially fixed passing of object parameters to PTX kernels; use a C++ object for managing resource allocation and cleanup around a PTX kernel execution
Doug Simon <doug.simon@oracle.com>
parents:
13683
diff
changeset
|
588 _ret_value = 0; |
80cd5c3b8827
partially fixed passing of object parameters to PTX kernels; use a C++ object for managing resource allocation and cleanup around a PTX kernel execution
Doug Simon <doug.simon@oracle.com>
parents:
13683
diff
changeset
|
589 } |
80cd5c3b8827
partially fixed passing of object parameters to PTX kernels; use a C++ object for managing resource allocation and cleanup around a PTX kernel execution
Doug Simon <doug.simon@oracle.com>
parents:
13683
diff
changeset
|
590 } |
80cd5c3b8827
partially fixed passing of object parameters to PTX kernels; use a C++ object for managing resource allocation and cleanup around a PTX kernel execution
Doug Simon <doug.simon@oracle.com>
parents:
13683
diff
changeset
|
591 |
80cd5c3b8827
partially fixed passing of object parameters to PTX kernels; use a C++ object for managing resource allocation and cleanup around a PTX kernel execution
Doug Simon <doug.simon@oracle.com>
parents:
13683
diff
changeset
|
592 ~PtxCall() { |
80cd5c3b8827
partially fixed passing of object parameters to PTX kernels; use a C++ object for managing resource allocation and cleanup around a PTX kernel execution
Doug Simon <doug.simon@oracle.com>
parents:
13683
diff
changeset
|
593 unpin_objects(); |
80cd5c3b8827
partially fixed passing of object parameters to PTX kernels; use a C++ object for managing resource allocation and cleanup around a PTX kernel execution
Doug Simon <doug.simon@oracle.com>
parents:
13683
diff
changeset
|
594 free_return_value(); |
13832
ab370d74a8eb
implemented GC locking for duration of a PTX kernel call
Doug Simon <doug.simon@oracle.com>
parents:
13819
diff
changeset
|
595 if (_gc_locked) { |
ab370d74a8eb
implemented GC locking for duration of a PTX kernel call
Doug Simon <doug.simon@oracle.com>
parents:
13819
diff
changeset
|
596 GC_locker::unlock_critical(_thread); |
ab370d74a8eb
implemented GC locking for duration of a PTX kernel call
Doug Simon <doug.simon@oracle.com>
parents:
13819
diff
changeset
|
597 if (TraceGPUInteraction) { |
ab370d74a8eb
implemented GC locking for duration of a PTX kernel call
Doug Simon <doug.simon@oracle.com>
parents:
13819
diff
changeset
|
598 tty->print_cr("[CUDA] Unlocked GC"); |
ab370d74a8eb
implemented GC locking for duration of a PTX kernel call
Doug Simon <doug.simon@oracle.com>
parents:
13819
diff
changeset
|
599 } |
13848
b97e2515d392
removed PTXKernelArguments; added mechanism for printing incoming kernel arguments
Doug Simon <doug.simon@oracle.com>
parents:
13834
diff
changeset
|
600 _gc_locked = false; |
13832
ab370d74a8eb
implemented GC locking for duration of a PTX kernel call
Doug Simon <doug.simon@oracle.com>
parents:
13819
diff
changeset
|
601 } |
13753
80cd5c3b8827
partially fixed passing of object parameters to PTX kernels; use a C++ object for managing resource allocation and cleanup around a PTX kernel execution
Doug Simon <doug.simon@oracle.com>
parents:
13683
diff
changeset
|
602 } |
80cd5c3b8827
partially fixed passing of object parameters to PTX kernels; use a C++ object for managing resource allocation and cleanup around a PTX kernel execution
Doug Simon <doug.simon@oracle.com>
parents:
13683
diff
changeset
|
603 }; |
80cd5c3b8827
partially fixed passing of object parameters to PTX kernels; use a C++ object for managing resource allocation and cleanup around a PTX kernel execution
Doug Simon <doug.simon@oracle.com>
parents:
13683
diff
changeset
|
604 |
13848
b97e2515d392
removed PTXKernelArguments; added mechanism for printing incoming kernel arguments
Doug Simon <doug.simon@oracle.com>
parents:
13834
diff
changeset
|
605 // Prints values in the kernel arguments buffer |
b97e2515d392
removed PTXKernelArguments; added mechanism for printing incoming kernel arguments
Doug Simon <doug.simon@oracle.com>
parents:
13834
diff
changeset
|
606 class KernelArgumentsPrinter: public SignatureIterator { |
b97e2515d392
removed PTXKernelArguments; added mechanism for printing incoming kernel arguments
Doug Simon <doug.simon@oracle.com>
parents:
13834
diff
changeset
|
607 Method* _method; |
b97e2515d392
removed PTXKernelArguments; added mechanism for printing incoming kernel arguments
Doug Simon <doug.simon@oracle.com>
parents:
13834
diff
changeset
|
608 address _buffer; |
b97e2515d392
removed PTXKernelArguments; added mechanism for printing incoming kernel arguments
Doug Simon <doug.simon@oracle.com>
parents:
13834
diff
changeset
|
609 size_t _bufferOffset; |
b97e2515d392
removed PTXKernelArguments; added mechanism for printing incoming kernel arguments
Doug Simon <doug.simon@oracle.com>
parents:
13834
diff
changeset
|
610 outputStream* _st; |
b97e2515d392
removed PTXKernelArguments; added mechanism for printing incoming kernel arguments
Doug Simon <doug.simon@oracle.com>
parents:
13834
diff
changeset
|
611 |
b97e2515d392
removed PTXKernelArguments; added mechanism for printing incoming kernel arguments
Doug Simon <doug.simon@oracle.com>
parents:
13834
diff
changeset
|
612 private: |
b97e2515d392
removed PTXKernelArguments; added mechanism for printing incoming kernel arguments
Doug Simon <doug.simon@oracle.com>
parents:
13834
diff
changeset
|
613 |
b97e2515d392
removed PTXKernelArguments; added mechanism for printing incoming kernel arguments
Doug Simon <doug.simon@oracle.com>
parents:
13834
diff
changeset
|
614 // Get next java argument |
b97e2515d392
removed PTXKernelArguments; added mechanism for printing incoming kernel arguments
Doug Simon <doug.simon@oracle.com>
parents:
13834
diff
changeset
|
615 oop next_arg(BasicType expectedType); |
b97e2515d392
removed PTXKernelArguments; added mechanism for printing incoming kernel arguments
Doug Simon <doug.simon@oracle.com>
parents:
13834
diff
changeset
|
616 |
b97e2515d392
removed PTXKernelArguments; added mechanism for printing incoming kernel arguments
Doug Simon <doug.simon@oracle.com>
parents:
13834
diff
changeset
|
617 public: |
b97e2515d392
removed PTXKernelArguments; added mechanism for printing incoming kernel arguments
Doug Simon <doug.simon@oracle.com>
parents:
13834
diff
changeset
|
618 KernelArgumentsPrinter(Method* method, address buffer, outputStream* st) : SignatureIterator(method->signature()), |
b97e2515d392
removed PTXKernelArguments; added mechanism for printing incoming kernel arguments
Doug Simon <doug.simon@oracle.com>
parents:
13834
diff
changeset
|
619 _method(method), _buffer(buffer), _bufferOffset(0), _st(st) { |
b97e2515d392
removed PTXKernelArguments; added mechanism for printing incoming kernel arguments
Doug Simon <doug.simon@oracle.com>
parents:
13834
diff
changeset
|
620 if (!method->is_static()) { |
b97e2515d392
removed PTXKernelArguments; added mechanism for printing incoming kernel arguments
Doug Simon <doug.simon@oracle.com>
parents:
13834
diff
changeset
|
621 print_oop(); |
b97e2515d392
removed PTXKernelArguments; added mechanism for printing incoming kernel arguments
Doug Simon <doug.simon@oracle.com>
parents:
13834
diff
changeset
|
622 } |
b97e2515d392
removed PTXKernelArguments; added mechanism for printing incoming kernel arguments
Doug Simon <doug.simon@oracle.com>
parents:
13834
diff
changeset
|
623 iterate(); |
b97e2515d392
removed PTXKernelArguments; added mechanism for printing incoming kernel arguments
Doug Simon <doug.simon@oracle.com>
parents:
13834
diff
changeset
|
624 } |
b97e2515d392
removed PTXKernelArguments; added mechanism for printing incoming kernel arguments
Doug Simon <doug.simon@oracle.com>
parents:
13834
diff
changeset
|
625 |
b97e2515d392
removed PTXKernelArguments; added mechanism for printing incoming kernel arguments
Doug Simon <doug.simon@oracle.com>
parents:
13834
diff
changeset
|
626 address next(size_t dataSz) { |
b97e2515d392
removed PTXKernelArguments; added mechanism for printing incoming kernel arguments
Doug Simon <doug.simon@oracle.com>
parents:
13834
diff
changeset
|
627 if (is_return_type()) { |
b97e2515d392
removed PTXKernelArguments; added mechanism for printing incoming kernel arguments
Doug Simon <doug.simon@oracle.com>
parents:
13834
diff
changeset
|
628 return _buffer; |
b97e2515d392
removed PTXKernelArguments; added mechanism for printing incoming kernel arguments
Doug Simon <doug.simon@oracle.com>
parents:
13834
diff
changeset
|
629 } |
b97e2515d392
removed PTXKernelArguments; added mechanism for printing incoming kernel arguments
Doug Simon <doug.simon@oracle.com>
parents:
13834
diff
changeset
|
630 if (_bufferOffset != 0) { |
b97e2515d392
removed PTXKernelArguments; added mechanism for printing incoming kernel arguments
Doug Simon <doug.simon@oracle.com>
parents:
13834
diff
changeset
|
631 _st->print(", "); |
b97e2515d392
removed PTXKernelArguments; added mechanism for printing incoming kernel arguments
Doug Simon <doug.simon@oracle.com>
parents:
13834
diff
changeset
|
632 } |
b97e2515d392
removed PTXKernelArguments; added mechanism for printing incoming kernel arguments
Doug Simon <doug.simon@oracle.com>
parents:
13834
diff
changeset
|
633 _bufferOffset = align_size_up_(_bufferOffset, dataSz); |
b97e2515d392
removed PTXKernelArguments; added mechanism for printing incoming kernel arguments
Doug Simon <doug.simon@oracle.com>
parents:
13834
diff
changeset
|
634 address result = _buffer + _bufferOffset; |
b97e2515d392
removed PTXKernelArguments; added mechanism for printing incoming kernel arguments
Doug Simon <doug.simon@oracle.com>
parents:
13834
diff
changeset
|
635 _bufferOffset += dataSz; |
b97e2515d392
removed PTXKernelArguments; added mechanism for printing incoming kernel arguments
Doug Simon <doug.simon@oracle.com>
parents:
13834
diff
changeset
|
636 return result; |
b97e2515d392
removed PTXKernelArguments; added mechanism for printing incoming kernel arguments
Doug Simon <doug.simon@oracle.com>
parents:
13834
diff
changeset
|
637 } |
b97e2515d392
removed PTXKernelArguments; added mechanism for printing incoming kernel arguments
Doug Simon <doug.simon@oracle.com>
parents:
13834
diff
changeset
|
638 |
b97e2515d392
removed PTXKernelArguments; added mechanism for printing incoming kernel arguments
Doug Simon <doug.simon@oracle.com>
parents:
13834
diff
changeset
|
639 void print_oop() { |
b97e2515d392
removed PTXKernelArguments; added mechanism for printing incoming kernel arguments
Doug Simon <doug.simon@oracle.com>
parents:
13834
diff
changeset
|
640 oop obj = *((oop*) next(sizeof(oop))); |
b97e2515d392
removed PTXKernelArguments; added mechanism for printing incoming kernel arguments
Doug Simon <doug.simon@oracle.com>
parents:
13834
diff
changeset
|
641 if (obj != NULL) { |
b97e2515d392
removed PTXKernelArguments; added mechanism for printing incoming kernel arguments
Doug Simon <doug.simon@oracle.com>
parents:
13834
diff
changeset
|
642 char type[256]; |
b97e2515d392
removed PTXKernelArguments; added mechanism for printing incoming kernel arguments
Doug Simon <doug.simon@oracle.com>
parents:
13834
diff
changeset
|
643 obj->klass()->name()->as_C_string(type, 256); |
18043
f55f2d400797
Fix some format strings
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15582
diff
changeset
|
644 _st->print("oop "INTPTR_FORMAT" (%s)", p2i(obj), type); |
13848
b97e2515d392
removed PTXKernelArguments; added mechanism for printing incoming kernel arguments
Doug Simon <doug.simon@oracle.com>
parents:
13834
diff
changeset
|
645 } else { |
b97e2515d392
removed PTXKernelArguments; added mechanism for printing incoming kernel arguments
Doug Simon <doug.simon@oracle.com>
parents:
13834
diff
changeset
|
646 _st->print("oop null"); |
b97e2515d392
removed PTXKernelArguments; added mechanism for printing incoming kernel arguments
Doug Simon <doug.simon@oracle.com>
parents:
13834
diff
changeset
|
647 } |
b97e2515d392
removed PTXKernelArguments; added mechanism for printing incoming kernel arguments
Doug Simon <doug.simon@oracle.com>
parents:
13834
diff
changeset
|
648 } |
b97e2515d392
removed PTXKernelArguments; added mechanism for printing incoming kernel arguments
Doug Simon <doug.simon@oracle.com>
parents:
13834
diff
changeset
|
649 |
b97e2515d392
removed PTXKernelArguments; added mechanism for printing incoming kernel arguments
Doug Simon <doug.simon@oracle.com>
parents:
13834
diff
changeset
|
650 bool skip() { |
b97e2515d392
removed PTXKernelArguments; added mechanism for printing incoming kernel arguments
Doug Simon <doug.simon@oracle.com>
parents:
13834
diff
changeset
|
651 return is_return_type(); |
b97e2515d392
removed PTXKernelArguments; added mechanism for printing incoming kernel arguments
Doug Simon <doug.simon@oracle.com>
parents:
13834
diff
changeset
|
652 } |
b97e2515d392
removed PTXKernelArguments; added mechanism for printing incoming kernel arguments
Doug Simon <doug.simon@oracle.com>
parents:
13834
diff
changeset
|
653 |
b97e2515d392
removed PTXKernelArguments; added mechanism for printing incoming kernel arguments
Doug Simon <doug.simon@oracle.com>
parents:
13834
diff
changeset
|
654 void do_bool () { if (!skip()) _st->print("bool %d", *((jboolean*) next(sizeof(jboolean)))); } |
b97e2515d392
removed PTXKernelArguments; added mechanism for printing incoming kernel arguments
Doug Simon <doug.simon@oracle.com>
parents:
13834
diff
changeset
|
655 void do_char () { if (!skip()) _st->print("char %c", *((jchar*) next(sizeof(jchar)))); } |
b97e2515d392
removed PTXKernelArguments; added mechanism for printing incoming kernel arguments
Doug Simon <doug.simon@oracle.com>
parents:
13834
diff
changeset
|
656 void do_float () { if (!skip()) _st->print("float %g", *((jfloat*) next(sizeof(jfloat)))); } |
b97e2515d392
removed PTXKernelArguments; added mechanism for printing incoming kernel arguments
Doug Simon <doug.simon@oracle.com>
parents:
13834
diff
changeset
|
657 void do_double() { if (!skip()) _st->print("double %g", *((jdouble*) next(sizeof(jdouble)))); } |
b97e2515d392
removed PTXKernelArguments; added mechanism for printing incoming kernel arguments
Doug Simon <doug.simon@oracle.com>
parents:
13834
diff
changeset
|
658 void do_byte () { if (!skip()) _st->print("byte %d", *((jbyte*) next(sizeof(jbyte)))); } |
b97e2515d392
removed PTXKernelArguments; added mechanism for printing incoming kernel arguments
Doug Simon <doug.simon@oracle.com>
parents:
13834
diff
changeset
|
659 void do_short () { if (!skip()) _st->print("short %d", *((jshort*) next(sizeof(jshort)))); } |
b97e2515d392
removed PTXKernelArguments; added mechanism for printing incoming kernel arguments
Doug Simon <doug.simon@oracle.com>
parents:
13834
diff
changeset
|
660 void do_int () { if (!skip()) _st->print("int %d", *((jint*) next(sizeof(jint)))); } |
b97e2515d392
removed PTXKernelArguments; added mechanism for printing incoming kernel arguments
Doug Simon <doug.simon@oracle.com>
parents:
13834
diff
changeset
|
661 void do_long () { if (!skip()) _st->print("long "JLONG_FORMAT, *((jlong*) next(sizeof(jlong)))); } |
b97e2515d392
removed PTXKernelArguments; added mechanism for printing incoming kernel arguments
Doug Simon <doug.simon@oracle.com>
parents:
13834
diff
changeset
|
662 void do_void () { } |
b97e2515d392
removed PTXKernelArguments; added mechanism for printing incoming kernel arguments
Doug Simon <doug.simon@oracle.com>
parents:
13834
diff
changeset
|
663 void do_object(int begin, int end) { if (!skip()) print_oop(); } |
b97e2515d392
removed PTXKernelArguments; added mechanism for printing incoming kernel arguments
Doug Simon <doug.simon@oracle.com>
parents:
13834
diff
changeset
|
664 void do_array (int begin, int end) { if (!skip()) print_oop(); } |
b97e2515d392
removed PTXKernelArguments; added mechanism for printing incoming kernel arguments
Doug Simon <doug.simon@oracle.com>
parents:
13834
diff
changeset
|
665 }; |
b97e2515d392
removed PTXKernelArguments; added mechanism for printing incoming kernel arguments
Doug Simon <doug.simon@oracle.com>
parents:
13834
diff
changeset
|
666 |
b97e2515d392
removed PTXKernelArguments; added mechanism for printing incoming kernel arguments
Doug Simon <doug.simon@oracle.com>
parents:
13834
diff
changeset
|
667 static void printKernelArguments(JavaThread* thread, address buffer) { |
b97e2515d392
removed PTXKernelArguments; added mechanism for printing incoming kernel arguments
Doug Simon <doug.simon@oracle.com>
parents:
13834
diff
changeset
|
668 for (vframeStream vfst(thread); !vfst.at_end(); vfst.next()) { |
b97e2515d392
removed PTXKernelArguments; added mechanism for printing incoming kernel arguments
Doug Simon <doug.simon@oracle.com>
parents:
13834
diff
changeset
|
669 Method* m = vfst.method(); |
b97e2515d392
removed PTXKernelArguments; added mechanism for printing incoming kernel arguments
Doug Simon <doug.simon@oracle.com>
parents:
13834
diff
changeset
|
670 if (m != NULL) { |
14040
2d95cf7a29c8
Fixes PTX test failure and a crash when TraceGPUInteraction flag is specified.
S.Bharadwaj Yadavalli <bharadwaj.yadavalli@oracle.com>
parents:
13922
diff
changeset
|
671 ResourceMark rm; |
13848
b97e2515d392
removed PTXKernelArguments; added mechanism for printing incoming kernel arguments
Doug Simon <doug.simon@oracle.com>
parents:
13834
diff
changeset
|
672 stringStream st(O_BUFLEN); |
b97e2515d392
removed PTXKernelArguments; added mechanism for printing incoming kernel arguments
Doug Simon <doug.simon@oracle.com>
parents:
13834
diff
changeset
|
673 st.print("[CUDA] Call: %s.%s(", m->method_holder()->name()->as_C_string(), m->name()->as_C_string()); |
b97e2515d392
removed PTXKernelArguments; added mechanism for printing incoming kernel arguments
Doug Simon <doug.simon@oracle.com>
parents:
13834
diff
changeset
|
674 KernelArgumentsPrinter kap(m, buffer, &st); |
b97e2515d392
removed PTXKernelArguments; added mechanism for printing incoming kernel arguments
Doug Simon <doug.simon@oracle.com>
parents:
13834
diff
changeset
|
675 tty->print_cr("%s)", st.as_string()); |
b97e2515d392
removed PTXKernelArguments; added mechanism for printing incoming kernel arguments
Doug Simon <doug.simon@oracle.com>
parents:
13834
diff
changeset
|
676 return; |
b97e2515d392
removed PTXKernelArguments; added mechanism for printing incoming kernel arguments
Doug Simon <doug.simon@oracle.com>
parents:
13834
diff
changeset
|
677 } |
b97e2515d392
removed PTXKernelArguments; added mechanism for printing incoming kernel arguments
Doug Simon <doug.simon@oracle.com>
parents:
13834
diff
changeset
|
678 } |
b97e2515d392
removed PTXKernelArguments; added mechanism for printing incoming kernel arguments
Doug Simon <doug.simon@oracle.com>
parents:
13834
diff
changeset
|
679 } |
b97e2515d392
removed PTXKernelArguments; added mechanism for printing incoming kernel arguments
Doug Simon <doug.simon@oracle.com>
parents:
13834
diff
changeset
|
680 |
13922
0995dcbd6dd8
Change CUDA context management to support multiple executions of a kernel. Exclude GPU offloading of lambdas from java.* library code.
S.Bharadwaj Yadavalli <bharadwaj.yadavalli@oracle.com>
parents:
13888
diff
changeset
|
681 GPU_VMENTRY(void, Ptx::destroy_ptx_context, (void)) |
0995dcbd6dd8
Change CUDA context management to support multiple executions of a kernel. Exclude GPU offloading of lambdas from java.* library code.
S.Bharadwaj Yadavalli <bharadwaj.yadavalli@oracle.com>
parents:
13888
diff
changeset
|
682 if (_device_context != NULL) { |
0995dcbd6dd8
Change CUDA context management to support multiple executions of a kernel. Exclude GPU offloading of lambdas from java.* library code.
S.Bharadwaj Yadavalli <bharadwaj.yadavalli@oracle.com>
parents:
13888
diff
changeset
|
683 int status = _cuda_cu_ctx_destroy(_device_context); |
0995dcbd6dd8
Change CUDA context management to support multiple executions of a kernel. Exclude GPU offloading of lambdas from java.* library code.
S.Bharadwaj Yadavalli <bharadwaj.yadavalli@oracle.com>
parents:
13888
diff
changeset
|
684 if (status != GRAAL_CUDA_SUCCESS) { |
0995dcbd6dd8
Change CUDA context management to support multiple executions of a kernel. Exclude GPU offloading of lambdas from java.* library code.
S.Bharadwaj Yadavalli <bharadwaj.yadavalli@oracle.com>
parents:
13888
diff
changeset
|
685 if (TraceGPUInteraction) { |
0995dcbd6dd8
Change CUDA context management to support multiple executions of a kernel. Exclude GPU offloading of lambdas from java.* library code.
S.Bharadwaj Yadavalli <bharadwaj.yadavalli@oracle.com>
parents:
13888
diff
changeset
|
686 tty->print_cr("[CUDA] Error(%d) : Failed to destroy context", status); |
0995dcbd6dd8
Change CUDA context management to support multiple executions of a kernel. Exclude GPU offloading of lambdas from java.* library code.
S.Bharadwaj Yadavalli <bharadwaj.yadavalli@oracle.com>
parents:
13888
diff
changeset
|
687 } |
0995dcbd6dd8
Change CUDA context management to support multiple executions of a kernel. Exclude GPU offloading of lambdas from java.* library code.
S.Bharadwaj Yadavalli <bharadwaj.yadavalli@oracle.com>
parents:
13888
diff
changeset
|
688 _device_context = NULL; |
0995dcbd6dd8
Change CUDA context management to support multiple executions of a kernel. Exclude GPU offloading of lambdas from java.* library code.
S.Bharadwaj Yadavalli <bharadwaj.yadavalli@oracle.com>
parents:
13888
diff
changeset
|
689 } else { |
0995dcbd6dd8
Change CUDA context management to support multiple executions of a kernel. Exclude GPU offloading of lambdas from java.* library code.
S.Bharadwaj Yadavalli <bharadwaj.yadavalli@oracle.com>
parents:
13888
diff
changeset
|
690 if (TraceGPUInteraction) { |
18043
f55f2d400797
Fix some format strings
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15582
diff
changeset
|
691 tty->print_cr("[CUDA] Destroyed context"); |
13922
0995dcbd6dd8
Change CUDA context management to support multiple executions of a kernel. Exclude GPU offloading of lambdas from java.* library code.
S.Bharadwaj Yadavalli <bharadwaj.yadavalli@oracle.com>
parents:
13888
diff
changeset
|
692 } |
0995dcbd6dd8
Change CUDA context management to support multiple executions of a kernel. Exclude GPU offloading of lambdas from java.* library code.
S.Bharadwaj Yadavalli <bharadwaj.yadavalli@oracle.com>
parents:
13888
diff
changeset
|
693 } |
0995dcbd6dd8
Change CUDA context management to support multiple executions of a kernel. Exclude GPU offloading of lambdas from java.* library code.
S.Bharadwaj Yadavalli <bharadwaj.yadavalli@oracle.com>
parents:
13888
diff
changeset
|
694 } |
0995dcbd6dd8
Change CUDA context management to support multiple executions of a kernel. Exclude GPU offloading of lambdas from java.* library code.
S.Bharadwaj Yadavalli <bharadwaj.yadavalli@oracle.com>
parents:
13888
diff
changeset
|
695 |
0995dcbd6dd8
Change CUDA context management to support multiple executions of a kernel. Exclude GPU offloading of lambdas from java.* library code.
S.Bharadwaj Yadavalli <bharadwaj.yadavalli@oracle.com>
parents:
13888
diff
changeset
|
696 GPU_END |
0995dcbd6dd8
Change CUDA context management to support multiple executions of a kernel. Exclude GPU offloading of lambdas from java.* library code.
S.Bharadwaj Yadavalli <bharadwaj.yadavalli@oracle.com>
parents:
13888
diff
changeset
|
697 |
13888
51584f76462d
pulled Ptx and Hsail classes out of gpu class namespace
Doug Simon <doug.simon@oracle.com>
parents:
13851
diff
changeset
|
698 GPU_VMENTRY(jlong, Ptx::get_execute_kernel_from_vm_address, (JNIEnv *env, jclass)) |
51584f76462d
pulled Ptx and Hsail classes out of gpu class namespace
Doug Simon <doug.simon@oracle.com>
parents:
13851
diff
changeset
|
699 return (jlong) Ptx::execute_kernel_from_vm; |
13819
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13753
diff
changeset
|
700 GPU_END |
13753
80cd5c3b8827
partially fixed passing of object parameters to PTX kernels; use a C++ object for managing resource allocation and cleanup around a PTX kernel execution
Doug Simon <doug.simon@oracle.com>
parents:
13683
diff
changeset
|
701 |
13888
51584f76462d
pulled Ptx and Hsail classes out of gpu class namespace
Doug Simon <doug.simon@oracle.com>
parents:
13851
diff
changeset
|
702 JRT_ENTRY(jlong, Ptx::execute_kernel_from_vm(JavaThread* thread, jlong kernel, jint dimX, jint dimY, jint dimZ, |
13753
80cd5c3b8827
partially fixed passing of object parameters to PTX kernels; use a C++ object for managing resource allocation and cleanup around a PTX kernel execution
Doug Simon <doug.simon@oracle.com>
parents:
13683
diff
changeset
|
703 jlong buffer, |
80cd5c3b8827
partially fixed passing of object parameters to PTX kernels; use a C++ object for managing resource allocation and cleanup around a PTX kernel execution
Doug Simon <doug.simon@oracle.com>
parents:
13683
diff
changeset
|
704 jint bufferSize, |
80cd5c3b8827
partially fixed passing of object parameters to PTX kernels; use a C++ object for managing resource allocation and cleanup around a PTX kernel execution
Doug Simon <doug.simon@oracle.com>
parents:
13683
diff
changeset
|
705 jint objectParametersCount, |
80cd5c3b8827
partially fixed passing of object parameters to PTX kernels; use a C++ object for managing resource allocation and cleanup around a PTX kernel execution
Doug Simon <doug.simon@oracle.com>
parents:
13683
diff
changeset
|
706 jlong objectParametersOffsets, |
80cd5c3b8827
partially fixed passing of object parameters to PTX kernels; use a C++ object for managing resource allocation and cleanup around a PTX kernel execution
Doug Simon <doug.simon@oracle.com>
parents:
13683
diff
changeset
|
707 jlong pinnedObjects, |
13648
27acedac70b7
added support for @ParallelOver annotation in PTX kernel call wrapper
Doug Simon <doug.simon@oracle.com>
parents:
13624
diff
changeset
|
708 int encodedReturnTypeSize)) |
13624
220ed109bf77
initial code for calling PTX kernel code from Java with parameter marshaling and return value unmarshaling performed by a wrapper specified via manual graph construction
Doug Simon <doug.simon@oracle.com>
parents:
12653
diff
changeset
|
709 if (kernel == 0L) { |
220ed109bf77
initial code for calling PTX kernel code from Java with parameter marshaling and return value unmarshaling performed by a wrapper specified via manual graph construction
Doug Simon <doug.simon@oracle.com>
parents:
12653
diff
changeset
|
710 SharedRuntime::throw_and_post_jvmti_exception(thread, vmSymbols::java_lang_NullPointerException(), NULL); |
220ed109bf77
initial code for calling PTX kernel code from Java with parameter marshaling and return value unmarshaling performed by a wrapper specified via manual graph construction
Doug Simon <doug.simon@oracle.com>
parents:
12653
diff
changeset
|
711 return 0L; |
220ed109bf77
initial code for calling PTX kernel code from Java with parameter marshaling and return value unmarshaling performed by a wrapper specified via manual graph construction
Doug Simon <doug.simon@oracle.com>
parents:
12653
diff
changeset
|
712 } |
220ed109bf77
initial code for calling PTX kernel code from Java with parameter marshaling and return value unmarshaling performed by a wrapper specified via manual graph construction
Doug Simon <doug.simon@oracle.com>
parents:
12653
diff
changeset
|
713 |
13848
b97e2515d392
removed PTXKernelArguments; added mechanism for printing incoming kernel arguments
Doug Simon <doug.simon@oracle.com>
parents:
13834
diff
changeset
|
714 if (TraceGPUInteraction) { |
b97e2515d392
removed PTXKernelArguments; added mechanism for printing incoming kernel arguments
Doug Simon <doug.simon@oracle.com>
parents:
13834
diff
changeset
|
715 printKernelArguments(thread, (address) buffer); |
b97e2515d392
removed PTXKernelArguments; added mechanism for printing incoming kernel arguments
Doug Simon <doug.simon@oracle.com>
parents:
13834
diff
changeset
|
716 } |
b97e2515d392
removed PTXKernelArguments; added mechanism for printing incoming kernel arguments
Doug Simon <doug.simon@oracle.com>
parents:
13834
diff
changeset
|
717 |
13753
80cd5c3b8827
partially fixed passing of object parameters to PTX kernels; use a C++ object for managing resource allocation and cleanup around a PTX kernel execution
Doug Simon <doug.simon@oracle.com>
parents:
13683
diff
changeset
|
718 PtxCall call(thread, (address) buffer, bufferSize, (oop*) (address) pinnedObjects, encodedReturnTypeSize); |
13624
220ed109bf77
initial code for calling PTX kernel code from Java with parameter marshaling and return value unmarshaling performed by a wrapper specified via manual graph construction
Doug Simon <doug.simon@oracle.com>
parents:
12653
diff
changeset
|
719 |
13753
80cd5c3b8827
partially fixed passing of object parameters to PTX kernels; use a C++ object for managing resource allocation and cleanup around a PTX kernel execution
Doug Simon <doug.simon@oracle.com>
parents:
13683
diff
changeset
|
720 #define TRY(action) do { \ |
80cd5c3b8827
partially fixed passing of object parameters to PTX kernels; use a C++ object for managing resource allocation and cleanup around a PTX kernel execution
Doug Simon <doug.simon@oracle.com>
parents:
13683
diff
changeset
|
721 action; \ |
80cd5c3b8827
partially fixed passing of object parameters to PTX kernels; use a C++ object for managing resource allocation and cleanup around a PTX kernel execution
Doug Simon <doug.simon@oracle.com>
parents:
13683
diff
changeset
|
722 if (HAS_PENDING_EXCEPTION) return 0L; \ |
80cd5c3b8827
partially fixed passing of object parameters to PTX kernels; use a C++ object for managing resource allocation and cleanup around a PTX kernel execution
Doug Simon <doug.simon@oracle.com>
parents:
13683
diff
changeset
|
723 } while (0) |
13624
220ed109bf77
initial code for calling PTX kernel code from Java with parameter marshaling and return value unmarshaling performed by a wrapper specified via manual graph construction
Doug Simon <doug.simon@oracle.com>
parents:
12653
diff
changeset
|
724 |
13753
80cd5c3b8827
partially fixed passing of object parameters to PTX kernels; use a C++ object for managing resource allocation and cleanup around a PTX kernel execution
Doug Simon <doug.simon@oracle.com>
parents:
13683
diff
changeset
|
725 TRY(call.alloc_return_value()); |
13624
220ed109bf77
initial code for calling PTX kernel code from Java with parameter marshaling and return value unmarshaling performed by a wrapper specified via manual graph construction
Doug Simon <doug.simon@oracle.com>
parents:
12653
diff
changeset
|
726 |
13753
80cd5c3b8827
partially fixed passing of object parameters to PTX kernels; use a C++ object for managing resource allocation and cleanup around a PTX kernel execution
Doug Simon <doug.simon@oracle.com>
parents:
13683
diff
changeset
|
727 TRY(call.pin_objects(objectParametersCount, (int*) (address) objectParametersOffsets)); |
80cd5c3b8827
partially fixed passing of object parameters to PTX kernels; use a C++ object for managing resource allocation and cleanup around a PTX kernel execution
Doug Simon <doug.simon@oracle.com>
parents:
13683
diff
changeset
|
728 |
80cd5c3b8827
partially fixed passing of object parameters to PTX kernels; use a C++ object for managing resource allocation and cleanup around a PTX kernel execution
Doug Simon <doug.simon@oracle.com>
parents:
13683
diff
changeset
|
729 TRY(call.launch((address) kernel, dimX, dimY, dimZ)); |
13624
220ed109bf77
initial code for calling PTX kernel code from Java with parameter marshaling and return value unmarshaling performed by a wrapper specified via manual graph construction
Doug Simon <doug.simon@oracle.com>
parents:
12653
diff
changeset
|
730 |
13753
80cd5c3b8827
partially fixed passing of object parameters to PTX kernels; use a C++ object for managing resource allocation and cleanup around a PTX kernel execution
Doug Simon <doug.simon@oracle.com>
parents:
13683
diff
changeset
|
731 TRY(call.synchronize()); |
13624
220ed109bf77
initial code for calling PTX kernel code from Java with parameter marshaling and return value unmarshaling performed by a wrapper specified via manual graph construction
Doug Simon <doug.simon@oracle.com>
parents:
12653
diff
changeset
|
732 |
13753
80cd5c3b8827
partially fixed passing of object parameters to PTX kernels; use a C++ object for managing resource allocation and cleanup around a PTX kernel execution
Doug Simon <doug.simon@oracle.com>
parents:
13683
diff
changeset
|
733 if (call.is_object_return()) { |
80cd5c3b8827
partially fixed passing of object parameters to PTX kernels; use a C++ object for managing resource allocation and cleanup around a PTX kernel execution
Doug Simon <doug.simon@oracle.com>
parents:
13683
diff
changeset
|
734 oop return_val; |
80cd5c3b8827
partially fixed passing of object parameters to PTX kernels; use a C++ object for managing resource allocation and cleanup around a PTX kernel execution
Doug Simon <doug.simon@oracle.com>
parents:
13683
diff
changeset
|
735 TRY(return_val = call.get_object_return_value()); |
80cd5c3b8827
partially fixed passing of object parameters to PTX kernels; use a C++ object for managing resource allocation and cleanup around a PTX kernel execution
Doug Simon <doug.simon@oracle.com>
parents:
13683
diff
changeset
|
736 thread->set_vm_result(return_val); |
13624
220ed109bf77
initial code for calling PTX kernel code from Java with parameter marshaling and return value unmarshaling performed by a wrapper specified via manual graph construction
Doug Simon <doug.simon@oracle.com>
parents:
12653
diff
changeset
|
737 return 0L; |
220ed109bf77
initial code for calling PTX kernel code from Java with parameter marshaling and return value unmarshaling performed by a wrapper specified via manual graph construction
Doug Simon <doug.simon@oracle.com>
parents:
12653
diff
changeset
|
738 } |
220ed109bf77
initial code for calling PTX kernel code from Java with parameter marshaling and return value unmarshaling performed by a wrapper specified via manual graph construction
Doug Simon <doug.simon@oracle.com>
parents:
12653
diff
changeset
|
739 |
13753
80cd5c3b8827
partially fixed passing of object parameters to PTX kernels; use a C++ object for managing resource allocation and cleanup around a PTX kernel execution
Doug Simon <doug.simon@oracle.com>
parents:
13683
diff
changeset
|
740 jlong return_val; |
80cd5c3b8827
partially fixed passing of object parameters to PTX kernels; use a C++ object for managing resource allocation and cleanup around a PTX kernel execution
Doug Simon <doug.simon@oracle.com>
parents:
13683
diff
changeset
|
741 TRY(return_val = call.get_primitive_return_value()); |
80cd5c3b8827
partially fixed passing of object parameters to PTX kernels; use a C++ object for managing resource allocation and cleanup around a PTX kernel execution
Doug Simon <doug.simon@oracle.com>
parents:
13683
diff
changeset
|
742 return return_val; |
13624
220ed109bf77
initial code for calling PTX kernel code from Java with parameter marshaling and return value unmarshaling performed by a wrapper specified via manual graph construction
Doug Simon <doug.simon@oracle.com>
parents:
12653
diff
changeset
|
743 |
13753
80cd5c3b8827
partially fixed passing of object parameters to PTX kernels; use a C++ object for managing resource allocation and cleanup around a PTX kernel execution
Doug Simon <doug.simon@oracle.com>
parents:
13683
diff
changeset
|
744 #undef TRY |
13624
220ed109bf77
initial code for calling PTX kernel code from Java with parameter marshaling and return value unmarshaling performed by a wrapper specified via manual graph construction
Doug Simon <doug.simon@oracle.com>
parents:
12653
diff
changeset
|
745 |
220ed109bf77
initial code for calling PTX kernel code from Java with parameter marshaling and return value unmarshaling performed by a wrapper specified via manual graph construction
Doug Simon <doug.simon@oracle.com>
parents:
12653
diff
changeset
|
746 JRT_END |
220ed109bf77
initial code for calling PTX kernel code from Java with parameter marshaling and return value unmarshaling performed by a wrapper specified via manual graph construction
Doug Simon <doug.simon@oracle.com>
parents:
12653
diff
changeset
|
747 |
10879 | 748 #if defined(LINUX) |
13922
0995dcbd6dd8
Change CUDA context management to support multiple executions of a kernel. Exclude GPU offloading of lambdas from java.* library code.
S.Bharadwaj Yadavalli <bharadwaj.yadavalli@oracle.com>
parents:
13888
diff
changeset
|
749 static const char cuda_library_name[] = "/usr/lib/libcuda.so"; |
10879 | 750 #elif defined(__APPLE__) |
751 static char const cuda_library_name[] = "/usr/local/cuda/lib/libcuda.dylib"; | |
752 #else | |
753 static char const cuda_library_name[] = ""; | |
754 #endif | |
755 | |
13888
51584f76462d
pulled Ptx and Hsail classes out of gpu class namespace
Doug Simon <doug.simon@oracle.com>
parents:
13851
diff
changeset
|
756 bool Ptx::link() { |
13819
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13753
diff
changeset
|
757 if (cuda_library_name == NULL) { |
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13753
diff
changeset
|
758 if (TraceGPUInteraction) { |
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13753
diff
changeset
|
759 tty->print_cr("Failed to find CUDA linkage"); |
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13753
diff
changeset
|
760 } |
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13753
diff
changeset
|
761 return false; |
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13753
diff
changeset
|
762 } |
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13753
diff
changeset
|
763 char ebuf[O_BUFLEN]; |
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13753
diff
changeset
|
764 void *handle = os::dll_load(cuda_library_name, ebuf, O_BUFLEN); |
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13753
diff
changeset
|
765 if (handle == NULL) { |
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13753
diff
changeset
|
766 if (TraceGPUInteraction) { |
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13753
diff
changeset
|
767 tty->print_cr("Unsupported CUDA platform: %s", ebuf); |
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13753
diff
changeset
|
768 } |
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13753
diff
changeset
|
769 return false; |
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13753
diff
changeset
|
770 } |
10882
6a2d65cb5d7d
fix: gpu_ptx.cpp did not compile on windows
Christian Wirth <christian.wirth@oracle.com>
parents:
10879
diff
changeset
|
771 |
13819
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13753
diff
changeset
|
772 LOOKUP_CUDA_FUNCTION(cuInit, cuda_cu_init); |
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13753
diff
changeset
|
773 LOOKUP_CUDA_FUNCTION(cuCtxSynchronize, cuda_cu_ctx_synchronize); |
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13753
diff
changeset
|
774 LOOKUP_CUDA_FUNCTION(cuCtxGetCurrent, cuda_cu_ctx_get_current); |
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13753
diff
changeset
|
775 LOOKUP_CUDA_FUNCTION(cuCtxSetCurrent, cuda_cu_ctx_set_current); |
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13753
diff
changeset
|
776 LOOKUP_CUDA_FUNCTION(cuDeviceGetCount, cuda_cu_device_get_count); |
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13753
diff
changeset
|
777 LOOKUP_CUDA_FUNCTION(cuDeviceGetName, cuda_cu_device_get_name); |
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13753
diff
changeset
|
778 LOOKUP_CUDA_FUNCTION(cuDeviceGet, cuda_cu_device_get); |
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13753
diff
changeset
|
779 LOOKUP_CUDA_FUNCTION(cuDeviceComputeCapability, cuda_cu_device_compute_capability); |
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13753
diff
changeset
|
780 LOOKUP_CUDA_FUNCTION(cuDeviceGetAttribute, cuda_cu_device_get_attribute); |
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13753
diff
changeset
|
781 LOOKUP_CUDA_FUNCTION(cuModuleGetFunction, cuda_cu_module_get_function); |
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13753
diff
changeset
|
782 LOOKUP_CUDA_FUNCTION(cuModuleLoadDataEx, cuda_cu_module_load_data_ex); |
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13753
diff
changeset
|
783 LOOKUP_CUDA_FUNCTION(cuLaunchKernel, cuda_cu_launch_kernel); |
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13753
diff
changeset
|
784 LOOKUP_CUDA_FUNCTION(cuMemHostRegister, cuda_cu_mem_host_register); |
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13753
diff
changeset
|
785 LOOKUP_CUDA_FUNCTION(cuMemHostUnregister, cuda_cu_mem_host_unregister); |
12653
1a7e7011a341
* PTX kernel argument buffer now has naturally aligned arguments as required by PTX JIT compiler.
S.Bharadwaj Yadavalli <bharadwaj.yadavalli@oracle.com>
parents:
12519
diff
changeset
|
786 #if defined(__x86_64) || defined(AMD64) || defined(_M_AMD64) |
13819
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13753
diff
changeset
|
787 LOOKUP_CUDA_V2_FUNCTION(cuCtxCreate, cuda_cu_ctx_create); |
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13753
diff
changeset
|
788 LOOKUP_CUDA_V2_FUNCTION(cuCtxDestroy, cuda_cu_ctx_destroy); |
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13753
diff
changeset
|
789 LOOKUP_CUDA_V2_FUNCTION(cuMemAlloc, cuda_cu_memalloc); |
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13753
diff
changeset
|
790 LOOKUP_CUDA_V2_FUNCTION(cuMemFree, cuda_cu_memfree); |
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13753
diff
changeset
|
791 LOOKUP_CUDA_V2_FUNCTION(cuMemcpyHtoD, cuda_cu_memcpy_htod); |
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13753
diff
changeset
|
792 LOOKUP_CUDA_V2_FUNCTION(cuMemcpyDtoH, cuda_cu_memcpy_dtoh); |
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13753
diff
changeset
|
793 LOOKUP_CUDA_V2_FUNCTION(cuMemHostGetDevicePointer, cuda_cu_mem_host_get_device_pointer); |
12653
1a7e7011a341
* PTX kernel argument buffer now has naturally aligned arguments as required by PTX JIT compiler.
S.Bharadwaj Yadavalli <bharadwaj.yadavalli@oracle.com>
parents:
12519
diff
changeset
|
794 #else |
13819
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13753
diff
changeset
|
795 LOOKUP_CUDA_FUNCTION(cuCtxCreate, cuda_cu_ctx_create); |
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13753
diff
changeset
|
796 LOOKUP_CUDA_FUNCTION(cuCtxDestroy, cuda_cu_ctx_destroy); |
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13753
diff
changeset
|
797 LOOKUP_CUDA_FUNCTION(cuMemAlloc, cuda_cu_memalloc); |
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13753
diff
changeset
|
798 LOOKUP_CUDA_FUNCTION(cuMemFree, cuda_cu_memfree); |
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13753
diff
changeset
|
799 LOOKUP_CUDA_FUNCTION(cuMemcpyHtoD, cuda_cu_memcpy_htod); |
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13753
diff
changeset
|
800 LOOKUP_CUDA_FUNCTION(cuMemcpyDtoH, cuda_cu_memcpy_dtoh); |
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13753
diff
changeset
|
801 LOOKUP_CUDA_FUNCTION(cuMemHostGetDevicePointer, cuda_cu_mem_host_get_device_pointer); |
12653
1a7e7011a341
* PTX kernel argument buffer now has naturally aligned arguments as required by PTX JIT compiler.
S.Bharadwaj Yadavalli <bharadwaj.yadavalli@oracle.com>
parents:
12519
diff
changeset
|
802 #endif |
11485
49bb1bc983c6
Implement several missing PTX codegen features; return value capture and method args passing of java method executed on GPU.
bharadwaj
parents:
11284
diff
changeset
|
803 |
13819
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13753
diff
changeset
|
804 if (TraceGPUInteraction) { |
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13753
diff
changeset
|
805 tty->print_cr("[CUDA] Success: library linkage"); |
10879 | 806 } |
13819
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13753
diff
changeset
|
807 return true; |
10879 | 808 } |