# HG changeset patch # User Doug Simon # Date 1394729324 -3600 # Node ID 10c4df6767c45c68206d2129f24f17528a51f9b2 # Parent 5e55de0379d98e766d0bd95c173d3b6d5f14b6a7 removed GPU offload interaction with compilation policy diff -r 5e55de0379d9 -r 10c4df6767c4 graal/com.oracle.graal.hotspot.ptx/src/com/oracle/graal/hotspot/ptx/PTXHotSpotBackend.java --- a/graal/com.oracle.graal.hotspot.ptx/src/com/oracle/graal/hotspot/ptx/PTXHotSpotBackend.java Thu Mar 13 17:47:44 2014 +0100 +++ b/graal/com.oracle.graal.hotspot.ptx/src/com/oracle/graal/hotspot/ptx/PTXHotSpotBackend.java Thu Mar 13 17:48:44 2014 +0100 @@ -41,7 +41,6 @@ import com.oracle.graal.debug.Debug.Scope; import com.oracle.graal.graph.*; import com.oracle.graal.hotspot.*; -import com.oracle.graal.hotspot.HotSpotReplacementsImpl.GraphProducer; import com.oracle.graal.hotspot.meta.*; import com.oracle.graal.lir.*; import com.oracle.graal.lir.LIRInstruction.OperandFlag; @@ -165,30 +164,6 @@ return deviceInitialized; } - @Override - public GraphProducer getGraphProducer() { - if (!deviceInitialized) { - // GPU could not be initialized so offload is disabled - return null; - } - return new GraphProducer() { - - public StructuredGraph getGraphFor(ResolvedJavaMethod method) { - if (canOffloadToGPU(method)) { - ExternalCompilationResult ptxCode = PTXHotSpotBackend.this.compileKernel(method, true); - HotSpotNmethod installedPTXCode = PTXHotSpotBackend.this.installKernel(method, ptxCode); - return new PTXWrapperBuilder(method, installedPTXCode, getRuntime().getHostBackend().getProviders()).getGraph(); - } - return null; - } - - private boolean canOffloadToGPU(ResolvedJavaMethod method) { - HotSpotVMConfig config = getRuntime().getConfig(); - return config.gpuOffload && method.getName().contains("lambda$") && method.isSynthetic(); - } - }; - } - /** * Compiles a given method to PTX code. * diff -r 5e55de0379d9 -r 10c4df6767c4 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotBackend.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotBackend.java Thu Mar 13 17:47:44 2014 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotBackend.java Thu Mar 13 17:48:44 2014 +0100 @@ -27,13 +27,13 @@ import com.oracle.graal.api.code.*; import com.oracle.graal.api.meta.*; import com.oracle.graal.compiler.target.*; -import com.oracle.graal.hotspot.HotSpotReplacementsImpl.GraphProducer; import com.oracle.graal.hotspot.bridge.*; import com.oracle.graal.hotspot.meta.*; import com.oracle.graal.hotspot.stubs.*; import com.oracle.graal.lir.*; -import com.oracle.graal.lir.LIRInstruction.*; -import com.oracle.graal.lir.StandardOp.*; +import com.oracle.graal.lir.LIRInstruction.ValueProcedure; +import com.oracle.graal.lir.StandardOp.LabelOp; +import com.oracle.graal.lir.StandardOp.SaveRegistersOp; import com.oracle.graal.nodes.*; import com.oracle.graal.nodes.cfg.*; import com.oracle.graal.phases.tiers.*; @@ -95,14 +95,6 @@ } /** - * Gets the graph producer provided by this backend (if any). A primary use case for this is a - * GPU backend that may want to offload certain methods to the GPU. - */ - public GraphProducer getGraphProducer() { - return null; - } - - /** * Finds all the registers that are defined by some given LIR. * * @param lir the LIR to examine diff -r 5e55de0379d9 -r 10c4df6767c4 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotHostBackend.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotHostBackend.java Thu Mar 13 17:47:44 2014 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotHostBackend.java Thu Mar 13 17:48:44 2014 +0100 @@ -26,12 +26,10 @@ import java.util.*; -import com.oracle.graal.api.code.*; import com.oracle.graal.api.meta.*; import com.oracle.graal.compiler.target.*; import com.oracle.graal.debug.*; import com.oracle.graal.debug.Debug.Scope; -import com.oracle.graal.hotspot.HotSpotReplacementsImpl.*; import com.oracle.graal.hotspot.meta.*; import com.oracle.graal.nodes.spi.*; @@ -60,8 +58,6 @@ lowerer.initialize(providers, config); HotSpotReplacementsImpl replacements = (HotSpotReplacementsImpl) providers.getReplacements(); - replacements.registerGraphProducers(getNonHostGraphProducers()); - // Install intrinsics. if (Intrinsify.getValue()) { try (Scope s = Debug.scope("RegisterReplacements", new DebugDumpScope("RegisterReplacements"))) { @@ -81,26 +77,4 @@ } } - - /** - * Gets the {@link GraphProducer}s from the non-host backends. These allow a GPU backend (for - * example) to offload compilation and execution of certain methods to a GPU. - *

