|
38 | 38 | import com.oracle.graal.pointsto.reports.ReportUtils; |
39 | 39 | import com.oracle.svm.core.SubstrateOptions; |
40 | 40 | import com.oracle.svm.core.option.APIOption; |
| 41 | +import com.oracle.svm.core.option.AccumulatingLocatableMultiOptionValue; |
41 | 42 | import com.oracle.svm.core.option.BundleMember; |
42 | 43 | import com.oracle.svm.core.option.HostedOptionKey; |
43 | | -import com.oracle.svm.core.option.AccumulatingLocatableMultiOptionValue; |
44 | 44 | import com.oracle.svm.core.option.SubstrateOptionsParser; |
45 | 45 | import com.oracle.svm.core.util.InterruptImageBuilding; |
46 | 46 | import com.oracle.svm.core.util.UserError; |
@@ -214,28 +214,26 @@ public static int getActualNumberOfThreads() { |
214 | 214 | } |
215 | 215 |
|
216 | 216 | public static void setCommonPoolParallelism(OptionValues optionValues) { |
217 | | - if (NativeImageOptions.NumberOfThreads.hasBeenSet(optionValues)) { |
218 | | - /* |
219 | | - * The main thread always helps to process tasks submitted to the common pool (e.g., see |
220 | | - * ForkJoinPool#awaitTermination()), so subtract one from the number of threads. The |
221 | | - * common pool can be disabled "by setting the parallelism property to zero" (see |
222 | | - * ForkJoinPool's javadoc). |
223 | | - */ |
224 | | - int numberOfCommonPoolThreads = NativeImageOptions.NumberOfThreads.getValue(optionValues) - 1; |
225 | | - String commonPoolParallelismProperty = "java.util.concurrent.ForkJoinPool.common.parallelism"; |
226 | | - assert System.getProperty(commonPoolParallelismProperty) == null : commonPoolParallelismProperty + " already set"; |
227 | | - System.setProperty(commonPoolParallelismProperty, "" + numberOfCommonPoolThreads); |
228 | | - int actualCommonPoolParallelism = ForkJoinPool.commonPool().getParallelism(); |
229 | | - /* |
230 | | - * getParallelism() returns at least 1, even in single-threaded mode where common pool |
231 | | - * is disabled. |
232 | | - */ |
233 | | - boolean isSingleThreadedMode = numberOfCommonPoolThreads == 0 && actualCommonPoolParallelism == 1; |
234 | | - if (!isSingleThreadedMode && actualCommonPoolParallelism != numberOfCommonPoolThreads) { |
235 | | - String warning = "Failed to set parallelism of common pool (actual parallelism is %s).".formatted(actualCommonPoolParallelism); |
236 | | - assert false : warning; |
237 | | - LogUtils.warning(warning); |
238 | | - } |
| 217 | + /* |
| 218 | + * The main thread always helps to process tasks submitted to the common pool (e.g., see |
| 219 | + * ForkJoinPool#awaitTermination()), so subtract one from the number of threads. The common |
| 220 | + * pool can be disabled "by setting the parallelism property to zero" (see ForkJoinPool's |
| 221 | + * javadoc). |
| 222 | + */ |
| 223 | + int numberOfCommonPoolThreads = NativeImageOptions.NumberOfThreads.getValueOrDefault(optionValues.getMap()) - 1; |
| 224 | + String commonPoolParallelismProperty = "java.util.concurrent.ForkJoinPool.common.parallelism"; |
| 225 | + assert System.getProperty(commonPoolParallelismProperty) == null : commonPoolParallelismProperty + " already set"; |
| 226 | + System.setProperty(commonPoolParallelismProperty, "" + numberOfCommonPoolThreads); |
| 227 | + int actualCommonPoolParallelism = ForkJoinPool.commonPool().getParallelism(); |
| 228 | + /* |
| 229 | + * getParallelism() returns at least 1, even in single-threaded mode where common pool is |
| 230 | + * disabled. |
| 231 | + */ |
| 232 | + boolean isSingleThreadedMode = numberOfCommonPoolThreads == 0 && actualCommonPoolParallelism == 1; |
| 233 | + if (!isSingleThreadedMode && actualCommonPoolParallelism != numberOfCommonPoolThreads) { |
| 234 | + String warning = "Failed to set parallelism of common pool (actual parallelism is %s).".formatted(actualCommonPoolParallelism); |
| 235 | + assert false : warning; |
| 236 | + LogUtils.warning(warning); |
239 | 237 | } |
240 | 238 | } |
241 | 239 |
|
|
0 commit comments