Mercurial > hg > graal-jvmci-8
annotate src/gpu/ptx/vm/ptxKernelArguments.cpp @ 11902:67a1e27a8dbb
PTX initial float and double
author | Morris Meyer <morris.meyer@oracle.com> |
---|---|
date | Sun, 06 Oct 2013 22:07:23 -0400 |
parents | 61767ccd4600 |
children | cfba4fd3d616 |
rev | line source |
---|---|
11485
49bb1bc983c6
Implement several missing PTX codegen features; return value capture and method args passing of java method executed on GPU.
bharadwaj
parents:
diff
changeset
|
1 /* |
49bb1bc983c6
Implement several missing PTX codegen features; return value capture and method args passing of java method executed on GPU.
bharadwaj
parents:
diff
changeset
|
2 * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. |
49bb1bc983c6
Implement several missing PTX codegen features; return value capture and method args passing of java method executed on GPU.
bharadwaj
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
49bb1bc983c6
Implement several missing PTX codegen features; return value capture and method args passing of java method executed on GPU.
bharadwaj
parents:
diff
changeset
|
4 * |
49bb1bc983c6
Implement several missing PTX codegen features; return value capture and method args passing of java method executed on GPU.
bharadwaj
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
49bb1bc983c6
Implement several missing PTX codegen features; return value capture and method args passing of java method executed on GPU.
bharadwaj
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
49bb1bc983c6
Implement several missing PTX codegen features; return value capture and method args passing of java method executed on GPU.
bharadwaj
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
49bb1bc983c6
Implement several missing PTX codegen features; return value capture and method args passing of java method executed on GPU.
bharadwaj
parents:
diff
changeset
|
8 * |
49bb1bc983c6
Implement several missing PTX codegen features; return value capture and method args passing of java method executed on GPU.
bharadwaj
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
49bb1bc983c6
Implement several missing PTX codegen features; return value capture and method args passing of java method executed on GPU.
bharadwaj
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
49bb1bc983c6
Implement several missing PTX codegen features; return value capture and method args passing of java method executed on GPU.
bharadwaj
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
49bb1bc983c6
Implement several missing PTX codegen features; return value capture and method args passing of java method executed on GPU.
bharadwaj
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
49bb1bc983c6
Implement several missing PTX codegen features; return value capture and method args passing of java method executed on GPU.
bharadwaj
parents:
diff
changeset
|
13 * accompanied this code). |
49bb1bc983c6
Implement several missing PTX codegen features; return value capture and method args passing of java method executed on GPU.
bharadwaj
parents:
diff
changeset
|
14 * |
49bb1bc983c6
Implement several missing PTX codegen features; return value capture and method args passing of java method executed on GPU.
bharadwaj
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
49bb1bc983c6
Implement several missing PTX codegen features; return value capture and method args passing of java method executed on GPU.
bharadwaj
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
49bb1bc983c6
Implement several missing PTX codegen features; return value capture and method args passing of java method executed on GPU.
bharadwaj
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
49bb1bc983c6
Implement several missing PTX codegen features; return value capture and method args passing of java method executed on GPU.
bharadwaj
parents:
diff
changeset
|
18 * |
49bb1bc983c6
Implement several missing PTX codegen features; return value capture and method args passing of java method executed on GPU.
bharadwaj
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
49bb1bc983c6
Implement several missing PTX codegen features; return value capture and method args passing of java method executed on GPU.
bharadwaj
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
49bb1bc983c6
Implement several missing PTX codegen features; return value capture and method args passing of java method executed on GPU.
bharadwaj
parents:
diff
changeset
|
21 * questions. |
49bb1bc983c6
Implement several missing PTX codegen features; return value capture and method args passing of java method executed on GPU.
bharadwaj
parents:
diff
changeset
|
22 * |
49bb1bc983c6
Implement several missing PTX codegen features; return value capture and method args passing of java method executed on GPU.
bharadwaj
parents:
diff
changeset
|
23 */ |
49bb1bc983c6
Implement several missing PTX codegen features; return value capture and method args passing of java method executed on GPU.
bharadwaj
parents:
diff
changeset
|
24 |
49bb1bc983c6
Implement several missing PTX codegen features; return value capture and method args passing of java method executed on GPU.
bharadwaj
parents:
diff
changeset
|
25 #include "precompiled.hpp" |
11596
91e5f927af63
Initial implementation of PTXRuntime (RegisterConfig, PTX description etc); guarded with new flag UseGPU. Specify -XX:+UseGPU to exercise this new implementation.
bharadwaj
parents:
11485
diff
changeset
|
26 #include "ptxKernelArguments.hpp" |
11485
49bb1bc983c6
Implement several missing PTX codegen features; return value capture and method args passing of java method executed on GPU.
bharadwaj
parents:
diff
changeset
|
27 #include "runtime/javaCalls.hpp" |
49bb1bc983c6
Implement several missing PTX codegen features; return value capture and method args passing of java method executed on GPU.
bharadwaj
parents:
diff
changeset
|
28 |
49bb1bc983c6
Implement several missing PTX codegen features; return value capture and method args passing of java method executed on GPU.
bharadwaj
parents:
diff
changeset
|
29 gpu::Ptx::cuda_cu_memalloc_func_t gpu::Ptx::_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:
diff
changeset
|
30 gpu::Ptx::cuda_cu_memcpy_htod_func_t gpu::Ptx::_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:
diff
changeset
|
31 |
49bb1bc983c6
Implement several missing PTX codegen features; return value capture and method args passing of java method executed on GPU.
bharadwaj
parents:
diff
changeset
|
32 // Get next java argument |
49bb1bc983c6
Implement several missing PTX codegen features; return value capture and method args passing of java method executed on GPU.
bharadwaj
parents:
diff
changeset
|
33 oop PTXKernelArguments::next_arg(BasicType expectedType) { |
49bb1bc983c6
Implement several missing PTX codegen features; return value capture and method args passing of java method executed on GPU.
bharadwaj
parents:
diff
changeset
|
34 assert(_index < _args->length(), "out of bounds"); |
11821
d8659ad83fcc
PTX single-threaded array store, Warp annotation
Morris Meyer <morris.meyer@oracle.com>
parents:
11596
diff
changeset
|
35 |
d8659ad83fcc
PTX single-threaded array store, Warp annotation
Morris Meyer <morris.meyer@oracle.com>
parents:
11596
diff
changeset
|
36 oop arg = ((objArrayOop) (_args))->obj_at(_index++); |
d8659ad83fcc
PTX single-threaded array store, Warp annotation
Morris Meyer <morris.meyer@oracle.com>
parents:
11596
diff
changeset
|
37 assert(expectedType == T_OBJECT || |
d8659ad83fcc
PTX single-threaded array store, Warp annotation
Morris Meyer <morris.meyer@oracle.com>
parents:
11596
diff
changeset
|
38 java_lang_boxing_object::is_instance(arg, expectedType), "arg type mismatch"); |
d8659ad83fcc
PTX single-threaded array store, Warp annotation
Morris Meyer <morris.meyer@oracle.com>
parents:
11596
diff
changeset
|
39 |
11485
49bb1bc983c6
Implement several missing PTX codegen features; return value capture and method args passing of java method executed on GPU.
bharadwaj
parents:
diff
changeset
|
40 return arg; |
49bb1bc983c6
Implement several missing PTX codegen features; return value capture and method args passing of java method executed on GPU.
bharadwaj
parents:
diff
changeset
|
41 } |
49bb1bc983c6
Implement several missing PTX codegen features; return value capture and method args passing of java method executed on GPU.
bharadwaj
parents:
diff
changeset
|
42 |
11821
d8659ad83fcc
PTX single-threaded array store, Warp annotation
Morris Meyer <morris.meyer@oracle.com>
parents:
11596
diff
changeset
|
43 void PTXKernelArguments::do_int() { |
11894
c7abc8411011
Fixed BasicPTXTest and IntegerPTXTest
Morris Meyer <morris.meyer@oracle.com>
parents:
11821
diff
changeset
|
44 if (is_after_invocation()) { |
c7abc8411011
Fixed BasicPTXTest and IntegerPTXTest
Morris Meyer <morris.meyer@oracle.com>
parents:
11821
diff
changeset
|
45 return; |
c7abc8411011
Fixed BasicPTXTest and IntegerPTXTest
Morris Meyer <morris.meyer@oracle.com>
parents:
11821
diff
changeset
|
46 } |
c7abc8411011
Fixed BasicPTXTest and IntegerPTXTest
Morris Meyer <morris.meyer@oracle.com>
parents:
11821
diff
changeset
|
47 // If the parameter is a return value, |
c7abc8411011
Fixed BasicPTXTest and IntegerPTXTest
Morris Meyer <morris.meyer@oracle.com>
parents:
11821
diff
changeset
|
48 if (is_return_type()) { |
c7abc8411011
Fixed BasicPTXTest and IntegerPTXTest
Morris Meyer <morris.meyer@oracle.com>
parents:
11821
diff
changeset
|
49 // Allocate device memory for T_INT return value pointer on device. Size in bytes |
c7abc8411011
Fixed BasicPTXTest and IntegerPTXTest
Morris Meyer <morris.meyer@oracle.com>
parents:
11821
diff
changeset
|
50 int status = gpu::Ptx::_cuda_cu_memalloc(&_return_value_ptr, T_INT_BYTE_SIZE); |
c7abc8411011
Fixed BasicPTXTest and IntegerPTXTest
Morris Meyer <morris.meyer@oracle.com>
parents:
11821
diff
changeset
|
51 if (status != GRAAL_CUDA_SUCCESS) { |
c7abc8411011
Fixed BasicPTXTest and IntegerPTXTest
Morris Meyer <morris.meyer@oracle.com>
parents:
11821
diff
changeset
|
52 tty->print_cr("[CUDA] *** Error (%d) Failed to allocate memory for return value pointer on device", status); |
c7abc8411011
Fixed BasicPTXTest and IntegerPTXTest
Morris Meyer <morris.meyer@oracle.com>
parents:
11821
diff
changeset
|
53 _success = false; |
c7abc8411011
Fixed BasicPTXTest and IntegerPTXTest
Morris Meyer <morris.meyer@oracle.com>
parents:
11821
diff
changeset
|
54 return; |
c7abc8411011
Fixed BasicPTXTest and IntegerPTXTest
Morris Meyer <morris.meyer@oracle.com>
parents:
11821
diff
changeset
|
55 } |
c7abc8411011
Fixed BasicPTXTest and IntegerPTXTest
Morris Meyer <morris.meyer@oracle.com>
parents:
11821
diff
changeset
|
56 // Push _return_value_ptr to _kernelBuffer |
c7abc8411011
Fixed BasicPTXTest and IntegerPTXTest
Morris Meyer <morris.meyer@oracle.com>
parents:
11821
diff
changeset
|
57 *((gpu::Ptx::CUdeviceptr*) &_kernelArgBuffer[_bufferOffset]) = _return_value_ptr; |
c7abc8411011
Fixed BasicPTXTest and IntegerPTXTest
Morris Meyer <morris.meyer@oracle.com>
parents:
11821
diff
changeset
|
58 _bufferOffset += sizeof(_return_value_ptr); |
c7abc8411011
Fixed BasicPTXTest and IntegerPTXTest
Morris Meyer <morris.meyer@oracle.com>
parents:
11821
diff
changeset
|
59 } else { |
c7abc8411011
Fixed BasicPTXTest and IntegerPTXTest
Morris Meyer <morris.meyer@oracle.com>
parents:
11821
diff
changeset
|
60 // Get the next java argument and its value which should be a T_INT |
c7abc8411011
Fixed BasicPTXTest and IntegerPTXTest
Morris Meyer <morris.meyer@oracle.com>
parents:
11821
diff
changeset
|
61 oop arg = next_arg(T_INT); |
c7abc8411011
Fixed BasicPTXTest and IntegerPTXTest
Morris Meyer <morris.meyer@oracle.com>
parents:
11821
diff
changeset
|
62 // Copy the java argument value to kernelArgBuffer |
c7abc8411011
Fixed BasicPTXTest and IntegerPTXTest
Morris Meyer <morris.meyer@oracle.com>
parents:
11821
diff
changeset
|
63 jvalue intval; |
c7abc8411011
Fixed BasicPTXTest and IntegerPTXTest
Morris Meyer <morris.meyer@oracle.com>
parents:
11821
diff
changeset
|
64 if (java_lang_boxing_object::get_value(arg, &intval) != T_INT) { |
c7abc8411011
Fixed BasicPTXTest and IntegerPTXTest
Morris Meyer <morris.meyer@oracle.com>
parents:
11821
diff
changeset
|
65 tty->print_cr("[CUDA] *** Error: Unexpected argument type; expecting T_INT"); |
c7abc8411011
Fixed BasicPTXTest and IntegerPTXTest
Morris Meyer <morris.meyer@oracle.com>
parents:
11821
diff
changeset
|
66 _success = false; |
c7abc8411011
Fixed BasicPTXTest and IntegerPTXTest
Morris Meyer <morris.meyer@oracle.com>
parents:
11821
diff
changeset
|
67 return; |
c7abc8411011
Fixed BasicPTXTest and IntegerPTXTest
Morris Meyer <morris.meyer@oracle.com>
parents:
11821
diff
changeset
|
68 } |
c7abc8411011
Fixed BasicPTXTest and IntegerPTXTest
Morris Meyer <morris.meyer@oracle.com>
parents:
11821
diff
changeset
|
69 *((gpu::Ptx::CUdeviceptr*) &_kernelArgBuffer[_bufferOffset]) = intval.i; |
c7abc8411011
Fixed BasicPTXTest and IntegerPTXTest
Morris Meyer <morris.meyer@oracle.com>
parents:
11821
diff
changeset
|
70 _bufferOffset += sizeof(intval.i); |
11485
49bb1bc983c6
Implement several missing PTX codegen features; return value capture and method args passing of java method executed on GPU.
bharadwaj
parents:
diff
changeset
|
71 } |
11894
c7abc8411011
Fixed BasicPTXTest and IntegerPTXTest
Morris Meyer <morris.meyer@oracle.com>
parents:
11821
diff
changeset
|
72 return; |
c7abc8411011
Fixed BasicPTXTest and IntegerPTXTest
Morris Meyer <morris.meyer@oracle.com>
parents:
11821
diff
changeset
|
73 } |
c7abc8411011
Fixed BasicPTXTest and IntegerPTXTest
Morris Meyer <morris.meyer@oracle.com>
parents:
11821
diff
changeset
|
74 |
c7abc8411011
Fixed BasicPTXTest and IntegerPTXTest
Morris Meyer <morris.meyer@oracle.com>
parents:
11821
diff
changeset
|
75 void PTXKernelArguments::do_float() { |
c7abc8411011
Fixed BasicPTXTest and IntegerPTXTest
Morris Meyer <morris.meyer@oracle.com>
parents:
11821
diff
changeset
|
76 if (is_after_invocation()) { |
c7abc8411011
Fixed BasicPTXTest and IntegerPTXTest
Morris Meyer <morris.meyer@oracle.com>
parents:
11821
diff
changeset
|
77 return; |
11485
49bb1bc983c6
Implement several missing PTX codegen features; return value capture and method args passing of java method executed on GPU.
bharadwaj
parents:
diff
changeset
|
78 } |
11894
c7abc8411011
Fixed BasicPTXTest and IntegerPTXTest
Morris Meyer <morris.meyer@oracle.com>
parents:
11821
diff
changeset
|
79 // If the parameter is a return value, |
c7abc8411011
Fixed BasicPTXTest and IntegerPTXTest
Morris Meyer <morris.meyer@oracle.com>
parents:
11821
diff
changeset
|
80 if (is_return_type()) { |
c7abc8411011
Fixed BasicPTXTest and IntegerPTXTest
Morris Meyer <morris.meyer@oracle.com>
parents:
11821
diff
changeset
|
81 // Allocate device memory for T_INT return value pointer on device. Size in bytes |
c7abc8411011
Fixed BasicPTXTest and IntegerPTXTest
Morris Meyer <morris.meyer@oracle.com>
parents:
11821
diff
changeset
|
82 int status = gpu::Ptx::_cuda_cu_memalloc(&_return_value_ptr, T_FLOAT_BYTE_SIZE); |
c7abc8411011
Fixed BasicPTXTest and IntegerPTXTest
Morris Meyer <morris.meyer@oracle.com>
parents:
11821
diff
changeset
|
83 if (status != GRAAL_CUDA_SUCCESS) { |
c7abc8411011
Fixed BasicPTXTest and IntegerPTXTest
Morris Meyer <morris.meyer@oracle.com>
parents:
11821
diff
changeset
|
84 tty->print_cr("[CUDA] *** Error (%d) Failed to allocate memory for return value pointer on device", status); |
c7abc8411011
Fixed BasicPTXTest and IntegerPTXTest
Morris Meyer <morris.meyer@oracle.com>
parents:
11821
diff
changeset
|
85 _success = false; |
c7abc8411011
Fixed BasicPTXTest and IntegerPTXTest
Morris Meyer <morris.meyer@oracle.com>
parents:
11821
diff
changeset
|
86 return; |
c7abc8411011
Fixed BasicPTXTest and IntegerPTXTest
Morris Meyer <morris.meyer@oracle.com>
parents:
11821
diff
changeset
|
87 } |
c7abc8411011
Fixed BasicPTXTest and IntegerPTXTest
Morris Meyer <morris.meyer@oracle.com>
parents:
11821
diff
changeset
|
88 // Push _return_value_ptr to _kernelBuffer |
c7abc8411011
Fixed BasicPTXTest and IntegerPTXTest
Morris Meyer <morris.meyer@oracle.com>
parents:
11821
diff
changeset
|
89 *((gpu::Ptx::CUdeviceptr*) &_kernelArgBuffer[_bufferOffset]) = _return_value_ptr; |
c7abc8411011
Fixed BasicPTXTest and IntegerPTXTest
Morris Meyer <morris.meyer@oracle.com>
parents:
11821
diff
changeset
|
90 _bufferOffset += sizeof(_return_value_ptr); |
c7abc8411011
Fixed BasicPTXTest and IntegerPTXTest
Morris Meyer <morris.meyer@oracle.com>
parents:
11821
diff
changeset
|
91 } else { |
c7abc8411011
Fixed BasicPTXTest and IntegerPTXTest
Morris Meyer <morris.meyer@oracle.com>
parents:
11821
diff
changeset
|
92 // Get the next java argument and its value which should be a T_INT |
c7abc8411011
Fixed BasicPTXTest and IntegerPTXTest
Morris Meyer <morris.meyer@oracle.com>
parents:
11821
diff
changeset
|
93 oop arg = next_arg(T_FLOAT); |
c7abc8411011
Fixed BasicPTXTest and IntegerPTXTest
Morris Meyer <morris.meyer@oracle.com>
parents:
11821
diff
changeset
|
94 // Copy the java argument value to kernelArgBuffer |
c7abc8411011
Fixed BasicPTXTest and IntegerPTXTest
Morris Meyer <morris.meyer@oracle.com>
parents:
11821
diff
changeset
|
95 jvalue floatval; |
c7abc8411011
Fixed BasicPTXTest and IntegerPTXTest
Morris Meyer <morris.meyer@oracle.com>
parents:
11821
diff
changeset
|
96 if (java_lang_boxing_object::get_value(arg, &floatval) != T_FLOAT) { |
c7abc8411011
Fixed BasicPTXTest and IntegerPTXTest
Morris Meyer <morris.meyer@oracle.com>
parents:
11821
diff
changeset
|
97 tty->print_cr("[CUDA] *** Error: Unexpected argument type; expecting T_INT"); |
c7abc8411011
Fixed BasicPTXTest and IntegerPTXTest
Morris Meyer <morris.meyer@oracle.com>
parents:
11821
diff
changeset
|
98 _success = false; |
c7abc8411011
Fixed BasicPTXTest and IntegerPTXTest
Morris Meyer <morris.meyer@oracle.com>
parents:
11821
diff
changeset
|
99 return; |
c7abc8411011
Fixed BasicPTXTest and IntegerPTXTest
Morris Meyer <morris.meyer@oracle.com>
parents:
11821
diff
changeset
|
100 } |
c7abc8411011
Fixed BasicPTXTest and IntegerPTXTest
Morris Meyer <morris.meyer@oracle.com>
parents:
11821
diff
changeset
|
101 *((gpu::Ptx::CUdeviceptr*) &_kernelArgBuffer[_bufferOffset]) = floatval.f; |
c7abc8411011
Fixed BasicPTXTest and IntegerPTXTest
Morris Meyer <morris.meyer@oracle.com>
parents:
11821
diff
changeset
|
102 _bufferOffset += sizeof(floatval.f); |
c7abc8411011
Fixed BasicPTXTest and IntegerPTXTest
Morris Meyer <morris.meyer@oracle.com>
parents:
11821
diff
changeset
|
103 } |
c7abc8411011
Fixed BasicPTXTest and IntegerPTXTest
Morris Meyer <morris.meyer@oracle.com>
parents:
11821
diff
changeset
|
104 return; |
11485
49bb1bc983c6
Implement several missing PTX codegen features; return value capture and method args passing of java method executed on GPU.
bharadwaj
parents:
diff
changeset
|
105 } |
49bb1bc983c6
Implement several missing PTX codegen features; return value capture and method args passing of java method executed on GPU.
bharadwaj
parents:
diff
changeset
|
106 |
11902
67a1e27a8dbb
PTX initial float and double
Morris Meyer <morris.meyer@oracle.com>
parents:
11901
diff
changeset
|
107 void PTXKernelArguments::do_double() { |
67a1e27a8dbb
PTX initial float and double
Morris Meyer <morris.meyer@oracle.com>
parents:
11901
diff
changeset
|
108 if (is_after_invocation()) { |
67a1e27a8dbb
PTX initial float and double
Morris Meyer <morris.meyer@oracle.com>
parents:
11901
diff
changeset
|
109 return; |
67a1e27a8dbb
PTX initial float and double
Morris Meyer <morris.meyer@oracle.com>
parents:
11901
diff
changeset
|
110 } |
67a1e27a8dbb
PTX initial float and double
Morris Meyer <morris.meyer@oracle.com>
parents:
11901
diff
changeset
|
111 // If the parameter is a return value, |
67a1e27a8dbb
PTX initial float and double
Morris Meyer <morris.meyer@oracle.com>
parents:
11901
diff
changeset
|
112 jvalue doubleval; |
67a1e27a8dbb
PTX initial float and double
Morris Meyer <morris.meyer@oracle.com>
parents:
11901
diff
changeset
|
113 if (is_return_type()) { |
67a1e27a8dbb
PTX initial float and double
Morris Meyer <morris.meyer@oracle.com>
parents:
11901
diff
changeset
|
114 // Allocate device memory for T_INT return value pointer on device. Size in bytes |
67a1e27a8dbb
PTX initial float and double
Morris Meyer <morris.meyer@oracle.com>
parents:
11901
diff
changeset
|
115 int status = gpu::Ptx::_cuda_cu_memalloc(&_return_value_ptr, T_DOUBLE_BYTE_SIZE); |
67a1e27a8dbb
PTX initial float and double
Morris Meyer <morris.meyer@oracle.com>
parents:
11901
diff
changeset
|
116 if (status != GRAAL_CUDA_SUCCESS) { |
67a1e27a8dbb
PTX initial float and double
Morris Meyer <morris.meyer@oracle.com>
parents:
11901
diff
changeset
|
117 tty->print_cr("[CUDA] *** Error (%d) Failed to allocate memory for return value pointer on device", status); |
67a1e27a8dbb
PTX initial float and double
Morris Meyer <morris.meyer@oracle.com>
parents:
11901
diff
changeset
|
118 _success = false; |
67a1e27a8dbb
PTX initial float and double
Morris Meyer <morris.meyer@oracle.com>
parents:
11901
diff
changeset
|
119 return; |
67a1e27a8dbb
PTX initial float and double
Morris Meyer <morris.meyer@oracle.com>
parents:
11901
diff
changeset
|
120 } |
67a1e27a8dbb
PTX initial float and double
Morris Meyer <morris.meyer@oracle.com>
parents:
11901
diff
changeset
|
121 // Push _return_value_ptr to _kernelBuffer |
67a1e27a8dbb
PTX initial float and double
Morris Meyer <morris.meyer@oracle.com>
parents:
11901
diff
changeset
|
122 *((gpu::Ptx::CUdeviceptr*) &_kernelArgBuffer[_bufferOffset]) = _return_value_ptr; |
67a1e27a8dbb
PTX initial float and double
Morris Meyer <morris.meyer@oracle.com>
parents:
11901
diff
changeset
|
123 // _bufferOffset += sizeof(_return_value_ptr); |
67a1e27a8dbb
PTX initial float and double
Morris Meyer <morris.meyer@oracle.com>
parents:
11901
diff
changeset
|
124 _bufferOffset += sizeof(doubleval.d); |
67a1e27a8dbb
PTX initial float and double
Morris Meyer <morris.meyer@oracle.com>
parents:
11901
diff
changeset
|
125 } else { |
67a1e27a8dbb
PTX initial float and double
Morris Meyer <morris.meyer@oracle.com>
parents:
11901
diff
changeset
|
126 // Get the next java argument and its value which should be a T_INT |
67a1e27a8dbb
PTX initial float and double
Morris Meyer <morris.meyer@oracle.com>
parents:
11901
diff
changeset
|
127 oop arg = next_arg(T_FLOAT); |
67a1e27a8dbb
PTX initial float and double
Morris Meyer <morris.meyer@oracle.com>
parents:
11901
diff
changeset
|
128 // Copy the java argument value to kernelArgBuffer |
67a1e27a8dbb
PTX initial float and double
Morris Meyer <morris.meyer@oracle.com>
parents:
11901
diff
changeset
|
129 if (java_lang_boxing_object::get_value(arg, &doubleval) != T_DOUBLE) { |
67a1e27a8dbb
PTX initial float and double
Morris Meyer <morris.meyer@oracle.com>
parents:
11901
diff
changeset
|
130 tty->print_cr("[CUDA] *** Error: Unexpected argument type; expecting T_INT"); |
67a1e27a8dbb
PTX initial float and double
Morris Meyer <morris.meyer@oracle.com>
parents:
11901
diff
changeset
|
131 _success = false; |
67a1e27a8dbb
PTX initial float and double
Morris Meyer <morris.meyer@oracle.com>
parents:
11901
diff
changeset
|
132 return; |
67a1e27a8dbb
PTX initial float and double
Morris Meyer <morris.meyer@oracle.com>
parents:
11901
diff
changeset
|
133 } |
67a1e27a8dbb
PTX initial float and double
Morris Meyer <morris.meyer@oracle.com>
parents:
11901
diff
changeset
|
134 *((gpu::Ptx::CUdeviceptr*) &_kernelArgBuffer[_bufferOffset]) = doubleval.d; |
67a1e27a8dbb
PTX initial float and double
Morris Meyer <morris.meyer@oracle.com>
parents:
11901
diff
changeset
|
135 _bufferOffset += sizeof(doubleval.d); |
67a1e27a8dbb
PTX initial float and double
Morris Meyer <morris.meyer@oracle.com>
parents:
11901
diff
changeset
|
136 } |
67a1e27a8dbb
PTX initial float and double
Morris Meyer <morris.meyer@oracle.com>
parents:
11901
diff
changeset
|
137 return; |
67a1e27a8dbb
PTX initial float and double
Morris Meyer <morris.meyer@oracle.com>
parents:
11901
diff
changeset
|
138 } |
67a1e27a8dbb
PTX initial float and double
Morris Meyer <morris.meyer@oracle.com>
parents:
11901
diff
changeset
|
139 |
11821
d8659ad83fcc
PTX single-threaded array store, Warp annotation
Morris Meyer <morris.meyer@oracle.com>
parents:
11596
diff
changeset
|
140 void PTXKernelArguments::do_long() { |
d8659ad83fcc
PTX single-threaded array store, Warp annotation
Morris Meyer <morris.meyer@oracle.com>
parents:
11596
diff
changeset
|
141 if (is_after_invocation()) { |
d8659ad83fcc
PTX single-threaded array store, Warp annotation
Morris Meyer <morris.meyer@oracle.com>
parents:
11596
diff
changeset
|
142 return; |
d8659ad83fcc
PTX single-threaded array store, Warp annotation
Morris Meyer <morris.meyer@oracle.com>
parents:
11596
diff
changeset
|
143 } |
11596
91e5f927af63
Initial implementation of PTXRuntime (RegisterConfig, PTX description etc); guarded with new flag UseGPU. Specify -XX:+UseGPU to exercise this new implementation.
bharadwaj
parents:
11485
diff
changeset
|
144 // If the parameter is a return value, |
11485
49bb1bc983c6
Implement several missing PTX codegen features; return value capture and method args passing of java method executed on GPU.
bharadwaj
parents:
diff
changeset
|
145 if (is_return_type()) { |
49bb1bc983c6
Implement several missing PTX codegen features; return value capture and method args passing of java method executed on GPU.
bharadwaj
parents:
diff
changeset
|
146 // Allocate device memory for T_LONG return value pointer on device. Size in bytes |
49bb1bc983c6
Implement several missing PTX codegen features; return value capture and method args passing of java method executed on GPU.
bharadwaj
parents:
diff
changeset
|
147 int status = gpu::Ptx::_cuda_cu_memalloc(&_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:
diff
changeset
|
148 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:
diff
changeset
|
149 tty->print_cr("[CUDA] *** Error (%d) Failed to allocate memory for return value pointer on device", status); |
49bb1bc983c6
Implement several missing PTX codegen features; return value capture and method args passing of java method executed on GPU.
bharadwaj
parents:
diff
changeset
|
150 _success = false; |
49bb1bc983c6
Implement several missing PTX codegen features; return value capture and method args passing of java method executed on GPU.
bharadwaj
parents:
diff
changeset
|
151 return; |
49bb1bc983c6
Implement several missing PTX codegen features; return value capture and method args passing of java method executed on GPU.
bharadwaj
parents:
diff
changeset
|
152 } |
49bb1bc983c6
Implement several missing PTX codegen features; return value capture and method args passing of java method executed on GPU.
bharadwaj
parents:
diff
changeset
|
153 // Push _return_value_ptr to _kernelBuffer |
49bb1bc983c6
Implement several missing PTX codegen features; return value capture and method args passing of java method executed on GPU.
bharadwaj
parents:
diff
changeset
|
154 *((gpu::Ptx::CUdeviceptr*) &_kernelArgBuffer[_bufferOffset]) = _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:
diff
changeset
|
155 _bufferOffset += sizeof(_return_value_ptr); |
11821
d8659ad83fcc
PTX single-threaded array store, Warp annotation
Morris Meyer <morris.meyer@oracle.com>
parents:
11596
diff
changeset
|
156 } else { |
11485
49bb1bc983c6
Implement several missing PTX codegen features; return value capture and method args passing of java method executed on GPU.
bharadwaj
parents:
diff
changeset
|
157 // Get the next java argument and its value which should be a T_LONG |
49bb1bc983c6
Implement several missing PTX codegen features; return value capture and method args passing of java method executed on GPU.
bharadwaj
parents:
diff
changeset
|
158 oop arg = next_arg(T_LONG); |
49bb1bc983c6
Implement several missing PTX codegen features; return value capture and method args passing of java method executed on GPU.
bharadwaj
parents:
diff
changeset
|
159 // Copy the java argument value to kernelArgBuffer |
49bb1bc983c6
Implement several missing PTX codegen features; return value capture and method args passing of java method executed on GPU.
bharadwaj
parents:
diff
changeset
|
160 jvalue val; |
49bb1bc983c6
Implement several missing PTX codegen features; return value capture and method args passing of java method executed on GPU.
bharadwaj
parents:
diff
changeset
|
161 if (java_lang_boxing_object::get_value(arg, &val) != T_LONG) { |
49bb1bc983c6
Implement several missing PTX codegen features; return value capture and method args passing of java method executed on GPU.
bharadwaj
parents:
diff
changeset
|
162 tty->print_cr("[CUDA] *** Error: Unexpected argument type; expecting T_LONG"); |
49bb1bc983c6
Implement several missing PTX codegen features; return value capture and method args passing of java method executed on GPU.
bharadwaj
parents:
diff
changeset
|
163 _success = false; |
49bb1bc983c6
Implement several missing PTX codegen features; return value capture and method args passing of java method executed on GPU.
bharadwaj
parents:
diff
changeset
|
164 return; |
49bb1bc983c6
Implement several missing PTX codegen features; return value capture and method args passing of java method executed on GPU.
bharadwaj
parents:
diff
changeset
|
165 } |
49bb1bc983c6
Implement several missing PTX codegen features; return value capture and method args passing of java method executed on GPU.
bharadwaj
parents:
diff
changeset
|
166 *((gpu::Ptx::CUdeviceptr*) &_kernelArgBuffer[_bufferOffset]) = val.j; |
49bb1bc983c6
Implement several missing PTX codegen features; return value capture and method args passing of java method executed on GPU.
bharadwaj
parents:
diff
changeset
|
167 _bufferOffset += sizeof(val.j); |
49bb1bc983c6
Implement several missing PTX codegen features; return value capture and method args passing of java method executed on GPU.
bharadwaj
parents:
diff
changeset
|
168 } |
49bb1bc983c6
Implement several missing PTX codegen features; return value capture and method args passing of java method executed on GPU.
bharadwaj
parents:
diff
changeset
|
169 return; |
49bb1bc983c6
Implement several missing PTX codegen features; return value capture and method args passing of java method executed on GPU.
bharadwaj
parents:
diff
changeset
|
170 } |
49bb1bc983c6
Implement several missing PTX codegen features; return value capture and method args passing of java method executed on GPU.
bharadwaj
parents:
diff
changeset
|
171 |
11821
d8659ad83fcc
PTX single-threaded array store, Warp annotation
Morris Meyer <morris.meyer@oracle.com>
parents:
11596
diff
changeset
|
172 void PTXKernelArguments::do_byte() { |
d8659ad83fcc
PTX single-threaded array store, Warp annotation
Morris Meyer <morris.meyer@oracle.com>
parents:
11596
diff
changeset
|
173 if (is_after_invocation()) { |
d8659ad83fcc
PTX single-threaded array store, Warp annotation
Morris Meyer <morris.meyer@oracle.com>
parents:
11596
diff
changeset
|
174 return; |
d8659ad83fcc
PTX single-threaded array store, Warp annotation
Morris Meyer <morris.meyer@oracle.com>
parents:
11596
diff
changeset
|
175 } |
d8659ad83fcc
PTX single-threaded array store, Warp annotation
Morris Meyer <morris.meyer@oracle.com>
parents:
11596
diff
changeset
|
176 // If the parameter is a return value, |
d8659ad83fcc
PTX single-threaded array store, Warp annotation
Morris Meyer <morris.meyer@oracle.com>
parents:
11596
diff
changeset
|
177 if (is_return_type()) { |
d8659ad83fcc
PTX single-threaded array store, Warp annotation
Morris Meyer <morris.meyer@oracle.com>
parents:
11596
diff
changeset
|
178 // Allocate device memory for T_BYTE return value pointer on device. Size in bytes |
d8659ad83fcc
PTX single-threaded array store, Warp annotation
Morris Meyer <morris.meyer@oracle.com>
parents:
11596
diff
changeset
|
179 int status = gpu::Ptx::_cuda_cu_memalloc(&_return_value_ptr, T_BYTE_SIZE); |
d8659ad83fcc
PTX single-threaded array store, Warp annotation
Morris Meyer <morris.meyer@oracle.com>
parents:
11596
diff
changeset
|
180 if (status != GRAAL_CUDA_SUCCESS) { |
d8659ad83fcc
PTX single-threaded array store, Warp annotation
Morris Meyer <morris.meyer@oracle.com>
parents:
11596
diff
changeset
|
181 tty->print_cr("[CUDA] *** Error (%d) Failed to allocate memory for return value pointer on device", status); |
d8659ad83fcc
PTX single-threaded array store, Warp annotation
Morris Meyer <morris.meyer@oracle.com>
parents:
11596
diff
changeset
|
182 _success = false; |
d8659ad83fcc
PTX single-threaded array store, Warp annotation
Morris Meyer <morris.meyer@oracle.com>
parents:
11596
diff
changeset
|
183 return; |
d8659ad83fcc
PTX single-threaded array store, Warp annotation
Morris Meyer <morris.meyer@oracle.com>
parents:
11596
diff
changeset
|
184 } |
d8659ad83fcc
PTX single-threaded array store, Warp annotation
Morris Meyer <morris.meyer@oracle.com>
parents:
11596
diff
changeset
|
185 // Push _return_value_ptr to _kernelBuffer |
d8659ad83fcc
PTX single-threaded array store, Warp annotation
Morris Meyer <morris.meyer@oracle.com>
parents:
11596
diff
changeset
|
186 *((gpu::Ptx::CUdeviceptr*) &_kernelArgBuffer[_bufferOffset]) = _return_value_ptr; |
d8659ad83fcc
PTX single-threaded array store, Warp annotation
Morris Meyer <morris.meyer@oracle.com>
parents:
11596
diff
changeset
|
187 _bufferOffset += sizeof(_return_value_ptr); |
d8659ad83fcc
PTX single-threaded array store, Warp annotation
Morris Meyer <morris.meyer@oracle.com>
parents:
11596
diff
changeset
|
188 } else { |
d8659ad83fcc
PTX single-threaded array store, Warp annotation
Morris Meyer <morris.meyer@oracle.com>
parents:
11596
diff
changeset
|
189 // Get the next java argument and its value which should be a T_BYTE |
d8659ad83fcc
PTX single-threaded array store, Warp annotation
Morris Meyer <morris.meyer@oracle.com>
parents:
11596
diff
changeset
|
190 oop arg = next_arg(T_BYTE); |
d8659ad83fcc
PTX single-threaded array store, Warp annotation
Morris Meyer <morris.meyer@oracle.com>
parents:
11596
diff
changeset
|
191 // Copy the java argument value to kernelArgBuffer |
d8659ad83fcc
PTX single-threaded array store, Warp annotation
Morris Meyer <morris.meyer@oracle.com>
parents:
11596
diff
changeset
|
192 jvalue val; |
d8659ad83fcc
PTX single-threaded array store, Warp annotation
Morris Meyer <morris.meyer@oracle.com>
parents:
11596
diff
changeset
|
193 if (java_lang_boxing_object::get_value(arg, &val) != T_BYTE) { |
d8659ad83fcc
PTX single-threaded array store, Warp annotation
Morris Meyer <morris.meyer@oracle.com>
parents:
11596
diff
changeset
|
194 tty->print_cr("[CUDA] *** Error: Unexpected argument type; expecting T_BYTE"); |
d8659ad83fcc
PTX single-threaded array store, Warp annotation
Morris Meyer <morris.meyer@oracle.com>
parents:
11596
diff
changeset
|
195 _success = false; |
d8659ad83fcc
PTX single-threaded array store, Warp annotation
Morris Meyer <morris.meyer@oracle.com>
parents:
11596
diff
changeset
|
196 return; |
d8659ad83fcc
PTX single-threaded array store, Warp annotation
Morris Meyer <morris.meyer@oracle.com>
parents:
11596
diff
changeset
|
197 } |
d8659ad83fcc
PTX single-threaded array store, Warp annotation
Morris Meyer <morris.meyer@oracle.com>
parents:
11596
diff
changeset
|
198 *((gpu::Ptx::CUdeviceptr*) &_kernelArgBuffer[_bufferOffset]) = val.b; |
d8659ad83fcc
PTX single-threaded array store, Warp annotation
Morris Meyer <morris.meyer@oracle.com>
parents:
11596
diff
changeset
|
199 _bufferOffset += sizeof(val.b); |
d8659ad83fcc
PTX single-threaded array store, Warp annotation
Morris Meyer <morris.meyer@oracle.com>
parents:
11596
diff
changeset
|
200 } |
d8659ad83fcc
PTX single-threaded array store, Warp annotation
Morris Meyer <morris.meyer@oracle.com>
parents:
11596
diff
changeset
|
201 return; |
d8659ad83fcc
PTX single-threaded array store, Warp annotation
Morris Meyer <morris.meyer@oracle.com>
parents:
11596
diff
changeset
|
202 } |
d8659ad83fcc
PTX single-threaded array store, Warp annotation
Morris Meyer <morris.meyer@oracle.com>
parents:
11596
diff
changeset
|
203 |
11901
61767ccd4600
PTX boolean return value, emitIntegerTestMove, warnings
Morris Meyer <morris.meyer@oracle.com>
parents:
11894
diff
changeset
|
204 void PTXKernelArguments::do_bool() { |
61767ccd4600
PTX boolean return value, emitIntegerTestMove, warnings
Morris Meyer <morris.meyer@oracle.com>
parents:
11894
diff
changeset
|
205 if (is_after_invocation()) { |
61767ccd4600
PTX boolean return value, emitIntegerTestMove, warnings
Morris Meyer <morris.meyer@oracle.com>
parents:
11894
diff
changeset
|
206 return; |
61767ccd4600
PTX boolean return value, emitIntegerTestMove, warnings
Morris Meyer <morris.meyer@oracle.com>
parents:
11894
diff
changeset
|
207 } |
61767ccd4600
PTX boolean return value, emitIntegerTestMove, warnings
Morris Meyer <morris.meyer@oracle.com>
parents:
11894
diff
changeset
|
208 // If the parameter is a return value, |
61767ccd4600
PTX boolean return value, emitIntegerTestMove, warnings
Morris Meyer <morris.meyer@oracle.com>
parents:
11894
diff
changeset
|
209 if (is_return_type()) { |
61767ccd4600
PTX boolean return value, emitIntegerTestMove, warnings
Morris Meyer <morris.meyer@oracle.com>
parents:
11894
diff
changeset
|
210 // Allocate device memory for T_BYTE return value pointer on device. Size in bytes |
61767ccd4600
PTX boolean return value, emitIntegerTestMove, warnings
Morris Meyer <morris.meyer@oracle.com>
parents:
11894
diff
changeset
|
211 int status = gpu::Ptx::_cuda_cu_memalloc(&_return_value_ptr, T_BOOLEAN_SIZE); |
61767ccd4600
PTX boolean return value, emitIntegerTestMove, warnings
Morris Meyer <morris.meyer@oracle.com>
parents:
11894
diff
changeset
|
212 if (status != GRAAL_CUDA_SUCCESS) { |
61767ccd4600
PTX boolean return value, emitIntegerTestMove, warnings
Morris Meyer <morris.meyer@oracle.com>
parents:
11894
diff
changeset
|
213 tty->print_cr("[CUDA] *** Error (%d) Failed to allocate memory for return value pointer on device", status); |
61767ccd4600
PTX boolean return value, emitIntegerTestMove, warnings
Morris Meyer <morris.meyer@oracle.com>
parents:
11894
diff
changeset
|
214 _success = false; |
61767ccd4600
PTX boolean return value, emitIntegerTestMove, warnings
Morris Meyer <morris.meyer@oracle.com>
parents:
11894
diff
changeset
|
215 return; |
61767ccd4600
PTX boolean return value, emitIntegerTestMove, warnings
Morris Meyer <morris.meyer@oracle.com>
parents:
11894
diff
changeset
|
216 } |
61767ccd4600
PTX boolean return value, emitIntegerTestMove, warnings
Morris Meyer <morris.meyer@oracle.com>
parents:
11894
diff
changeset
|
217 // Push _return_value_ptr to _kernelBuffer |
61767ccd4600
PTX boolean return value, emitIntegerTestMove, warnings
Morris Meyer <morris.meyer@oracle.com>
parents:
11894
diff
changeset
|
218 *((gpu::Ptx::CUdeviceptr*) &_kernelArgBuffer[_bufferOffset]) = _return_value_ptr; |
61767ccd4600
PTX boolean return value, emitIntegerTestMove, warnings
Morris Meyer <morris.meyer@oracle.com>
parents:
11894
diff
changeset
|
219 _bufferOffset += sizeof(_return_value_ptr); |
61767ccd4600
PTX boolean return value, emitIntegerTestMove, warnings
Morris Meyer <morris.meyer@oracle.com>
parents:
11894
diff
changeset
|
220 } else { |
61767ccd4600
PTX boolean return value, emitIntegerTestMove, warnings
Morris Meyer <morris.meyer@oracle.com>
parents:
11894
diff
changeset
|
221 // Get the next java argument and its value which should be a T_BYTE |
61767ccd4600
PTX boolean return value, emitIntegerTestMove, warnings
Morris Meyer <morris.meyer@oracle.com>
parents:
11894
diff
changeset
|
222 oop arg = next_arg(T_BYTE); |
61767ccd4600
PTX boolean return value, emitIntegerTestMove, warnings
Morris Meyer <morris.meyer@oracle.com>
parents:
11894
diff
changeset
|
223 // Copy the java argument value to kernelArgBuffer |
61767ccd4600
PTX boolean return value, emitIntegerTestMove, warnings
Morris Meyer <morris.meyer@oracle.com>
parents:
11894
diff
changeset
|
224 jvalue val; |
61767ccd4600
PTX boolean return value, emitIntegerTestMove, warnings
Morris Meyer <morris.meyer@oracle.com>
parents:
11894
diff
changeset
|
225 if (java_lang_boxing_object::get_value(arg, &val) != T_BOOLEAN) { |
61767ccd4600
PTX boolean return value, emitIntegerTestMove, warnings
Morris Meyer <morris.meyer@oracle.com>
parents:
11894
diff
changeset
|
226 tty->print_cr("[CUDA] *** Error: Unexpected argument type; expecting T_BYTE"); |
61767ccd4600
PTX boolean return value, emitIntegerTestMove, warnings
Morris Meyer <morris.meyer@oracle.com>
parents:
11894
diff
changeset
|
227 _success = false; |
61767ccd4600
PTX boolean return value, emitIntegerTestMove, warnings
Morris Meyer <morris.meyer@oracle.com>
parents:
11894
diff
changeset
|
228 return; |
61767ccd4600
PTX boolean return value, emitIntegerTestMove, warnings
Morris Meyer <morris.meyer@oracle.com>
parents:
11894
diff
changeset
|
229 } |
61767ccd4600
PTX boolean return value, emitIntegerTestMove, warnings
Morris Meyer <morris.meyer@oracle.com>
parents:
11894
diff
changeset
|
230 *((gpu::Ptx::CUdeviceptr*) &_kernelArgBuffer[_bufferOffset]) = val.z; |
61767ccd4600
PTX boolean return value, emitIntegerTestMove, warnings
Morris Meyer <morris.meyer@oracle.com>
parents:
11894
diff
changeset
|
231 _bufferOffset += sizeof(val.z); |
61767ccd4600
PTX boolean return value, emitIntegerTestMove, warnings
Morris Meyer <morris.meyer@oracle.com>
parents:
11894
diff
changeset
|
232 } |
61767ccd4600
PTX boolean return value, emitIntegerTestMove, warnings
Morris Meyer <morris.meyer@oracle.com>
parents:
11894
diff
changeset
|
233 return; |
61767ccd4600
PTX boolean return value, emitIntegerTestMove, warnings
Morris Meyer <morris.meyer@oracle.com>
parents:
11894
diff
changeset
|
234 } |
61767ccd4600
PTX boolean return value, emitIntegerTestMove, warnings
Morris Meyer <morris.meyer@oracle.com>
parents:
11894
diff
changeset
|
235 |
11821
d8659ad83fcc
PTX single-threaded array store, Warp annotation
Morris Meyer <morris.meyer@oracle.com>
parents:
11596
diff
changeset
|
236 void PTXKernelArguments::do_array(int begin, int end) { |
d8659ad83fcc
PTX single-threaded array store, Warp annotation
Morris Meyer <morris.meyer@oracle.com>
parents:
11596
diff
changeset
|
237 gpu::Ptx::CUdeviceptr _array_ptr; |
d8659ad83fcc
PTX single-threaded array store, Warp annotation
Morris Meyer <morris.meyer@oracle.com>
parents:
11596
diff
changeset
|
238 int status; |
d8659ad83fcc
PTX single-threaded array store, Warp annotation
Morris Meyer <morris.meyer@oracle.com>
parents:
11596
diff
changeset
|
239 |
d8659ad83fcc
PTX single-threaded array store, Warp annotation
Morris Meyer <morris.meyer@oracle.com>
parents:
11596
diff
changeset
|
240 // Get the next java argument and its value which should be a T_ARRAY |
d8659ad83fcc
PTX single-threaded array store, Warp annotation
Morris Meyer <morris.meyer@oracle.com>
parents:
11596
diff
changeset
|
241 oop arg = next_arg(T_OBJECT); |
d8659ad83fcc
PTX single-threaded array store, Warp annotation
Morris Meyer <morris.meyer@oracle.com>
parents:
11596
diff
changeset
|
242 int array_size = arg->size() * HeapWordSize; |
d8659ad83fcc
PTX single-threaded array store, Warp annotation
Morris Meyer <morris.meyer@oracle.com>
parents:
11596
diff
changeset
|
243 |
d8659ad83fcc
PTX single-threaded array store, Warp annotation
Morris Meyer <morris.meyer@oracle.com>
parents:
11596
diff
changeset
|
244 if (is_after_invocation()) { |
d8659ad83fcc
PTX single-threaded array store, Warp annotation
Morris Meyer <morris.meyer@oracle.com>
parents:
11596
diff
changeset
|
245 _array_ptr = *((gpu::Ptx::CUdeviceptr*) &_kernelArgBuffer[_bufferOffset]); |
d8659ad83fcc
PTX single-threaded array store, Warp annotation
Morris Meyer <morris.meyer@oracle.com>
parents:
11596
diff
changeset
|
246 status = gpu::Ptx::_cuda_cu_memcpy_dtoh(arg, _array_ptr, array_size); |
d8659ad83fcc
PTX single-threaded array store, Warp annotation
Morris Meyer <morris.meyer@oracle.com>
parents:
11596
diff
changeset
|
247 if (status != GRAAL_CUDA_SUCCESS) { |
d8659ad83fcc
PTX single-threaded array store, Warp annotation
Morris Meyer <morris.meyer@oracle.com>
parents:
11596
diff
changeset
|
248 tty->print_cr("[CUDA] *** Error (%d) Failed to copy array argument to host", status); |
d8659ad83fcc
PTX single-threaded array store, Warp annotation
Morris Meyer <morris.meyer@oracle.com>
parents:
11596
diff
changeset
|
249 _success = false; |
d8659ad83fcc
PTX single-threaded array store, Warp annotation
Morris Meyer <morris.meyer@oracle.com>
parents:
11596
diff
changeset
|
250 return; |
d8659ad83fcc
PTX single-threaded array store, Warp annotation
Morris Meyer <morris.meyer@oracle.com>
parents:
11596
diff
changeset
|
251 } else { |
d8659ad83fcc
PTX single-threaded array store, Warp annotation
Morris Meyer <morris.meyer@oracle.com>
parents:
11596
diff
changeset
|
252 // tty->print_cr("device: %x host: %x size: %d", _array_ptr, arg, array_size); |
d8659ad83fcc
PTX single-threaded array store, Warp annotation
Morris Meyer <morris.meyer@oracle.com>
parents:
11596
diff
changeset
|
253 } |
d8659ad83fcc
PTX single-threaded array store, Warp annotation
Morris Meyer <morris.meyer@oracle.com>
parents:
11596
diff
changeset
|
254 return; |
d8659ad83fcc
PTX single-threaded array store, Warp annotation
Morris Meyer <morris.meyer@oracle.com>
parents:
11596
diff
changeset
|
255 } |
d8659ad83fcc
PTX single-threaded array store, Warp annotation
Morris Meyer <morris.meyer@oracle.com>
parents:
11596
diff
changeset
|
256 // Allocate device memory for T_ARRAY return value pointer on device. Size in bytes |
d8659ad83fcc
PTX single-threaded array store, Warp annotation
Morris Meyer <morris.meyer@oracle.com>
parents:
11596
diff
changeset
|
257 status = gpu::Ptx::_cuda_cu_memalloc(&_return_value_ptr, array_size); |
11485
49bb1bc983c6
Implement several missing PTX codegen features; return value capture and method args passing of java method executed on GPU.
bharadwaj
parents:
diff
changeset
|
258 if (status != GRAAL_CUDA_SUCCESS) { |
11821
d8659ad83fcc
PTX single-threaded array store, Warp annotation
Morris Meyer <morris.meyer@oracle.com>
parents:
11596
diff
changeset
|
259 tty->print_cr("[CUDA] *** Error (%d) Failed to allocate memory for return value pointer on device", status); |
d8659ad83fcc
PTX single-threaded array store, Warp annotation
Morris Meyer <morris.meyer@oracle.com>
parents:
11596
diff
changeset
|
260 _success = false; |
d8659ad83fcc
PTX single-threaded array store, Warp annotation
Morris Meyer <morris.meyer@oracle.com>
parents:
11596
diff
changeset
|
261 return; |
d8659ad83fcc
PTX single-threaded array store, Warp annotation
Morris Meyer <morris.meyer@oracle.com>
parents:
11596
diff
changeset
|
262 } |
d8659ad83fcc
PTX single-threaded array store, Warp annotation
Morris Meyer <morris.meyer@oracle.com>
parents:
11596
diff
changeset
|
263 status = gpu::Ptx::_cuda_cu_memcpy_htod(_return_value_ptr, arg, array_size); |
d8659ad83fcc
PTX single-threaded array store, Warp annotation
Morris Meyer <morris.meyer@oracle.com>
parents:
11596
diff
changeset
|
264 if (status != GRAAL_CUDA_SUCCESS) { |
d8659ad83fcc
PTX single-threaded array store, Warp annotation
Morris Meyer <morris.meyer@oracle.com>
parents:
11596
diff
changeset
|
265 tty->print_cr("[CUDA] *** Error (%d) Failed to copy array to device argument", status); |
d8659ad83fcc
PTX single-threaded array store, Warp annotation
Morris Meyer <morris.meyer@oracle.com>
parents:
11596
diff
changeset
|
266 _success = false; |
d8659ad83fcc
PTX single-threaded array store, Warp annotation
Morris Meyer <morris.meyer@oracle.com>
parents:
11596
diff
changeset
|
267 return; |
d8659ad83fcc
PTX single-threaded array store, Warp annotation
Morris Meyer <morris.meyer@oracle.com>
parents:
11596
diff
changeset
|
268 } else { |
d8659ad83fcc
PTX single-threaded array store, Warp annotation
Morris Meyer <morris.meyer@oracle.com>
parents:
11596
diff
changeset
|
269 // tty->print_cr("host: %x device: %x size: %d", arg, _return_value_ptr, array_size); |
11485
49bb1bc983c6
Implement several missing PTX codegen features; return value capture and method args passing of java method executed on GPU.
bharadwaj
parents:
diff
changeset
|
270 } |
49bb1bc983c6
Implement several missing PTX codegen features; return value capture and method args passing of java method executed on GPU.
bharadwaj
parents:
diff
changeset
|
271 // Push _return_value_ptr to _kernelBuffer |
49bb1bc983c6
Implement several missing PTX codegen features; return value capture and method args passing of java method executed on GPU.
bharadwaj
parents:
diff
changeset
|
272 *((gpu::Ptx::CUdeviceptr*) &_kernelArgBuffer[_bufferOffset]) = _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:
diff
changeset
|
273 _bufferOffset += sizeof(_return_value_ptr); |
11821
d8659ad83fcc
PTX single-threaded array store, Warp annotation
Morris Meyer <morris.meyer@oracle.com>
parents:
11596
diff
changeset
|
274 return; |
d8659ad83fcc
PTX single-threaded array store, Warp annotation
Morris Meyer <morris.meyer@oracle.com>
parents:
11596
diff
changeset
|
275 } |
d8659ad83fcc
PTX single-threaded array store, Warp annotation
Morris Meyer <morris.meyer@oracle.com>
parents:
11596
diff
changeset
|
276 |
d8659ad83fcc
PTX single-threaded array store, Warp annotation
Morris Meyer <morris.meyer@oracle.com>
parents:
11596
diff
changeset
|
277 void PTXKernelArguments::do_void() { |
d8659ad83fcc
PTX single-threaded array store, Warp annotation
Morris Meyer <morris.meyer@oracle.com>
parents:
11596
diff
changeset
|
278 return; |
11485
49bb1bc983c6
Implement several missing PTX codegen features; return value capture and method args passing of java method executed on GPU.
bharadwaj
parents:
diff
changeset
|
279 } |
49bb1bc983c6
Implement several missing PTX codegen features; return value capture and method args passing of java method executed on GPU.
bharadwaj
parents:
diff
changeset
|
280 |
49bb1bc983c6
Implement several missing PTX codegen features; return value capture and method args passing of java method executed on GPU.
bharadwaj
parents:
diff
changeset
|
281 // TODO implement other do_* |