Mercurial > hg > graal-jvmci-8
diff src/share/vm/runtime/compilationPolicy.cpp @ 13731:9161ed8ce796
Add graal-specific option -XX:+GPUOffload to trigger all GPU offload functionality. Cleanup function to decide GPU offload. Exclude GPU sources from nongraal builds.
author | S.Bharadwaj Yadavalli <bharadwaj.yadavalli@oracle.com> |
---|---|
date | Wed, 22 Jan 2014 16:06:47 -0500 |
parents | de839ec35cc7 |
children | 49db2c1e3bee |
line wrap: on
line diff
--- a/src/share/vm/runtime/compilationPolicy.cpp Wed Jan 22 15:27:31 2014 +0100 +++ b/src/share/vm/runtime/compilationPolicy.cpp Wed Jan 22 16:06:47 2014 -0500 @@ -105,30 +105,7 @@ if (m->has_compiled_code()) return false; // already compiled -#ifdef GRAAL - // Check if this is a Lambda method that can be compiled to a GPU. - if (m->is_lambda()) { - // If GPU is available and the necessary linkage is available - // rerurn true indicatin that this method must be compiled. - if (gpu::is_available() && gpu::has_gpu_linkage()) { - if (TraceGPUInteraction) { - tty->print("Compiling Lambda method"); - m->print_short_name(); - switch (gpu::get_target_il_type()) { - case gpu::PTX : - tty->print_cr(" to PTX"); - break; - case gpu::HSAIL : - tty->print_cr(" to HSAIL"); - break; - default : - tty->print_cr(" to Unknown GPU!!!"); - } - } - return true; - } - } -#endif + if (CompilationPolicy::can_be_offloaded_to_gpu(m)) return true; if (!can_be_compiled(m, comp_level)) return false; @@ -184,6 +161,58 @@ return (result && can_be_compiled(m, comp_level)); } +bool CompilationPolicy::can_be_offloaded_to_gpu(methodHandle m) { +#ifdef GRAAL + if (GPUOffload) { + // Check if this method can be offloaded to GPU. + // 1. Offload it to GPU if it is a Lambda method + if (m->is_synthetic()) { + // A lambda method is a syntheric method. + Symbol * klass_name = m->method_holder()->name(); + Symbol * method_name = m->name(); + bool offloadToGPU = false; + { + ResourceMark rm; + if (klass_name != NULL) { + if (klass_name != NULL && method_name != NULL) { + const char* lambdaPrefix = "lambda$"; + char* methodPrefix = strstr(method_name->as_C_string(), lambdaPrefix); + if (methodPrefix != 0) { + if ((strncmp(lambdaPrefix, methodPrefix, strlen(lambdaPrefix)) == 0)) { + offloadToGPU = true; + } + } + } + } + } + if (offloadToGPU) { + // If GPU is available and the necessary linkage is available + // return true indicatin that this method must be compiled. + if (gpu::is_available() && gpu::has_gpu_linkage()) { + if (TraceGPUInteraction) { + tty->print("Compiling Lambda method "); + m->print_short_name(); + switch (gpu::get_target_il_type()) { + case gpu::PTX : + tty->print_cr("to PTX"); + break; + case gpu::HSAIL : + tty->print_cr("to HSAIL"); + break; + default : + tty->print_cr("to Unknown GPU!!!"); + } + } + return true; + } + } + } + } +#endif + + return false; +} + bool CompilationPolicy::is_compilation_enabled() { // NOTE: CompileBroker::should_compile_new_jobs() checks for UseCompiler return !delay_compilation_during_startup() && CompileBroker::should_compile_new_jobs();