comparison src/share/vm/runtime/compilationPolicy.cpp @ 13819:49db2c1e3bee

added support for co-existing GPU backends (JBS:GRAAL-1)
author Doug Simon <doug.simon@oracle.com>
date Thu, 30 Jan 2014 00:52:33 +0100
parents 9161ed8ce796
children 0995dcbd6dd8
comparison
equal deleted inserted replaced
13818:d2f520f46180 13819:49db2c1e3bee
161 return (result && can_be_compiled(m, comp_level)); 161 return (result && can_be_compiled(m, comp_level));
162 } 162 }
163 163
164 bool CompilationPolicy::can_be_offloaded_to_gpu(methodHandle m) { 164 bool CompilationPolicy::can_be_offloaded_to_gpu(methodHandle m) {
165 #ifdef GRAAL 165 #ifdef GRAAL
166 if (GPUOffload) { 166 if (GPUOffload && gpu::initialized_gpus() > 0) {
167 // Check if this method can be offloaded to GPU. 167 // Check if this method can be off-loaded to GPU.
168 // 1. Offload it to GPU if it is a Lambda method
169 if (m->is_synthetic()) { 168 if (m->is_synthetic()) {
170 // A lambda method is a syntheric method. 169 // A lambda method is a synthetic method.
171 Symbol * klass_name = m->method_holder()->name(); 170 Symbol * klass_name = m->method_holder()->name();
172 Symbol * method_name = m->name(); 171 Symbol * method_name = m->name();
173 bool offloadToGPU = false;
174 { 172 {
175 ResourceMark rm; 173 ResourceMark rm;
176 if (klass_name != NULL) { 174 if (klass_name != NULL) {
177 if (klass_name != NULL && method_name != NULL) { 175 if (klass_name != NULL && method_name != NULL) {
178 const char* lambdaPrefix = "lambda$"; 176 const char* lambdaPrefix = "lambda$";
179 char* methodPrefix = strstr(method_name->as_C_string(), lambdaPrefix); 177 char* methodPrefix = strstr(method_name->as_C_string(), lambdaPrefix);
180 if (methodPrefix != 0) { 178 if (methodPrefix != 0) {
181 if ((strncmp(lambdaPrefix, methodPrefix, strlen(lambdaPrefix)) == 0)) { 179 if ((strncmp(lambdaPrefix, methodPrefix, strlen(lambdaPrefix)) == 0)) {
182 offloadToGPU = true; 180 if (TraceGPUInteraction) {
181 char buf[O_BUFLEN];
182 tty->print_cr("Selected lambda method %s for GPU offload", m->name_and_sig_as_C_string(buf, O_BUFLEN));
183 }
184 return true;
183 } 185 }
184 } 186 }
185 } 187 }
186 } 188 }
187 } 189 }
188 if (offloadToGPU) {
189 // If GPU is available and the necessary linkage is available
190 // return true indicatin that this method must be compiled.
191 if (gpu::is_available() && gpu::has_gpu_linkage()) {
192 if (TraceGPUInteraction) {
193 tty->print("Compiling Lambda method ");
194 m->print_short_name();
195 switch (gpu::get_target_il_type()) {
196 case gpu::PTX :
197 tty->print_cr("to PTX");
198 break;
199 case gpu::HSAIL :
200 tty->print_cr("to HSAIL");
201 break;
202 default :
203 tty->print_cr("to Unknown GPU!!!");
204 }
205 }
206 return true;
207 }
208 }
209 } 190 }
210 } 191 }
211 #endif 192 #endif
212
213 return false; 193 return false;
214 } 194 }
215 195
216 bool CompilationPolicy::is_compilation_enabled() { 196 bool CompilationPolicy::is_compilation_enabled() {
217 // NOTE: CompileBroker::should_compile_new_jobs() checks for UseCompiler 197 // NOTE: CompileBroker::should_compile_new_jobs() checks for UseCompiler