comparison src/gpu/hsail/vm/hsailKernelArguments.cpp @ 12743:f1a55428a8d7

more HSAIL support in the C++ layer for executing HSAIL code on the simulator Contributed-by: Eric Caspole <eric.caspole@amd.com>
author Doug Simon <doug.simon@oracle.com>
date Sun, 10 Nov 2013 13:18:09 +0100
parents
children 89fbf495e589
comparison
equal deleted inserted replaced
12742:40924dbc623b 12743:f1a55428a8d7
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"
26 #include "hsailKernelArguments.hpp"
27 #include "runtime/javaCalls.hpp"
28
29
30 // Get next java argument
31 oop HSAILKernelArguments::next_arg(BasicType expectedType) {
32 assert(_index < _args->length(), "out of bounds");
33
34 oop arg = ((objArrayOop) (_args))->obj_at(_index++);
35 assert(expectedType == T_OBJECT ||
36 java_lang_boxing_object::is_instance(arg, expectedType), "arg type mismatch");
37
38 return arg;
39 }
40
41 void HSAILKernelArguments::do_bool() {
42 // Get the boxed value
43 oop arg = _args->obj_at(_index++);
44 assert(java_lang_boxing_object::is_instance(arg, T_BOOLEAN), "arg type mismatch");
45
46 jvalue jValue;
47 java_lang_boxing_object::get_value(arg, &jValue);
48
49 bool pushed = gpu::Hsail::_okra_push_boolean(_kernel, jValue.z);
50 assert(pushed == true, "arg push failed");
51 }
52
53 void HSAILKernelArguments::do_byte() {
54 // Get the boxed value
55 oop arg = _args->obj_at(_index++);
56 assert(java_lang_boxing_object::is_instance(arg, T_BYTE), "arg type mismatch");
57
58 jvalue jValue;
59 java_lang_boxing_object::get_value(arg, &jValue);
60
61 bool pushed = gpu::Hsail::_okra_push_byte(_kernel, jValue.b);
62 assert(pushed == true, "arg push failed");
63 }
64
65 void HSAILKernelArguments::do_double() {
66 // Get the boxed value
67 oop arg = _args->obj_at(_index++);
68 assert(java_lang_boxing_object::is_instance(arg, T_DOUBLE), "arg type mismatch");
69
70 jvalue jValue;
71 java_lang_boxing_object::get_value(arg, &jValue);
72 if (TraceGPUInteraction) {
73 tty->print_cr("[HSAIL] HSAILKernelArguments::double value = %e", jValue.d);
74 }
75 bool pushed = gpu::Hsail::_okra_push_double(_kernel, jValue.d);
76 assert(pushed == true, "arg push failed");
77 }
78
79 void HSAILKernelArguments::do_float() {
80 // Get the boxed value
81 oop arg = _args->obj_at(_index++);
82 assert(java_lang_boxing_object::is_instance(arg, T_FLOAT), "arg type mismatch");
83
84 jvalue jValue;
85 java_lang_boxing_object::get_value(arg, &jValue);
86 if (TraceGPUInteraction) {
87 tty->print_cr("[HSAIL] HSAILKernelArguments::float value = %f", jValue.f);
88 }
89 bool pushed = gpu::Hsail::_okra_push_float(_kernel, jValue.f);
90 assert(pushed == true, "float push failed");
91 }
92
93 void HSAILKernelArguments::do_int() {
94 // The last int is the iteration variable in an IntStream, but we don't pass it
95 // since we use the HSAIL workitemid in place of that int value
96 if (_index == _length) {
97 if (TraceGPUInteraction) {
98 tty->print_cr("[HSAIL] HSAILKernelArguments::not pushing trailing int");
99 }
100 return;
101 }
102
103 // Get the boxed int
104 oop arg = _args->obj_at(_index++);
105 assert(java_lang_boxing_object::is_instance(arg, T_INT), "arg type mismatch");
106
107 jvalue jValue;
108 java_lang_boxing_object::get_value(arg, &jValue);
109
110 bool pushed = gpu::Hsail::_okra_push_int(_kernel, jValue.i);
111 assert(pushed == true, "arg push failed");
112 }
113
114 void HSAILKernelArguments::do_long() {
115 // Get the boxed value
116 oop arg = _args->obj_at(_index++);
117 assert(java_lang_boxing_object::is_instance(arg, T_LONG), "arg type mismatch");
118
119 jvalue jValue;
120 java_lang_boxing_object::get_value(arg, &jValue);
121
122 bool pushed = gpu::Hsail::_okra_push_long(_kernel, jValue.j);
123 assert(pushed == true, "arg push failed");
124 }
125
126 void HSAILKernelArguments::do_array(int begin, int end) {
127 oop arg = _args->obj_at(_index++);
128 assert(arg->is_array(), "arg type mismatch");
129 if (TraceGPUInteraction) {
130 tty->print_cr("[HSAIL] HSAILKernelArguments::do_array 0x%08x, is a %s", (address) arg, arg->klass()->external_name());
131 }
132
133 bool pushed = gpu::Hsail::_okra_push_object(_kernel, arg);
134 assert(pushed == true, "arg push failed");
135 }
136
137 void HSAILKernelArguments::do_object() {
138 if (TraceGPUInteraction) {
139 tty->print_cr("[HSAIL] HSAILKernelArguments::do_object.");
140 }
141 if (_index == _length) {
142 // last arg in object stream lambda is the object stream source array
143 if (TraceGPUInteraction) {
144 tty->print_cr("[HSAIL] HSAILKernelArguments::trailing object ref should be object source array ref");
145 }
146 }
147
148 oop arg = _args->obj_at(_index++);
149 assert(arg->is_array(), "arg type mismatch");
150 if (TraceGPUInteraction) {
151 tty->print_cr("[HSAIL] HSAILKernelArguments::do_object, 0x%08x is a %s", (address) arg, arg->klass()->external_name());
152 }
153
154 bool pushed = gpu::Hsail::_okra_push_object(_kernel, arg);
155 assert(pushed == true, "arg push failed");
156 }
157
158 void HSAILKernelArguments::do_object(int begin, int end) {
159 if (TraceGPUInteraction) {
160 tty->print_cr("[HSAIL] HSAILKernelArguments::do_object(int begin, int end).");
161 }
162
163 if ((!_is_static && (_index >=(_length-1))) || (_is_static && (_index >=(_length)))) {
164 // last arg in object stream lambda is the object stream source array
165 if (TraceGPUInteraction) {
166 tty->print_cr("[HSAIL] HSAILKernelArguments::trailing object ref should be object source array ref");
167 }
168 }
169
170 oop arg = _args->obj_at(_index++);
171 assert(arg->is_array(), "arg type mismatch");
172 if (TraceGPUInteraction) {
173 tty->print_cr("[HSAIL] HSAILKernelArguments::do_object(int, int), 0x%08x is a %s", (address) arg, arg->klass()->external_name());
174 }
175
176 bool pushed = gpu::Hsail::_okra_push_object(_kernel, arg);
177 assert(pushed == true, "arg push failed");
178 }
179
180 void HSAILKernelArguments::do_void() {
181 return;
182 }
183
184 // TODO implement other do_*