Mercurial > hg > truffle
comparison src/gpu/ptx/vm/kernelArguments.hpp @ 11485:49bb1bc983c6
Implement several missing PTX codegen features; return value capture and method args passing of java method executed on GPU.
author | bharadwaj |
---|---|
date | Fri, 30 Aug 2013 16:39:05 -0400 |
parents | |
children | c99e65785936 |
comparison
equal
deleted
inserted
replaced
11484:2aac62d79af4 | 11485:49bb1bc983c6 |
---|---|
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 #ifndef KERNEL_ARGUMENTS_PTX_HPP | |
26 #define KERNEL_ARGUMENTS_PTX_HPP | |
27 | |
28 #include "runtime/gpu.hpp" | |
29 #include "runtime/signature.hpp" | |
30 | |
31 #define T_BYTE_SIZE 1 | |
32 #define T_INT_BYTE_SIZE 4 | |
33 #define T_LONG_BYTE_SIZE 8 | |
34 | |
35 class PTXKernelArguments : public SignatureIterator { | |
36 public: | |
37 // Buffer holding CUdeviceptr values that represent the kernel arguments | |
38 char _kernelArgBuffer[1024]; | |
39 // Current offset into _kernelArgBuffer | |
40 size_t _bufferOffset; | |
41 gpu::Ptx::CUdeviceptr _return_value_ptr; | |
42 private: | |
43 // Array of java argument oops | |
44 arrayOop _args; | |
45 // Current index into _args | |
46 int _index; | |
47 // Flag to indicate successful creation of kernel argument buffer | |
48 bool _success; | |
49 // Get next java argument | |
50 oop next_arg(BasicType expectedType); | |
51 | |
52 public: | |
53 PTXKernelArguments(Symbol* signature, arrayOop args, bool is_static) : SignatureIterator(signature) { | |
54 this->_return_type = T_ILLEGAL; | |
55 _index = 0; | |
56 _args = args; | |
57 _success = true; | |
58 _bufferOffset = 0; | |
59 if (!is_static) { | |
60 // TODO : Create a device argument for receiver object and add it to _kernelBuffer | |
61 tty->print_cr("{CUDA] ****** TODO: Support for execution of non-static java methods not implemented yet."); | |
62 } | |
63 // Iterate over the entire signature | |
64 iterate(); | |
65 assert((_success && (_index == args->length())), "arg count mismatch with signature"); | |
66 } | |
67 | |
68 inline char* device_argument_buffer() { | |
69 return _kernelArgBuffer; | |
70 } | |
71 | |
72 inline size_t device_argument_buffer_size() { | |
73 return _bufferOffset; | |
74 } | |
75 | |
76 // Get the return oop value | |
77 oop get_return_oop(); | |
78 | |
79 // get device return value ptr | |
80 gpu::Ptx::CUdeviceptr get_return_value_ptr() { | |
81 return _return_value_ptr; | |
82 } | |
83 | |
84 | |
85 void do_byte(); | |
86 void do_int(); | |
87 void do_long(); | |
88 | |
89 inline void do_bool() { | |
90 /* TODO : To be implemented */ | |
91 guarantee(false, "NYI"); | |
92 } | |
93 inline void do_char() { | |
94 /* TODO : To be implemented */ | |
95 guarantee(false, "NYI"); | |
96 } | |
97 inline void do_short() { | |
98 /* TODO : To be implemented */ | |
99 guarantee(false, "NYI"); | |
100 } | |
101 inline void do_float() { | |
102 /* TODO : To be implemented */ | |
103 guarantee(false, "NYI"); | |
104 } | |
105 inline void do_double() { | |
106 /* TODO : To be implemented */ | |
107 guarantee(false, "NYI"); | |
108 } | |
109 | |
110 inline void do_object() { | |
111 /* TODO : To be implemented */ | |
112 guarantee(false, "NYI"); | |
113 } | |
114 inline void do_object(int begin, int end) { | |
115 /* TODO : To be implemented */ | |
116 guarantee(false, "NYI"); | |
117 } | |
118 inline void do_array(int begin, int end) { | |
119 /* TODO : To be implemented */ | |
120 guarantee(false, "NYI"); | |
121 } | |
122 inline void do_void() { | |
123 /* TODO : To be implemented */ | |
124 guarantee(false, "NYI"); | |
125 } | |
126 }; | |
127 | |
128 #endif // KERNEL_ARGUMENTS_HPP |