Mercurial > hg > truffle
annotate src/gpu/ptx/vm/gpu_ptx.cpp @ 11486:5d5bfb75dae0
added metrics for total number of Nodes, LIRInstructions and CompositeValues created (GRAAL-448)
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Wed, 28 Aug 2013 22:34:22 +0200 |
parents | d876002b98e6 |
children | 49bb1bc983c6 |
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" |
10879 | 32 |
33 void * gpu::Ptx::_device_context; | |
34 | |
35 gpu::Ptx::cuda_cu_init_func_t gpu::Ptx::_cuda_cu_init; | |
36 gpu::Ptx::cuda_cu_ctx_create_func_t gpu::Ptx::_cuda_cu_ctx_create; | |
37 gpu::Ptx::cuda_cu_ctx_detach_func_t gpu::Ptx::_cuda_cu_ctx_detach; | |
38 gpu::Ptx::cuda_cu_ctx_synchronize_func_t gpu::Ptx::_cuda_cu_ctx_synchronize; | |
39 gpu::Ptx::cuda_cu_device_get_count_func_t gpu::Ptx::_cuda_cu_device_get_count; | |
40 gpu::Ptx::cuda_cu_device_get_name_func_t gpu::Ptx::_cuda_cu_device_get_name; | |
41 gpu::Ptx::cuda_cu_device_get_func_t gpu::Ptx::_cuda_cu_device_get; | |
42 gpu::Ptx::cuda_cu_device_compute_capability_func_t gpu::Ptx::_cuda_cu_device_compute_capability; | |
43 gpu::Ptx::cuda_cu_device_get_attribute_func_t gpu::Ptx::_cuda_cu_device_get_attribute; | |
44 gpu::Ptx::cuda_cu_launch_kernel_func_t gpu::Ptx::_cuda_cu_launch_kernel; | |
45 gpu::Ptx::cuda_cu_module_get_function_func_t gpu::Ptx::_cuda_cu_module_get_function; | |
46 gpu::Ptx::cuda_cu_module_load_data_ex_func_t gpu::Ptx::_cuda_cu_module_load_data_ex; | |
47 | |
48 void gpu::probe_linkage() { | |
49 #if defined(__APPLE__) || defined(LINUX) | |
50 set_gpu_linkage(gpu::Ptx::probe_linkage()); | |
51 #else | |
52 set_gpu_linkage(false); | |
53 #endif | |
54 } | |
55 | |
56 void gpu::initialize_gpu() { | |
57 if (gpu::has_gpu_linkage()) { | |
58 set_initialized(gpu::Ptx::initialize_gpu()); | |
59 } | |
60 } | |
61 | |
62 void * gpu::generate_kernel(unsigned char *code, int code_len, const char *name) { | |
63 if (gpu::has_gpu_linkage()) { | |
64 return (gpu::Ptx::generate_kernel(code, code_len, name)); | |
65 } else { | |
66 return NULL; | |
67 } | |
68 } | |
69 | |
11283
1cd1f8ff70a1
CR-20: PTX kernel invocation with arguments - from Bharadwaj
Morris Meyer <morris.meyer@oracle.com>
parents:
10884
diff
changeset
|
70 bool gpu::execute_kernel(address kernel, JavaCallArguments * jca) { |
10879 | 71 if (gpu::has_gpu_linkage()) { |
11283
1cd1f8ff70a1
CR-20: PTX kernel invocation with arguments - from Bharadwaj
Morris Meyer <morris.meyer@oracle.com>
parents:
10884
diff
changeset
|
72 return (gpu::Ptx::execute_kernel(kernel, jca)); |
10879 | 73 } else { |
74 return false; | |
75 } | |
76 } | |
77 | |
78 bool gpu::Ptx::initialize_gpu() { | |
79 | |
80 /* Initialize CUDA driver API */ | |
81 int status = _cuda_cu_init(0); | |
82 if (status != GRAAL_CUDA_SUCCESS) { | |
83 tty->print_cr("Failed to initialize CUDA device"); | |
84 return false; | |
85 } | |
86 | |
87 if (TraceGPUInteraction) { | |
88 tty->print_cr("CUDA driver initialization: Success"); | |
89 } | |
90 | |
91 /* Get the number of compute-capable device count */ | |
92 int device_count = 0; | |
93 status = _cuda_cu_device_get_count(&device_count); | |
94 if (status != GRAAL_CUDA_SUCCESS) { | |
95 tty->print_cr("[CUDA] Failed to get compute-capable device count"); | |
96 return false; | |
97 } | |
98 | |
99 if (device_count == 0) { | |
100 tty->print_cr("[CUDA] Found no device supporting CUDA"); | |
101 return false; | |
102 } | |
103 | |
104 if (TraceGPUInteraction) { | |
105 tty->print_cr("[CUDA] Number of compute-capable devices found: %d", device_count); | |
106 } | |
107 | |
108 /* Get the handle to the first compute device */ | |
109 int device_id = 0; | |
110 /* Compute-capable device handle */ | |
111 int cu_device = 0; | |
112 status = _cuda_cu_device_get(&cu_device, device_id); | |
113 | |
114 if (status != GRAAL_CUDA_SUCCESS) { | |
115 tty->print_cr("[CUDA] Failed to get handle of first compute-capable device i.e., the one at ordinal: %d", device_id); | |
116 return false; | |
117 } | |
118 | |
119 if (TraceGPUInteraction) { | |
120 tty->print_cr("[CUDA] Got the handle of first compute-device"); | |
121 } | |
122 | |
123 /* Get device attributes */ | |
11283
1cd1f8ff70a1
CR-20: PTX kernel invocation with arguments - from Bharadwaj
Morris Meyer <morris.meyer@oracle.com>
parents:
10884
diff
changeset
|
124 int minor, major, unified_addressing; |
10879 | 125 status = _cuda_cu_device_get_attribute(&minor, GRAAL_CU_DEVICE_ATTRIBUTE_COMPUTE_CAPABILITY_MINOR, cu_device); |
126 | |
127 if (status != GRAAL_CUDA_SUCCESS) { | |
128 tty->print_cr("[CUDA] Failed to get minor attribute of device: %d", cu_device); | |
129 return false; | |
130 } | |
131 | |
132 status = _cuda_cu_device_get_attribute(&major, GRAAL_CU_DEVICE_ATTRIBUTE_COMPUTE_CAPABILITY_MAJOR, cu_device); | |
133 | |
134 if (status != GRAAL_CUDA_SUCCESS) { | |
135 tty->print_cr("[CUDA] Failed to get major attribute of device: %d", cu_device); | |
136 return false; | |
137 } | |
138 | |
139 if (TraceGPUInteraction) { | |
140 tty->print_cr("[CUDA] Compatibility version of device %d: %d.%d", cu_device, major, minor); | |
141 } | |
142 | |
11283
1cd1f8ff70a1
CR-20: PTX kernel invocation with arguments - from Bharadwaj
Morris Meyer <morris.meyer@oracle.com>
parents:
10884
diff
changeset
|
143 status = _cuda_cu_device_get_attribute(&unified_addressing, GRAAL_CU_DEVICE_ATTRIBUTE_UNIFIED_ADDRESSING, cu_device); |
1cd1f8ff70a1
CR-20: PTX kernel invocation with arguments - from Bharadwaj
Morris Meyer <morris.meyer@oracle.com>
parents:
10884
diff
changeset
|
144 |
1cd1f8ff70a1
CR-20: PTX kernel invocation with arguments - from Bharadwaj
Morris Meyer <morris.meyer@oracle.com>
parents:
10884
diff
changeset
|
145 if (status != GRAAL_CUDA_SUCCESS) { |
1cd1f8ff70a1
CR-20: PTX kernel invocation with arguments - from Bharadwaj
Morris Meyer <morris.meyer@oracle.com>
parents:
10884
diff
changeset
|
146 tty->print_cr("[CUDA] Failed to query unified addressing mode of device: %d", cu_device); |
1cd1f8ff70a1
CR-20: PTX kernel invocation with arguments - from Bharadwaj
Morris Meyer <morris.meyer@oracle.com>
parents:
10884
diff
changeset
|
147 return false; |
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 |
1cd1f8ff70a1
CR-20: PTX kernel invocation with arguments - from Bharadwaj
Morris Meyer <morris.meyer@oracle.com>
parents:
10884
diff
changeset
|
150 if (TraceGPUInteraction) { |
1cd1f8ff70a1
CR-20: PTX kernel invocation with arguments - from Bharadwaj
Morris Meyer <morris.meyer@oracle.com>
parents:
10884
diff
changeset
|
151 tty->print_cr("[CUDA] Unified addressing support on device %d: %d", cu_device, unified_addressing); |
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 |
10879 | 155 /* Get device name */ |
156 char device_name[256]; | |
157 status = _cuda_cu_device_get_name(device_name, 256, cu_device); | |
158 | |
159 if (status != GRAAL_CUDA_SUCCESS) { | |
160 tty->print_cr("[CUDA] Failed to get name of device: %d", cu_device); | |
161 return false; | |
162 } | |
163 | |
164 if (TraceGPUInteraction) { | |
165 tty->print_cr("[CUDA] Using %s", device_name); | |
166 } | |
167 | |
168 /* Create CUDA context */ | |
169 status = _cuda_cu_ctx_create(&_device_context, 0, cu_device); | |
170 | |
171 if (status != GRAAL_CUDA_SUCCESS) { | |
172 tty->print_cr("[CUDA] Failed to create CUDA context for device: %d", cu_device); | |
173 return false; | |
174 } | |
175 | |
176 if (TraceGPUInteraction) { | |
177 tty->print_cr("[CUDA] Success: Created context for device: %d", cu_device); | |
178 } | |
179 | |
180 return true; | |
181 } | |
182 | |
183 void *gpu::Ptx::generate_kernel(unsigned char *code, int code_len, const char *name) { | |
184 | |
185 struct CUmod_st * cu_module; | |
186 // Use three JIT compiler options | |
187 const unsigned int jit_num_options = 3; | |
188 int *jit_options = NEW_C_HEAP_ARRAY(int, jit_num_options, mtCompiler); | |
189 void **jit_option_values = NEW_C_HEAP_ARRAY(void *, jit_num_options, mtCompiler); | |
190 | |
191 // Set up PTX JIT compiler options | |
192 // 1. set size of compilation log buffer | |
193 int jit_log_buffer_size = 1024; | |
194 jit_options[0] = GRAAL_CU_JIT_INFO_LOG_BUFFER_SIZE_BYTES; | |
195 jit_option_values[0] = (void *)(size_t)jit_log_buffer_size; | |
196 | |
197 // 2. set pointer to compilation log buffer | |
198 char *jit_log_buffer = NEW_C_HEAP_ARRAY(char, jit_log_buffer_size, mtCompiler); | |
199 jit_options[1] = GRAAL_CU_JIT_INFO_LOG_BUFFER; | |
200 jit_option_values[1] = jit_log_buffer; | |
201 | |
202 // 3. set pointer to set the Maximum # of registers (32) for the kernel | |
203 int jit_register_count = 32; | |
204 jit_options[2] = GRAAL_CU_JIT_MAX_REGISTERS; | |
205 jit_option_values[2] = (void *)(size_t)jit_register_count; | |
206 | |
207 if (TraceGPUInteraction) { | |
208 tty->print_cr("[CUDA] PTX Kernel\n%s", code); | |
209 tty->print_cr("[CUDA] Function name : %s", name); | |
210 | |
211 } | |
212 | |
213 /* Load module's data with compiler options */ | |
214 int status = _cuda_cu_module_load_data_ex(&cu_module, code, jit_num_options, | |
215 jit_options, (void **)jit_option_values); | |
216 if (status != GRAAL_CUDA_SUCCESS) { | |
217 if (status == GRAAL_CUDA_ERROR_NO_BINARY_FOR_GPU) { | |
218 tty->print_cr("[CUDA] Check for malformed PTX kernel or incorrect PTX compilation options"); | |
219 } | |
220 tty->print_cr("[CUDA] *** Error (%d) Failed to load module data with online compiler options for method %s", | |
221 status, name); | |
222 return NULL; | |
223 } | |
224 | |
225 if (TraceGPUInteraction) { | |
226 tty->print_cr("[CUDA] Loaded data for PTX Kernel"); | |
227 } | |
228 | |
229 struct CUfunc_st * cu_function; | |
230 | |
231 status = _cuda_cu_module_get_function(&cu_function, cu_module, name); | |
232 | |
233 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
|
234 tty->print_cr("[CUDA] *** Error: Failed to get function %s", name); |
10879 | 235 return NULL; |
236 } | |
237 | |
238 if (TraceGPUInteraction) { | |
239 tty->print_cr("[CUDA] Got function handle for %s", name); | |
240 } | |
241 return cu_function; | |
242 } | |
243 | |
11283
1cd1f8ff70a1
CR-20: PTX kernel invocation with arguments - from Bharadwaj
Morris Meyer <morris.meyer@oracle.com>
parents:
10884
diff
changeset
|
244 bool gpu::Ptx::execute_kernel(address kernel, JavaCallArguments * jca) { |
10879 | 245 // grid dimensionality |
246 unsigned int gridX = 1; | |
247 unsigned int gridY = 1; | |
248 unsigned int gridZ = 1; | |
249 | |
250 // thread dimensionality | |
251 unsigned int blockX = 1; | |
252 unsigned int blockY = 1; | |
253 unsigned int blockZ = 1; | |
254 | |
255 int *cu_function = (int *)kernel; | |
256 | |
11283
1cd1f8ff70a1
CR-20: PTX kernel invocation with arguments - from Bharadwaj
Morris Meyer <morris.meyer@oracle.com>
parents:
10884
diff
changeset
|
257 char * paramBuffer = (char *) jca->parameters(); |
1cd1f8ff70a1
CR-20: PTX kernel invocation with arguments - from Bharadwaj
Morris Meyer <morris.meyer@oracle.com>
parents:
10884
diff
changeset
|
258 size_t paramBufferSz = (size_t) jca->size_of_parameters(); |
1cd1f8ff70a1
CR-20: PTX kernel invocation with arguments - from Bharadwaj
Morris Meyer <morris.meyer@oracle.com>
parents:
10884
diff
changeset
|
259 |
1cd1f8ff70a1
CR-20: PTX kernel invocation with arguments - from Bharadwaj
Morris Meyer <morris.meyer@oracle.com>
parents:
10884
diff
changeset
|
260 void * config[] = { |
1cd1f8ff70a1
CR-20: PTX kernel invocation with arguments - from Bharadwaj
Morris Meyer <morris.meyer@oracle.com>
parents:
10884
diff
changeset
|
261 GRAAL_CU_LAUNCH_PARAM_BUFFER_POINTER, paramBuffer, |
1cd1f8ff70a1
CR-20: PTX kernel invocation with arguments - from Bharadwaj
Morris Meyer <morris.meyer@oracle.com>
parents:
10884
diff
changeset
|
262 GRAAL_CU_LAUNCH_PARAM_BUFFER_SIZE, ¶mBufferSz, |
1cd1f8ff70a1
CR-20: PTX kernel invocation with arguments - from Bharadwaj
Morris Meyer <morris.meyer@oracle.com>
parents:
10884
diff
changeset
|
263 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
|
264 }; |
1cd1f8ff70a1
CR-20: PTX kernel invocation with arguments - from Bharadwaj
Morris Meyer <morris.meyer@oracle.com>
parents:
10884
diff
changeset
|
265 |
10879 | 266 if (kernel == NULL) { |
267 return false; | |
268 } | |
269 | |
270 if (TraceGPUInteraction) { | |
271 tty->print_cr("[CUDA] launching kernel"); | |
272 } | |
273 int status = _cuda_cu_launch_kernel(cu_function, | |
274 gridX, gridY, gridZ, | |
275 blockX, blockY, blockZ, | |
11283
1cd1f8ff70a1
CR-20: PTX kernel invocation with arguments - from Bharadwaj
Morris Meyer <morris.meyer@oracle.com>
parents:
10884
diff
changeset
|
276 0, NULL, NULL, config); |
10879 | 277 if (status != GRAAL_CUDA_SUCCESS) { |
278 tty->print_cr("[CUDA] Failed to launch kernel"); | |
279 return false; | |
280 } | |
281 | |
282 if (TraceGPUInteraction) { | |
283 tty->print_cr("[CUDA] Success: Kernel Launch"); | |
284 } | |
285 return status == 0; // GRAAL_CUDA_SUCCESS | |
286 } | |
287 | |
288 #if defined(LINUX) | |
289 static const char cuda_library_name[] = "libcuda.so"; | |
290 #elif defined(__APPLE__) | |
291 static char const cuda_library_name[] = "/usr/local/cuda/lib/libcuda.dylib"; | |
292 #else | |
293 static char const cuda_library_name[] = ""; | |
294 #endif | |
295 | |
10882
6a2d65cb5d7d
fix: gpu_ptx.cpp did not compile on windows
Christian Wirth <christian.wirth@oracle.com>
parents:
10879
diff
changeset
|
296 #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
|
297 |
10879 | 298 bool gpu::Ptx::probe_linkage() { |
299 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
|
300 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
|
301 void *handle = os::dll_load(cuda_library_name, buffer, STD_BUFFER_SIZE); |
6a2d65cb5d7d
fix: gpu_ptx.cpp did not compile on windows
Christian Wirth <christian.wirth@oracle.com>
parents:
10879
diff
changeset
|
302 free(buffer); |
10879 | 303 if (handle != NULL) { |
304 _cuda_cu_init = | |
10882
6a2d65cb5d7d
fix: gpu_ptx.cpp did not compile on windows
Christian Wirth <christian.wirth@oracle.com>
parents:
10879
diff
changeset
|
305 CAST_TO_FN_PTR(cuda_cu_init_func_t, os::dll_lookup(handle, "cuInit")); |
10879 | 306 _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
|
307 CAST_TO_FN_PTR(cuda_cu_ctx_create_func_t, os::dll_lookup(handle, "cuCtxCreate")); |
10879 | 308 _cuda_cu_ctx_detach = |
10882
6a2d65cb5d7d
fix: gpu_ptx.cpp did not compile on windows
Christian Wirth <christian.wirth@oracle.com>
parents:
10879
diff
changeset
|
309 CAST_TO_FN_PTR(cuda_cu_ctx_detach_func_t, os::dll_lookup(handle, "cuCtxDetach")); |
10879 | 310 _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
|
311 CAST_TO_FN_PTR(cuda_cu_ctx_synchronize_func_t, os::dll_lookup(handle, "cuCtxSynchronize")); |
10879 | 312 _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
|
313 CAST_TO_FN_PTR(cuda_cu_device_get_count_func_t, os::dll_lookup(handle, "cuDeviceGetCount")); |
10879 | 314 _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
|
315 CAST_TO_FN_PTR(cuda_cu_device_get_name_func_t, os::dll_lookup(handle, "cuDeviceGetName")); |
10879 | 316 _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
|
317 CAST_TO_FN_PTR(cuda_cu_device_get_func_t, os::dll_lookup(handle, "cuDeviceGet")); |
10879 | 318 _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
|
319 CAST_TO_FN_PTR(cuda_cu_device_compute_capability_func_t, os::dll_lookup(handle, "cuDeviceComputeCapability")); |
10879 | 320 _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
|
321 CAST_TO_FN_PTR(cuda_cu_device_get_attribute_func_t, os::dll_lookup(handle, "cuDeviceGetAttribute")); |
10879 | 322 _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
|
323 CAST_TO_FN_PTR(cuda_cu_module_get_function_func_t, os::dll_lookup(handle, "cuModuleGetFunction")); |
10879 | 324 _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
|
325 CAST_TO_FN_PTR(cuda_cu_module_load_data_ex_func_t, os::dll_lookup(handle, "cuModuleLoadDataEx")); |
10879 | 326 _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
|
327 CAST_TO_FN_PTR(cuda_cu_launch_kernel_func_t, os::dll_lookup(handle, "cuLaunchKernel")); |
10879 | 328 if (TraceGPUInteraction) { |
329 tty->print_cr("[CUDA] Success: library linkage"); | |
330 } | |
331 return true; | |
332 } else { | |
333 // Unable to dlopen libcuda | |
334 return false; | |
335 } | |
336 } else { | |
337 tty->print_cr("Unsupported CUDA platform"); | |
338 return false; | |
339 } | |
340 tty->print_cr("Failed to find CUDA linkage"); | |
341 return false; | |
342 } | |
343 |