- * Note that is is a very rough initial attempt at providing a hook for a GPU backend to - * intercept a compilation (or method inlining) for the purpose of routing execution to the GPU. - * Expect it to be extensively refined as experimentation with GPU offload proceeds. - */ - protected GraphProducer[] getNonHostGraphProducers() { - List list = new ArrayList<>(); - for (Map.Entry, HotSpotBackend> e : getRuntime().getBackends().entrySet()) { - HotSpotBackend value = e.getValue(); - if (value != this) { - GraphProducer gp = value.getGraphProducer(); - if (gp != null) { - list.add(gp); - } - } - } - return list.toArray(new GraphProducer[list.size()]); - } } diff -r 5e55de0379d9 -r 10c4df6767c4 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotReplacementsImpl.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotReplacementsImpl.java Thu Mar 13 17:47:44 2014 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotReplacementsImpl.java Thu Mar 13 17:48:44 2014 +0100 @@ -80,41 +80,6 @@ return super.registerMethodSubstitution(originalMethod, substituteMethod); } - /** - * A producer of graphs for methods. - */ - public interface GraphProducer { - - /** - * @returns a graph for {@code method} or null - */ - StructuredGraph getGraphFor(ResolvedJavaMethod method); - } - - /** - * Registers the graph producers that will take precedence over the registered method - * substitutions when {@link #getMethodSubstitution(ResolvedJavaMethod)} is called. - */ - public void registerGraphProducers(GraphProducer[] producers) { - assert this.graphProducers == UNINITIALIZED : "graph producers must be registered at most once"; - this.graphProducers = producers.clone(); - } - - private static GraphProducer[] UNINITIALIZED = {}; - - private GraphProducer[] graphProducers = UNINITIALIZED; - - @Override - public StructuredGraph getMethodSubstitution(ResolvedJavaMethod original) { - for (GraphProducer gp : graphProducers) { - StructuredGraph graph = gp.getGraphFor(original); - if (graph != null) { - return graph; - } - } - return super.getMethodSubstitution(original); - } - @Override public Class getMacroSubstitution(ResolvedJavaMethod method) { HotSpotResolvedJavaMethod hsMethod = (HotSpotResolvedJavaMethod) method; diff -r 5e55de0379d9 -r 10c4df6767c4 src/share/vm/compiler/compileBroker.cpp --- a/src/share/vm/compiler/compileBroker.cpp Thu Mar 13 17:47:44 2014 +0100 +++ b/src/share/vm/compiler/compileBroker.cpp Thu Mar 13 17:48:44 2014 +0100 @@ -1118,8 +1118,7 @@ assert(CompLevel_full_optimization == CompLevel_highest_tier, "incorrect level definition"); if (comp_level == CompLevel_full_optimization) { if (!JavaThread::current()->is_graal_compiling()) { - bool blockingCompilation = is_compile_blocking(method, osr_bci) || - CompilationPolicy::can_be_offloaded_to_gpu(method); + bool blockingCompilation = is_compile_blocking(method, osr_bci); GraalCompiler::instance()->compile_method(method, osr_bci, blockingCompilation); } else { // Can't enqueue this request because there would be no one to service it, so simply return. diff -r 5e55de0379d9 -r 10c4df6767c4 src/share/vm/runtime/compilationPolicy.cpp --- a/src/share/vm/runtime/compilationPolicy.cpp Thu Mar 13 17:47:44 2014 +0100 +++ b/src/share/vm/runtime/compilationPolicy.cpp Thu Mar 13 17:48:44 2014 +0100 @@ -105,8 +105,6 @@ if (m->has_compiled_code()) return false; // already compiled - if (CompilationPolicy::can_be_offloaded_to_gpu(m)) return true; - if (!can_be_compiled(m, comp_level)) return false; return !UseInterpreter || // must compile all methods @@ -161,42 +159,6 @@ return (result && can_be_compiled(m, comp_level)); } -bool CompilationPolicy::can_be_offloaded_to_gpu(methodHandle m) { -#ifdef GRAAL - if (GPUOffload && gpu::initialized_gpus() > 0) { - // Check if this method can be off-loaded to GPU. - if (m->is_synthetic()) { - // A lambda method is a synthetic method. - Symbol * klass_name = m->method_holder()->name(); - Symbol * method_name = m->name(); - { - ResourceMark rm; - if (klass_name != NULL) { - const char* javaClass = "java/"; - // Exclude java library classes - for now - if (strncmp(klass_name->as_C_string(), javaClass, strlen(javaClass))) { - if (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)) { - if (TraceGPUInteraction) { - char buf[O_BUFLEN]; - tty->print_cr("Selected lambda method %s for GPU offload", m->name_and_sig_as_C_string(buf, O_BUFLEN)); - } - 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(); diff -r 5e55de0379d9 -r 10c4df6767c4 src/share/vm/runtime/compilationPolicy.hpp --- a/src/share/vm/runtime/compilationPolicy.hpp Thu Mar 13 17:47:44 2014 +0100 +++ b/src/share/vm/runtime/compilationPolicy.hpp Thu Mar 13 17:48:44 2014 +0100 @@ -58,9 +58,6 @@ static void set_policy(CompilationPolicy* policy) { _policy = policy; } static CompilationPolicy* policy() { return _policy; } - // m is allowed to be offloaded to a gpu - static bool can_be_offloaded_to_gpu(methodHandle m); - // Profiling elapsedTimer* accumulated_time() { return &_accumulated_time; } void print_time() PRODUCT_RETURN;