|
72 | 72 | import mx_sdk_vm_impl |
73 | 73 | import mx_util |
74 | 74 | from mx_util import Stage, StageName, Layer |
75 | | -from mx_benchmark import DataPoints, DataPoint, BenchmarkSuite, Vm, SingleBenchmarkExecutionContext, ForkInfo |
| 75 | +from mx_benchmark import DataPoints, DataPoint, BenchmarkSuite, bm_exec_context, ConstantContextValueManager, SingleBenchmarkManager |
76 | 76 | from mx_sdk_vm_impl import svm_experimental_options |
77 | 77 |
|
78 | 78 | _suite = mx.suite('sdk') |
@@ -1786,7 +1786,7 @@ def get_layer_aware_build_args(self) -> List[str]: |
1786 | 1786 |
|
1787 | 1787 | def run_stage_image(self): |
1788 | 1788 | executable_name_args = ['-o', self.config.final_image_name] |
1789 | | - pgo_args = [f"--pgo={self.config.profile_path}"] |
| 1789 | + pgo_args = [f"--pgo={self.config.bm_suite.get_pgo_profile_for_image_build(self.config.profile_path)}"] |
1790 | 1790 | if self.pgo_use_perf: |
1791 | 1791 | # -g is already set in base_image_build_args if we're not using perf. When using perf, if debug symbols |
1792 | 1792 | # are present they will interfere with sample decoding using source mappings. |
@@ -1946,8 +1946,8 @@ def _prepare_for_running(self, args, out, err, cwd, nonZeroIsFatal): |
1946 | 1946 | self.stages_context = StagesContext(self, out, err, nonZeroIsFatal, os.path.abspath(cwd if cwd else os.getcwd())) |
1947 | 1947 | file_name = f"staged-benchmark.{self.ext}" |
1948 | 1948 | output_dir = self.bmSuite.get_image_output_dir( |
1949 | | - self.bmSuite.benchmark_output_dir(self.bmSuite.execution_context.benchmark, args), |
1950 | | - self.bmSuite.get_full_image_name(self.bmSuite.get_base_image_name(), self.bmSuite.execution_context.virtual_machine.config_name()) |
| 1949 | + self.bmSuite.benchmark_output_dir(bm_exec_context().get("benchmark"), args), |
| 1950 | + self.bmSuite.get_full_image_name(self.bmSuite.get_base_image_name(), bm_exec_context().get("vm").config_name()) |
1951 | 1951 | ) |
1952 | 1952 | self.staged_program_file_path = output_dir / file_name |
1953 | 1953 | self.staged_program_file_path.parent.mkdir(parents=True, exist_ok=True) |
@@ -3178,7 +3178,7 @@ def subgroup(self): |
3178 | 3178 | return "graal-compiler" |
3179 | 3179 |
|
3180 | 3180 | def benchmarkName(self): |
3181 | | - return self.execution_context.benchmark |
| 3181 | + return bm_exec_context().get("benchmark") |
3182 | 3182 |
|
3183 | 3183 | def benchmarkList(self, bmSuiteArgs): |
3184 | 3184 | exclude = [] |
@@ -3226,8 +3226,9 @@ def validateEnvironment(self): |
3226 | 3226 | self.baristaProjectConfigurationPath() |
3227 | 3227 | self.baristaHarnessPath() |
3228 | 3228 |
|
3229 | | - def new_execution_context(self, vm: Optional[Vm], benchmarks: List[str], bmSuiteArgs: List[str], fork_info: Optional[ForkInfo] = None) -> SingleBenchmarkExecutionContext: |
3230 | | - return SingleBenchmarkExecutionContext(self, vm, benchmarks, bmSuiteArgs, fork_info) |
| 3229 | + def run(self, benchmarks, bmSuiteArgs) -> DataPoints: |
| 3230 | + with SingleBenchmarkManager(self): |
| 3231 | + return super().run(benchmarks, bmSuiteArgs) |
3231 | 3232 |
|
3232 | 3233 | def createCommandLineArgs(self, benchmarks, bmSuiteArgs): |
3233 | 3234 | # Pass the VM options, BaristaCommand will form the final command. |
@@ -3490,7 +3491,7 @@ def produceHarnessCommand(self, cmd, suite): |
3490 | 3491 | jvm_vm_options = jvm_cmd[index_of_java_exe + 1:] |
3491 | 3492 |
|
3492 | 3493 | # Verify that the run arguments don't already contain a "--mode" option |
3493 | | - run_args = suite.runArgs(suite.execution_context.bmSuiteArgs) + self._energyTrackerExtraOptions(suite) |
| 3494 | + run_args = suite.runArgs(bm_exec_context().get("bm_suite_args")) + self._energyTrackerExtraOptions(suite) |
3494 | 3495 | mode_pattern = r"^(?:-m|--mode)(=.*)?$" |
3495 | 3496 | mode_match = self._regexFindInCommand(run_args, mode_pattern) |
3496 | 3497 | if mode_match: |
@@ -4128,7 +4129,7 @@ def intercept_run(self, super_delegate: BenchmarkSuite, benchmarks, bm_suite_arg |
4128 | 4129 | datapoints: List[DataPoint] = [] |
4129 | 4130 |
|
4130 | 4131 | vm = self.get_vm_registry().get_vm_from_suite_args(bm_suite_args) |
4131 | | - with self.new_execution_context(vm, benchmarks, bm_suite_args): |
| 4132 | + with ConstantContextValueManager("vm", vm): |
4132 | 4133 | effective_stages, complete_stage_list = vm.prepare_stages(self, bm_suite_args) |
4133 | 4134 | self.stages_info = StagesInfo(effective_stages, complete_stage_list, vm) |
4134 | 4135 |
|
@@ -4261,7 +4262,7 @@ def run(self, benchmarks, bm_suite_args: List[str]) -> DataPoints: |
4261 | 4262 | fallback_reason = self.fallback_mode_reason(bm_suite_args) |
4262 | 4263 |
|
4263 | 4264 | vm = self.get_vm_registry().get_vm_from_suite_args(bm_suite_args) |
4264 | | - with self.new_execution_context(vm, benchmarks, bm_suite_args): |
| 4265 | + with ConstantContextValueManager("vm", vm): |
4265 | 4266 | effective_stages, complete_stage_list = vm.prepare_stages(self, bm_suite_args) |
4266 | 4267 | self.stages_info = StagesInfo(effective_stages, complete_stage_list, vm, bool(fallback_reason)) |
4267 | 4268 |
|
@@ -4502,6 +4503,13 @@ def get_image_output_dir(self, benchmark_output_dir: str, full_image_name: str) |
4502 | 4503 | """ |
4503 | 4504 | return Path(benchmark_output_dir).absolute() / "native-image-benchmarks" / full_image_name |
4504 | 4505 |
|
| 4506 | + def get_pgo_profile_for_image_build(self, default_pgo_profile: str) -> str: |
| 4507 | + vm_args = self.vmArgs(bm_exec_context().get("bm_suite_args")) |
| 4508 | + parsed_arg = parse_prefixed_arg("-Dnative-image.benchmark.pgo=", vm_args, "Native Image benchmark PGO profiles should only be specified once!") |
| 4509 | + if not parsed_arg: |
| 4510 | + return default_pgo_profile |
| 4511 | + return parsed_arg |
| 4512 | + |
4505 | 4513 |
|
4506 | 4514 | def measureTimeToFirstResponse(bmSuite): |
4507 | 4515 | protocolHost = bmSuite.serviceHost() |
|
0 commit comments