Mercurial > hg > truffle
annotate src/gpu/ptx/vm/gpu_ptx.cpp @ 11527:c99e65785936
Improvements to PTX codegen; allows more PTX tests that run on the device to pass.
author | bharadwaj |
---|---|
date | Wed, 04 Sep 2013 10:47:37 -0400 |
parents | 49bb1bc983c6 |
children | 91e5f927af63 |
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" |
28 #include "utilities/globalDefinitions.hpp" | |
29 #include "utilities/ostream.hpp" | |
10883
5fcb30bcb90a
Fix compilation without precompiled headers.
Roland Schatz <roland.schatz@oracle.com>
parents:
10882
diff
changeset
|
30 #include "memory/allocation.hpp" |
5fcb30bcb90a
Fix compilation without precompiled headers.
Roland Schatz <roland.schatz@oracle.com>
parents:
10882
diff
changeset
|
31 #include "memory/allocation.inline.hpp" |
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
|
32 #include "kernelArguments.hpp" |
10879 | 33 |
34 void * gpu::Ptx::_device_context; | |
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
|
35 int gpu::Ptx::_cu_device = 0; |
10879 | 36 |
37 gpu::Ptx::cuda_cu_init_func_t gpu::Ptx::_cuda_cu_init; | |
38 gpu::Ptx::cuda_cu_ctx_create_func_t gpu::Ptx::_cuda_cu_ctx_create; | |
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
|
39 gpu::Ptx::cuda_cu_ctx_destroy_func_t gpu::Ptx::_cuda_cu_ctx_destroy; |
10879 | 40 gpu::Ptx::cuda_cu_ctx_synchronize_func_t gpu::Ptx::_cuda_cu_ctx_synchronize; |
11527
c99e65785936
Improvements to PTX codegen; allows more PTX tests that run on the device to pass.
bharadwaj
parents:
11485
diff
changeset
|
41 gpu::Ptx::cuda_cu_ctx_set_current_func_t gpu::Ptx::_cuda_cu_ctx_set_current; |
10879 | 42 gpu::Ptx::cuda_cu_device_get_count_func_t gpu::Ptx::_cuda_cu_device_get_count; |
43 gpu::Ptx::cuda_cu_device_get_name_func_t gpu::Ptx::_cuda_cu_device_get_name; | |
44 gpu::Ptx::cuda_cu_device_get_func_t gpu::Ptx::_cuda_cu_device_get; | |
45 gpu::Ptx::cuda_cu_device_compute_capability_func_t gpu::Ptx::_cuda_cu_device_compute_capability; | |
46 gpu::Ptx::cuda_cu_device_get_attribute_func_t gpu::Ptx::_cuda_cu_device_get_attribute; | |
47 gpu::Ptx::cuda_cu_launch_kernel_func_t gpu::Ptx::_cuda_cu_launch_kernel; | |
48 gpu::Ptx::cuda_cu_module_get_function_func_t gpu::Ptx::_cuda_cu_module_get_function; | |
49 gpu::Ptx::cuda_cu_module_load_data_ex_func_t gpu::Ptx::_cuda_cu_module_load_data_ex; | |
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
|
50 gpu::Ptx::cuda_cu_memcpy_dtoh_func_t gpu::Ptx::_cuda_cu_memcpy_dtoh; |
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
|
51 gpu::Ptx::cuda_cu_memfree_func_t gpu::Ptx::_cuda_cu_memfree; |
10879 | 52 |
53 void gpu::probe_linkage() { | |
54 #if defined(__APPLE__) || defined(LINUX) | |
55 set_gpu_linkage(gpu::Ptx::probe_linkage()); | |
56 #else | |
57 set_gpu_linkage(false); | |
58 #endif | |
59 } | |
60 | |
61 void gpu::initialize_gpu() { | |
62 if (gpu::has_gpu_linkage()) { | |
63 set_initialized(gpu::Ptx::initialize_gpu()); | |
64 } | |
65 } | |
66 | |
67 void * gpu::generate_kernel(unsigned char *code, int code_len, const char *name) { | |
68 if (gpu::has_gpu_linkage()) { | |
69 return (gpu::Ptx::generate_kernel(code, code_len, name)); | |
70 } else { | |
71 return NULL; | |
72 } | |
73 } | |
74 | |
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
|
75 bool gpu::execute_kernel(address kernel, PTXKernelArguments & ptxka, JavaValue& ret) { |
10879 | 76 if (gpu::has_gpu_linkage()) { |
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
|
77 return (gpu::Ptx::execute_kernel(kernel, ptxka, ret)); |
10879 | 78 } else { |
79 return false; | |
80 } | |
81 } | |
82 | |
83 bool gpu::Ptx::initialize_gpu() { | |
84 | |
85 /* Initialize CUDA driver API */ | |
86 int status = _cuda_cu_init(0); | |
87 if (status != GRAAL_CUDA_SUCCESS) { | |
88 tty->print_cr("Failed to initialize CUDA device"); | |
89 return false; | |
90 } | |
11527
c99e65785936
Improvements to PTX codegen; allows more PTX tests that run on the device to pass.
bharadwaj
parents:
11485
diff
changeset
|
91 |
10879 | 92 if (TraceGPUInteraction) { |
93 tty->print_cr("CUDA driver initialization: Success"); | |
94 } | |
95 | |
96 /* Get the number of compute-capable device count */ | |
97 int device_count = 0; | |
98 status = _cuda_cu_device_get_count(&device_count); | |
99 if (status != GRAAL_CUDA_SUCCESS) { | |
100 tty->print_cr("[CUDA] Failed to get compute-capable device count"); | |
101 return false; | |
102 } | |
103 | |
104 if (device_count == 0) { | |
105 tty->print_cr("[CUDA] Found no device supporting CUDA"); | |
106 return false; | |
107 } | |
108 | |
109 if (TraceGPUInteraction) { | |
110 tty->print_cr("[CUDA] Number of compute-capable devices found: %d", device_count); | |
111 } | |
11527
c99e65785936
Improvements to PTX codegen; allows more PTX tests that run on the device to pass.
bharadwaj
parents:
11485
diff
changeset
|
112 |
10879 | 113 /* Get the handle to the first compute device */ |
114 int device_id = 0; | |
115 /* 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
|
116 status = _cuda_cu_device_get(&_cu_device, device_id); |
10879 | 117 |
118 if (status != GRAAL_CUDA_SUCCESS) { | |
119 tty->print_cr("[CUDA] Failed to get handle of first compute-capable device i.e., the one at ordinal: %d", device_id); | |
120 return false; | |
121 } | |
122 | |
123 if (TraceGPUInteraction) { | |
124 tty->print_cr("[CUDA] Got the handle of first compute-device"); | |
125 } | |
126 | |
127 /* Get device attributes */ | |
11283
1cd1f8ff70a1
CR-20: PTX kernel invocation with arguments - from Bharadwaj
Morris Meyer <morris.meyer@oracle.com>
parents:
10884
diff
changeset
|
128 int minor, major, unified_addressing; |
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
|
129 status = _cuda_cu_device_get_attribute(&minor, GRAAL_CU_DEVICE_ATTRIBUTE_COMPUTE_CAPABILITY_MINOR, _cu_device); |
10879 | 130 |
131 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
|
132 tty->print_cr("[CUDA] Failed to get minor attribute of device: %d", _cu_device); |
10879 | 133 return false; |
134 } | |
135 | |
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
|
136 status = _cuda_cu_device_get_attribute(&major, GRAAL_CU_DEVICE_ATTRIBUTE_COMPUTE_CAPABILITY_MAJOR, _cu_device); |
10879 | 137 |
138 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
|
139 tty->print_cr("[CUDA] Failed to get major attribute of device: %d", _cu_device); |
10879 | 140 return false; |
141 } | |
142 | |
143 if (TraceGPUInteraction) { | |
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
|
144 tty->print_cr("[CUDA] Compatibility version of device %d: %d.%d", _cu_device, major, minor); |
10879 | 145 } |
146 | |
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
|
147 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
|
148 |
1cd1f8ff70a1
CR-20: PTX kernel invocation with arguments - from Bharadwaj
Morris Meyer <morris.meyer@oracle.com>
parents:
10884
diff
changeset
|
149 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
|
150 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
|
151 return false; |
1cd1f8ff70a1
CR-20: PTX kernel invocation with arguments - from Bharadwaj
Morris Meyer <morris.meyer@oracle.com>
parents:
10884
diff
changeset
|
152 } |
1cd1f8ff70a1
CR-20: PTX kernel invocation with arguments - from Bharadwaj
Morris Meyer <morris.meyer@oracle.com>
parents:
10884
diff
changeset
|
153 |
1cd1f8ff70a1
CR-20: PTX kernel invocation with arguments - from Bharadwaj
Morris Meyer <morris.meyer@oracle.com>
parents:
10884
diff
changeset
|
154 if (TraceGPUInteraction) { |
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
|
155 tty->print_cr("[CUDA] Unified addressing support on device %d: %d", _cu_device, unified_addressing); |
11283
1cd1f8ff70a1
CR-20: PTX kernel invocation with arguments - from Bharadwaj
Morris Meyer <morris.meyer@oracle.com>
parents:
10884
diff
changeset
|
156 } |
1cd1f8ff70a1
CR-20: PTX kernel invocation with arguments - from Bharadwaj
Morris Meyer <morris.meyer@oracle.com>
parents:
10884
diff
changeset
|
157 |
1cd1f8ff70a1
CR-20: PTX kernel invocation with arguments - from Bharadwaj
Morris Meyer <morris.meyer@oracle.com>
parents:
10884
diff
changeset
|
158 |
10879 | 159 /* Get device name */ |
160 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
|
161 status = _cuda_cu_device_get_name(device_name, 256, _cu_device); |
10879 | 162 |
163 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
|
164 tty->print_cr("[CUDA] Failed to get name of device: %d", _cu_device); |
10879 | 165 return false; |
166 } | |
167 | |
168 if (TraceGPUInteraction) { | |
169 tty->print_cr("[CUDA] Using %s", device_name); | |
170 } | |
171 | |
172 return true; | |
173 } | |
174 | |
175 void *gpu::Ptx::generate_kernel(unsigned char *code, int code_len, const char *name) { | |
176 | |
177 struct CUmod_st * cu_module; | |
178 // Use three JIT compiler options | |
179 const unsigned int jit_num_options = 3; | |
180 int *jit_options = NEW_C_HEAP_ARRAY(int, jit_num_options, mtCompiler); | |
181 void **jit_option_values = NEW_C_HEAP_ARRAY(void *, jit_num_options, mtCompiler); | |
182 | |
183 // Set up PTX JIT compiler options | |
184 // 1. set size of compilation log buffer | |
185 int jit_log_buffer_size = 1024; | |
186 jit_options[0] = GRAAL_CU_JIT_INFO_LOG_BUFFER_SIZE_BYTES; | |
187 jit_option_values[0] = (void *)(size_t)jit_log_buffer_size; | |
188 | |
189 // 2. set pointer to compilation log buffer | |
190 char *jit_log_buffer = NEW_C_HEAP_ARRAY(char, jit_log_buffer_size, mtCompiler); | |
191 jit_options[1] = GRAAL_CU_JIT_INFO_LOG_BUFFER; | |
192 jit_option_values[1] = jit_log_buffer; | |
193 | |
194 // 3. set pointer to set the Maximum # of registers (32) for the kernel | |
195 int jit_register_count = 32; | |
196 jit_options[2] = GRAAL_CU_JIT_MAX_REGISTERS; | |
197 jit_option_values[2] = (void *)(size_t)jit_register_count; | |
198 | |
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
|
199 /* Create CUDA context to compile and execute the kernel */ |
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
|
200 int status = _cuda_cu_ctx_create(&_device_context, 0, _cu_device); |
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
|
201 |
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
|
202 if (status != GRAAL_CUDA_SUCCESS) { |
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
|
203 tty->print_cr("[CUDA] Failed to create CUDA context for device: %d", _cu_device); |
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
|
204 return NULL; |
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
|
205 } |
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
|
206 |
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
|
207 if (TraceGPUInteraction) { |
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
|
208 tty->print_cr("[CUDA] Success: Created context for device: %d", _cu_device); |
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
|
209 } |
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
|
210 |
11527
c99e65785936
Improvements to PTX codegen; allows more PTX tests that run on the device to pass.
bharadwaj
parents:
11485
diff
changeset
|
211 status = _cuda_cu_ctx_set_current(_device_context); |
c99e65785936
Improvements to PTX codegen; allows more PTX tests that run on the device to pass.
bharadwaj
parents:
11485
diff
changeset
|
212 |
c99e65785936
Improvements to PTX codegen; allows more PTX tests that run on the device to pass.
bharadwaj
parents:
11485
diff
changeset
|
213 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
|
214 tty->print_cr("[CUDA] Failed to 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
|
215 return NULL; |
c99e65785936
Improvements to PTX codegen; allows more PTX tests that run on the device to pass.
bharadwaj
parents:
11485
diff
changeset
|
216 } |
c99e65785936
Improvements to PTX codegen; allows more PTX tests that run on the device to pass.
bharadwaj
parents:
11485
diff
changeset
|
217 |
c99e65785936
Improvements to PTX codegen; allows more PTX tests that run on the device to pass.
bharadwaj
parents:
11485
diff
changeset
|
218 if (TraceGPUInteraction) { |
c99e65785936
Improvements to PTX codegen; allows more PTX tests that run on the device to pass.
bharadwaj
parents:
11485
diff
changeset
|
219 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
|
220 } |
c99e65785936
Improvements to PTX codegen; allows more PTX tests that run on the device to pass.
bharadwaj
parents:
11485
diff
changeset
|
221 |
c99e65785936
Improvements to PTX codegen; allows more PTX tests that run on the device to pass.
bharadwaj
parents:
11485
diff
changeset
|
222 if (TraceGPUInteraction) { |
c99e65785936
Improvements to PTX codegen; allows more PTX tests that run on the device to pass.
bharadwaj
parents:
11485
diff
changeset
|
223 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
|
224 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
|
225 |
c99e65785936
Improvements to PTX codegen; allows more PTX tests that run on the device to pass.
bharadwaj
parents:
11485
diff
changeset
|
226 } |
c99e65785936
Improvements to PTX codegen; allows more PTX tests that run on the device to pass.
bharadwaj
parents:
11485
diff
changeset
|
227 |
10879 | 228 /* 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
|
229 status = _cuda_cu_module_load_data_ex(&cu_module, (void*) code, jit_num_options, |
10879 | 230 jit_options, (void **)jit_option_values); |
231 if (status != GRAAL_CUDA_SUCCESS) { | |
232 if (status == GRAAL_CUDA_ERROR_NO_BINARY_FOR_GPU) { | |
233 tty->print_cr("[CUDA] Check for malformed PTX kernel or incorrect PTX compilation options"); | |
234 } | |
11527
c99e65785936
Improvements to PTX codegen; allows more PTX tests that run on the device to pass.
bharadwaj
parents:
11485
diff
changeset
|
235 tty->print_cr("[CUDA] *** Error (%d) Failed to load module data with online compiler options for method %s", |
10879 | 236 status, name); |
237 return NULL; | |
238 } | |
239 | |
240 if (TraceGPUInteraction) { | |
241 tty->print_cr("[CUDA] Loaded data for PTX Kernel"); | |
242 } | |
243 | |
244 struct CUfunc_st * cu_function; | |
245 | |
246 status = _cuda_cu_module_get_function(&cu_function, cu_module, name); | |
247 | |
248 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
|
249 tty->print_cr("[CUDA] *** Error: Failed to get function %s", name); |
10879 | 250 return NULL; |
251 } | |
252 | |
253 if (TraceGPUInteraction) { | |
254 tty->print_cr("[CUDA] Got function handle for %s", name); | |
255 } | |
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
|
256 |
10879 | 257 return cu_function; |
258 } | |
259 | |
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
|
260 bool gpu::Ptx::execute_kernel(address kernel, PTXKernelArguments &ptxka, JavaValue &ret) { |
10879 | 261 // grid dimensionality |
262 unsigned int gridX = 1; | |
263 unsigned int gridY = 1; | |
264 unsigned int gridZ = 1; | |
265 | |
266 // thread dimensionality | |
267 unsigned int blockX = 1; | |
268 unsigned int blockY = 1; | |
269 unsigned int blockZ = 1; | |
11527
c99e65785936
Improvements to PTX codegen; allows more PTX tests that run on the device to pass.
bharadwaj
parents:
11485
diff
changeset
|
270 |
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
|
271 struct CUfunc_st* cu_function = (struct CUfunc_st*) kernel; |
10879 | 272 |
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
|
273 void * config[5] = { |
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
|
274 GRAAL_CU_LAUNCH_PARAM_BUFFER_POINTER, ptxka._kernelArgBuffer, |
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
|
275 GRAAL_CU_LAUNCH_PARAM_BUFFER_SIZE, &(ptxka._bufferOffset), |
11283
1cd1f8ff70a1
CR-20: PTX kernel invocation with arguments - from Bharadwaj
Morris Meyer <morris.meyer@oracle.com>
parents:
10884
diff
changeset
|
276 GRAAL_CU_LAUNCH_PARAM_END |
1cd1f8ff70a1
CR-20: PTX kernel invocation with arguments - from Bharadwaj
Morris Meyer <morris.meyer@oracle.com>
parents:
10884
diff
changeset
|
277 }; |
1cd1f8ff70a1
CR-20: PTX kernel invocation with arguments - from Bharadwaj
Morris Meyer <morris.meyer@oracle.com>
parents:
10884
diff
changeset
|
278 |
10879 | 279 if (kernel == NULL) { |
280 return false; | |
281 } | |
282 | |
283 if (TraceGPUInteraction) { | |
284 tty->print_cr("[CUDA] launching kernel"); | |
285 } | |
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
|
286 |
10879 | 287 int status = _cuda_cu_launch_kernel(cu_function, |
288 gridX, gridY, gridZ, | |
289 blockX, blockY, blockZ, | |
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
|
290 0, NULL, NULL, (void **) &config); |
10879 | 291 if (status != GRAAL_CUDA_SUCCESS) { |
292 tty->print_cr("[CUDA] Failed to launch kernel"); | |
293 return false; | |
294 } | |
295 | |
296 if (TraceGPUInteraction) { | |
297 tty->print_cr("[CUDA] Success: Kernel Launch"); | |
298 } | |
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
|
299 |
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
|
300 status = _cuda_cu_ctx_synchronize(); |
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
|
301 |
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
|
302 if (status != GRAAL_CUDA_SUCCESS) { |
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
|
303 tty->print_cr("[CUDA] Failed to synchronize launched kernel (%d)", status); |
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
|
304 return false; |
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
|
305 } |
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
|
306 |
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
|
307 if (TraceGPUInteraction) { |
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
|
308 tty->print_cr("[CUDA] Success: Synchronized launch kernel"); |
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
|
309 } |
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
|
310 |
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
|
311 |
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
|
312 // Get the result. TODO: Move this code to get_return_oop() |
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
|
313 BasicType return_type = ptxka.get_ret_type(); |
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
|
314 switch (return_type) { |
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
|
315 case T_INT : |
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
|
316 { |
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
|
317 int return_val; |
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
|
318 status = gpu::Ptx::_cuda_cu_memcpy_dtoh(&return_val, ptxka._return_value_ptr, T_INT_BYTE_SIZE); |
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
|
319 if (status != GRAAL_CUDA_SUCCESS) { |
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
|
320 tty->print_cr("[CUDA] *** Error (%d) Failed to copy value to device argument", status); |
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
|
321 return false; |
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
|
322 } |
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
|
323 ret.set_jint(return_val); |
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
|
324 } |
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
|
325 break; |
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
|
326 case T_LONG : |
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
|
327 { |
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
|
328 long return_val; |
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
|
329 status = gpu::Ptx::_cuda_cu_memcpy_dtoh(&return_val, ptxka._return_value_ptr, T_LONG_BYTE_SIZE); |
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
|
330 if (status != GRAAL_CUDA_SUCCESS) { |
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
|
331 tty->print_cr("[CUDA] *** Error (%d) Failed to copy value to device argument", status); |
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
|
332 return false; |
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
|
333 } |
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
|
334 ret.set_jlong(return_val); |
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
|
335 } |
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
|
336 break; |
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
|
337 default: |
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
|
338 tty->print_cr("[CUDA] TODO *** Unhandled return type"); |
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
|
339 } |
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
|
340 |
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
|
341 |
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
|
342 // Free device memory allocated for result |
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
|
343 status = gpu::Ptx::_cuda_cu_memfree(ptxka._return_value_ptr); |
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
|
344 if (status != GRAAL_CUDA_SUCCESS) { |
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
|
345 tty->print_cr("[CUDA] *** Error (%d) Failed to free device memory of return value", status); |
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
|
346 return false; |
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
|
347 } |
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
|
348 |
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
|
349 if (TraceGPUInteraction) { |
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
|
350 tty->print_cr("[CUDA] Success: Freed device memory of return value"); |
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
|
351 } |
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
|
352 |
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
|
353 // Destroy context |
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
|
354 status = gpu::Ptx::_cuda_cu_ctx_destroy(_device_context); |
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
|
355 if (status != GRAAL_CUDA_SUCCESS) { |
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
|
356 tty->print_cr("[CUDA] *** Error (%d) Failed to destroy context", status); |
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
|
357 return false; |
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
|
358 } |
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
|
359 |
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
|
360 if (TraceGPUInteraction) { |
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
|
361 tty->print_cr("[CUDA] Success: Destroy context"); |
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
|
362 } |
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
|
363 |
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
|
364 return (status == GRAAL_CUDA_SUCCESS); |
10879 | 365 } |
366 | |
367 #if defined(LINUX) | |
368 static const char cuda_library_name[] = "libcuda.so"; | |
369 #elif defined(__APPLE__) | |
370 static char const cuda_library_name[] = "/usr/local/cuda/lib/libcuda.dylib"; | |
371 #else | |
372 static char const cuda_library_name[] = ""; | |
373 #endif | |
374 | |
10882
6a2d65cb5d7d
fix: gpu_ptx.cpp did not compile on windows
Christian Wirth <christian.wirth@oracle.com>
parents:
10879
diff
changeset
|
375 #define STD_BUFFER_SIZE 1024 |
6a2d65cb5d7d
fix: gpu_ptx.cpp did not compile on windows
Christian Wirth <christian.wirth@oracle.com>
parents:
10879
diff
changeset
|
376 |
10879 | 377 bool gpu::Ptx::probe_linkage() { |
378 if (cuda_library_name != NULL) { | |
10882
6a2d65cb5d7d
fix: gpu_ptx.cpp did not compile on windows
Christian Wirth <christian.wirth@oracle.com>
parents:
10879
diff
changeset
|
379 char *buffer = (char*)malloc(STD_BUFFER_SIZE); |
6a2d65cb5d7d
fix: gpu_ptx.cpp did not compile on windows
Christian Wirth <christian.wirth@oracle.com>
parents:
10879
diff
changeset
|
380 void *handle = os::dll_load(cuda_library_name, buffer, STD_BUFFER_SIZE); |
11527
c99e65785936
Improvements to PTX codegen; allows more PTX tests that run on the device to pass.
bharadwaj
parents:
11485
diff
changeset
|
381 free(buffer); |
10879 | 382 if (handle != NULL) { |
383 _cuda_cu_init = | |
10882
6a2d65cb5d7d
fix: gpu_ptx.cpp did not compile on windows
Christian Wirth <christian.wirth@oracle.com>
parents:
10879
diff
changeset
|
384 CAST_TO_FN_PTR(cuda_cu_init_func_t, os::dll_lookup(handle, "cuInit")); |
10879 | 385 _cuda_cu_ctx_create = |
10882
6a2d65cb5d7d
fix: gpu_ptx.cpp did not compile on windows
Christian Wirth <christian.wirth@oracle.com>
parents:
10879
diff
changeset
|
386 CAST_TO_FN_PTR(cuda_cu_ctx_create_func_t, os::dll_lookup(handle, "cuCtxCreate")); |
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
|
387 _cuda_cu_ctx_destroy = |
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
|
388 CAST_TO_FN_PTR(cuda_cu_ctx_destroy_func_t, os::dll_lookup(handle, "cuCtxDestroy")); |
10879 | 389 _cuda_cu_ctx_synchronize = |
10882
6a2d65cb5d7d
fix: gpu_ptx.cpp did not compile on windows
Christian Wirth <christian.wirth@oracle.com>
parents:
10879
diff
changeset
|
390 CAST_TO_FN_PTR(cuda_cu_ctx_synchronize_func_t, os::dll_lookup(handle, "cuCtxSynchronize")); |
11527
c99e65785936
Improvements to PTX codegen; allows more PTX tests that run on the device to pass.
bharadwaj
parents:
11485
diff
changeset
|
391 _cuda_cu_ctx_set_current = |
c99e65785936
Improvements to PTX codegen; allows more PTX tests that run on the device to pass.
bharadwaj
parents:
11485
diff
changeset
|
392 CAST_TO_FN_PTR(cuda_cu_ctx_set_current_func_t, os::dll_lookup(handle, "cuCtxSetCurrent")); |
10879 | 393 _cuda_cu_device_get_count = |
10882
6a2d65cb5d7d
fix: gpu_ptx.cpp did not compile on windows
Christian Wirth <christian.wirth@oracle.com>
parents:
10879
diff
changeset
|
394 CAST_TO_FN_PTR(cuda_cu_device_get_count_func_t, os::dll_lookup(handle, "cuDeviceGetCount")); |
10879 | 395 _cuda_cu_device_get_name = |
10882
6a2d65cb5d7d
fix: gpu_ptx.cpp did not compile on windows
Christian Wirth <christian.wirth@oracle.com>
parents:
10879
diff
changeset
|
396 CAST_TO_FN_PTR(cuda_cu_device_get_name_func_t, os::dll_lookup(handle, "cuDeviceGetName")); |
10879 | 397 _cuda_cu_device_get = |
10882
6a2d65cb5d7d
fix: gpu_ptx.cpp did not compile on windows
Christian Wirth <christian.wirth@oracle.com>
parents:
10879
diff
changeset
|
398 CAST_TO_FN_PTR(cuda_cu_device_get_func_t, os::dll_lookup(handle, "cuDeviceGet")); |
10879 | 399 _cuda_cu_device_compute_capability = |
10882
6a2d65cb5d7d
fix: gpu_ptx.cpp did not compile on windows
Christian Wirth <christian.wirth@oracle.com>
parents:
10879
diff
changeset
|
400 CAST_TO_FN_PTR(cuda_cu_device_compute_capability_func_t, os::dll_lookup(handle, "cuDeviceComputeCapability")); |
10879 | 401 _cuda_cu_device_get_attribute = |
10882
6a2d65cb5d7d
fix: gpu_ptx.cpp did not compile on windows
Christian Wirth <christian.wirth@oracle.com>
parents:
10879
diff
changeset
|
402 CAST_TO_FN_PTR(cuda_cu_device_get_attribute_func_t, os::dll_lookup(handle, "cuDeviceGetAttribute")); |
10879 | 403 _cuda_cu_module_get_function = |
10882
6a2d65cb5d7d
fix: gpu_ptx.cpp did not compile on windows
Christian Wirth <christian.wirth@oracle.com>
parents:
10879
diff
changeset
|
404 CAST_TO_FN_PTR(cuda_cu_module_get_function_func_t, os::dll_lookup(handle, "cuModuleGetFunction")); |
10879 | 405 _cuda_cu_module_load_data_ex = |
10882
6a2d65cb5d7d
fix: gpu_ptx.cpp did not compile on windows
Christian Wirth <christian.wirth@oracle.com>
parents:
10879
diff
changeset
|
406 CAST_TO_FN_PTR(cuda_cu_module_load_data_ex_func_t, os::dll_lookup(handle, "cuModuleLoadDataEx")); |
10879 | 407 _cuda_cu_launch_kernel = |
10882
6a2d65cb5d7d
fix: gpu_ptx.cpp did not compile on windows
Christian Wirth <christian.wirth@oracle.com>
parents:
10879
diff
changeset
|
408 CAST_TO_FN_PTR(cuda_cu_launch_kernel_func_t, os::dll_lookup(handle, "cuLaunchKernel")); |
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
|
409 _cuda_cu_memalloc = |
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
|
410 CAST_TO_FN_PTR(cuda_cu_memalloc_func_t, os::dll_lookup(handle, "cuMemAlloc")); |
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
|
411 _cuda_cu_memfree = |
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
|
412 CAST_TO_FN_PTR(cuda_cu_memfree_func_t, os::dll_lookup(handle, "cuMemFree")); |
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
|
413 _cuda_cu_memcpy_htod = |
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
|
414 CAST_TO_FN_PTR(cuda_cu_memcpy_htod_func_t, os::dll_lookup(handle, "cuMemcpyHtoD")); |
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
|
415 _cuda_cu_memcpy_dtoh = |
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
|
416 CAST_TO_FN_PTR(cuda_cu_memcpy_dtoh_func_t, os::dll_lookup(handle, "cuMemcpyDtoH")); |
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
|
417 |
10879 | 418 if (TraceGPUInteraction) { |
419 tty->print_cr("[CUDA] Success: library linkage"); | |
420 } | |
421 return true; | |
422 } else { | |
423 // Unable to dlopen libcuda | |
424 return false; | |
425 } | |
426 } else { | |
427 tty->print_cr("Unsupported CUDA platform"); | |
428 return false; | |
429 } | |
430 tty->print_cr("Failed to find CUDA linkage"); | |
431 return false; | |
432 } |