Mercurial > hg > truffle
comparison 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 |
comparison
equal
deleted
inserted
replaced
13730:168976cae9ce | 13731:9161ed8ce796 |
---|---|
103 // Don't allow Xcomp to cause compiles in replay mode | 103 // Don't allow Xcomp to cause compiles in replay mode |
104 if (ReplayCompiles) return false; | 104 if (ReplayCompiles) return false; |
105 | 105 |
106 if (m->has_compiled_code()) return false; // already compiled | 106 if (m->has_compiled_code()) return false; // already compiled |
107 | 107 |
108 #ifdef GRAAL | 108 if (CompilationPolicy::can_be_offloaded_to_gpu(m)) return true; |
109 // Check if this is a Lambda method that can be compiled to a GPU. | |
110 if (m->is_lambda()) { | |
111 // If GPU is available and the necessary linkage is available | |
112 // rerurn true indicatin that this method must be compiled. | |
113 if (gpu::is_available() && gpu::has_gpu_linkage()) { | |
114 if (TraceGPUInteraction) { | |
115 tty->print("Compiling Lambda method"); | |
116 m->print_short_name(); | |
117 switch (gpu::get_target_il_type()) { | |
118 case gpu::PTX : | |
119 tty->print_cr(" to PTX"); | |
120 break; | |
121 case gpu::HSAIL : | |
122 tty->print_cr(" to HSAIL"); | |
123 break; | |
124 default : | |
125 tty->print_cr(" to Unknown GPU!!!"); | |
126 } | |
127 } | |
128 return true; | |
129 } | |
130 } | |
131 #endif | |
132 | 109 |
133 if (!can_be_compiled(m, comp_level)) return false; | 110 if (!can_be_compiled(m, comp_level)) return false; |
134 | 111 |
135 return !UseInterpreter || // must compile all methods | 112 return !UseInterpreter || // must compile all methods |
136 (UseCompiler && AlwaysCompileLoopMethods && m->has_loops() && CompileBroker::should_compile_new_jobs()); // eagerly compile loop methods | 113 (UseCompiler && AlwaysCompileLoopMethods && m->has_loops() && CompileBroker::should_compile_new_jobs()); // eagerly compile loop methods |
180 } | 157 } |
181 } else if (is_compile(comp_level)) { | 158 } else if (is_compile(comp_level)) { |
182 result = !m->is_not_osr_compilable(comp_level); | 159 result = !m->is_not_osr_compilable(comp_level); |
183 } | 160 } |
184 return (result && can_be_compiled(m, comp_level)); | 161 return (result && can_be_compiled(m, comp_level)); |
162 } | |
163 | |
164 bool CompilationPolicy::can_be_offloaded_to_gpu(methodHandle m) { | |
165 #ifdef GRAAL | |
166 if (GPUOffload) { | |
167 // Check if this method can be offloaded to GPU. | |
168 // 1. Offload it to GPU if it is a Lambda method | |
169 if (m->is_synthetic()) { | |
170 // A lambda method is a syntheric method. | |
171 Symbol * klass_name = m->method_holder()->name(); | |
172 Symbol * method_name = m->name(); | |
173 bool offloadToGPU = false; | |
174 { | |
175 ResourceMark rm; | |
176 if (klass_name != NULL) { | |
177 if (klass_name != NULL && method_name != NULL) { | |
178 const char* lambdaPrefix = "lambda$"; | |
179 char* methodPrefix = strstr(method_name->as_C_string(), lambdaPrefix); | |
180 if (methodPrefix != 0) { | |
181 if ((strncmp(lambdaPrefix, methodPrefix, strlen(lambdaPrefix)) == 0)) { | |
182 offloadToGPU = true; | |
183 } | |
184 } | |
185 } | |
186 } | |
187 } | |
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 } | |
210 } | |
211 #endif | |
212 | |
213 return false; | |
185 } | 214 } |
186 | 215 |
187 bool CompilationPolicy::is_compilation_enabled() { | 216 bool CompilationPolicy::is_compilation_enabled() { |
188 // NOTE: CompileBroker::should_compile_new_jobs() checks for UseCompiler | 217 // NOTE: CompileBroker::should_compile_new_jobs() checks for UseCompiler |
189 return !delay_compilation_during_startup() && CompileBroker::should_compile_new_jobs(); | 218 return !delay_compilation_during_startup() && CompileBroker::should_compile_new_jobs(); |