diff --git a/varats/varats/experiments/vara/feature_weight.py b/varats/varats/experiments/vara/feature_weight.py new file mode 100644 index 000000000..0529eb0e5 --- /dev/null +++ b/varats/varats/experiments/vara/feature_weight.py @@ -0,0 +1,76 @@ +"""Implements an experiment that times the execution of all project binaries.""" +import typing as tp + +from benchbuild.extensions import compiler, run +from benchbuild.utils import actions + +from varats.data.reports.instrumentation_verifier_report import ( + InstrVerifierReport, +) +from varats.experiment.experiment_util import ( + get_default_compile_error_wrapped, + WithUnlimitedStackSize, +) +from varats.experiments.vara.feature_experiment import ( + FeatureExperiment, + RunVaRATracedWorkloads, + FeatureInstrType, +) +from varats.project.varats_project import VProject +from varats.report.report import ReportSpecification + + +class WeightRegionsCountRec(FeatureExperiment, shorthand="WAR"): + """Generates Weight report files for Recursive weight function.""" + + NAME = "WeightAnalysisRecursive" + + REPORT_SPEC = ReportSpecification(InstrVerifierReport) + + def actions_for_project( + self, project: VProject + ) -> tp.MutableSequence[actions.Step]: + """Returns the specified steps to run the project(s) specified in the + call in a fixed order.""" + + project.cflags += self.get_vara_feature_cflags(project) + + # change the featureInstrType to verify + project.cflags += self.get_vara_tracing_cflags( + FeatureInstrType.TEF, instruction_threshold=1 + ) + + project.cflags += [ + "-fvara-weight-opt=recursive", + "-01", + "-g0", + "-mllvm", + "--vara-use-phasar" + ] + + project.ldflags += self.get_vara_tracing_ldflags() + + # Add the required runtime extensions to the project(s). + project.runtime_extension = run.RuntimeExtension(project, self) + + # Add the required compiler extensions to the project(s). + project.compiler_extension = compiler.RunCompiler(project, self) \ + << WithUnlimitedStackSize() + + + project.compile = get_default_compile_error_wrapped( + self.get_handle(), project, self.REPORT_SPEC.main_report + ) + + analysis_actions = [] + analysis_actions.append(actions.Compile(project)) + + analysis_actions.append(actions.Compile(project)) + analysis_actions.append( + RunVaRATracedWorkloads( + project, self.get_handle(), report_file_ending="ivr" + ) + ) + analysis_actions.append(actions.Clean(project)) + + return analysis_actions diff --git a/varats/varats/experiments/vara/feature_weight_default.py b/varats/varats/experiments/vara/feature_weight_default.py new file mode 100644 index 000000000..b23da26f0 --- /dev/null +++ b/varats/varats/experiments/vara/feature_weight_default.py @@ -0,0 +1,76 @@ +"""Implements an experiment that times the execution of all project binaries.""" +import typing as tp + +from benchbuild.extensions import compiler, run +from benchbuild.utils import actions + +from varats.data.reports.instrumentation_verifier_report import ( + InstrVerifierReport, +) +from varats.experiment.experiment_util import ( + get_default_compile_error_wrapped, + WithUnlimitedStackSize, +) +from varats.experiments.vara.feature_experiment import ( + FeatureExperiment, + RunVaRATracedWorkloads, + FeatureInstrType, +) +from varats.project.varats_project import VProject +from varats.report.report import ReportSpecification + + +class WeightRegionsCountDef(FeatureExperiment, shorthand="WAD"): + """Generates Weight report files for Default recursive function.""" + + NAME = "WeightAnalysisDefault" + + REPORT_SPEC = ReportSpecification(InstrVerifierReport) + + def actions_for_project( + self, project: VProject + ) -> tp.MutableSequence[actions.Step]: + """Returns the specified steps to run the project(s) specified in the + call in a fixed order.""" + + project.cflags += self.get_vara_feature_cflags(project) + + # change the featureInstrType to verify + project.cflags += self.get_vara_tracing_cflags( + FeatureInstrType.TEF, instruction_threshold=1 + ) + + project.cflags += [ + "-fvara-weight-opt=default", + "-01", + "-g0", + "-mllvm", + "--vara-use-phasar" + ] + + project.ldflags += self.get_vara_tracing_ldflags() + + # Add the required runtime extensions to the project(s). + project.runtime_extension = run.RuntimeExtension(project, self) + + # Add the required compiler extensions to the project(s). + project.compiler_extension = compiler.RunCompiler(project, self) \ + << WithUnlimitedStackSize() + + + project.compile = get_default_compile_error_wrapped( + self.get_handle(), project, self.REPORT_SPEC.main_report + ) + + analysis_actions = [] + analysis_actions.append(actions.Compile(project)) + + analysis_actions.append(actions.Compile(project)) + analysis_actions.append( + RunVaRATracedWorkloads( + project, self.get_handle(), report_file_ending="ivr" + ) + ) + analysis_actions.append(actions.Clean(project)) + + return analysis_actions diff --git a/varats/varats/projects/perf_tests/feature_perf_cs_collection.py b/varats/varats/projects/perf_tests/feature_perf_cs_collection.py index 07e1fadb0..d41215218 100644 --- a/varats/varats/projects/perf_tests/feature_perf_cs_collection.py +++ b/varats/varats/projects/perf_tests/feature_perf_cs_collection.py @@ -231,6 +231,235 @@ def recompile(self) -> None: _do_feature_perf_cs_collection_recompile(self) +# Create SimpleCall Project +class LongerCallee(VProject): + """Main Class longer than function called.""" + + NAME = 'LongerCallee' + GROUP = 'perf_tests' + DOMAIN = ProjectDomains.TEST + + SOURCE = [ + bb.source.Git( + remote="https://github.com/se-sic/FeaturePerfCSCollection.git", + local=NAME, + refspec="origin/f-calculatedynamicweight", + limit=None, + shallow=False, + version_filter=project_filter_generator(NAME) + ), + FeatureSource() + ] + + WORKLOADS = { + WorkloadSet(WorkloadCategory.EXAMPLE): [ + VCommand( + SourceRoot(NAME) / RSBinary("LongerCallee"), label="CompileTime-LongerCallee" + ) + ] + } + + @staticmethod + def binaries_for_revision( + revision: ShortCommitHash # pylint: disable=W0613 + ) -> tp.List[ProjectBinaryWrapper]: + binary_map = RevisionBinaryMap( + get_local_project_git_path(SimpleCall.NAME) + ) + binary_map.specify_binary( + "build/bin/LongerCallee", + BinaryType.EXECUTABLE, + only_valid_in=RevisionRange("0214ccd4cebac656449ce232a69e3b385d5e63e9", "0214ccd4cebac656449ce232a69e3b385d5e63e9") #check the hash commit number on f-CalcualteDynamicWeight branch + ) + + return binary_map[revision] + + def run_tests(self) -> None: + pass + + def compile(self) -> None: + """Compile the project.""" + _do_feature_perf_cs_collection_compile( + self, "FPCSC_ENABLE_PROJECT_LONGERCALLEE" + ) + + def recompile(self) -> None: + """Recompile the project.""" + _do_feature_perf_cs_collection_recompile(self) + + + +class LongerCaller(VProject): + """Main Class longer than function called.""" + + NAME = 'LongerCaller' + GROUP = 'perf_tests' + DOMAIN = ProjectDomains.TEST + + SOURCE = [ + bb.source.Git( + remote="https://github.com/se-sic/FeaturePerfCSCollection.git", + local=NAME, + refspec="origin/f-calculatedynamicweight", + limit=None, + shallow=False, + version_filter=project_filter_generator(NAME) + ), + FeatureSource() + ] + + WORKLOADS = { + WorkloadSet(WorkloadCategory.EXAMPLE): [ + VCommand( + SourceRoot(NAME) / RSBinary("LongerCaller"), label="CompileTime-LongerCaller" + ) + ] + } + + @staticmethod + def binaries_for_revision( + revision: ShortCommitHash # pylint: disable=W0613 + ) -> tp.List[ProjectBinaryWrapper]: + binary_map = RevisionBinaryMap( + get_local_project_git_path(SimpleCall.NAME) + ) + binary_map.specify_binary( + "build/bin/LongerCaller", + BinaryType.EXECUTABLE, + only_valid_in=RevisionRange("0214ccd4cebac656449ce232a69e3b385d5e63e9", "0214ccd4cebac656449ce232a69e3b385d5e63e9") #check the hash commit number on f-CalcualteDynamicWeight branch + ) + + return binary_map[revision] + + def run_tests(self) -> None: + pass + + def compile(self) -> None: + """Compile the project.""" + _do_feature_perf_cs_collection_compile( + self, "FPCSC_ENABLE_PROJECT_LONGERCALLER" + ) + + def recompile(self) -> None: + """Recompile the project.""" + _do_feature_perf_cs_collection_recompile(self) + + + +class SimpleCall(VProject): + """Main Class longer than function called.""" + + NAME = 'SimpleCall' + GROUP = 'perf_tests' + DOMAIN = ProjectDomains.TEST + + SOURCE = [ + bb.source.Git( + remote="https://github.com/se-sic/FeaturePerfCSCollection.git", + local=NAME, + refspec="origin/f-calculatedynamicweight", + limit=None, + shallow=False, + version_filter=project_filter_generator(NAME) + ), + FeatureSource() + ] + + WORKLOADS = { + WorkloadSet(WorkloadCategory.EXAMPLE): [ + VCommand( + SourceRoot(NAME) / RSBinary("SimpleCall"), label="CompileTime-SimpleCall" + ) + ] + } + + @staticmethod + def binaries_for_revision( + revision: ShortCommitHash # pylint: disable=W0613 + ) -> tp.List[ProjectBinaryWrapper]: + binary_map = RevisionBinaryMap( + get_local_project_git_path(SimpleCall.NAME) + ) + binary_map.specify_binary( + "build/bin/SimpleCall", + BinaryType.EXECUTABLE, + only_valid_in=RevisionRange("0214ccd4cebac656449ce232a69e3b385d5e63e9", "0214ccd4cebac656449ce232a69e3b385d5e63e9") #check the hash commit number on f-CalcualteDynamicWeight branch + ) + + return binary_map[revision] + + def run_tests(self) -> None: + pass + + def compile(self) -> None: + """Compile the project.""" + _do_feature_perf_cs_collection_compile( + self, "FPCSC_ENABLE_PROJECT_SIMPLECALL" + ) + + def recompile(self) -> None: + """Recompile the project.""" + _do_feature_perf_cs_collection_recompile(self) + + + +class RecursiveCalls(VProject): + """Main Class longer than function called.""" + + NAME = 'RecursiveCalls' + GROUP = 'perf_tests' + DOMAIN = ProjectDomains.TEST + + SOURCE = [ + bb.source.Git( + remote="https://github.com/se-sic/FeaturePerfCSCollection.git", + local=NAME, + refspec="origin/f-calculatedynamicweight", + limit=None, + shallow=False, + version_filter=project_filter_generator(NAME) + ), + FeatureSource() + ] + + WORKLOADS = { + WorkloadSet(WorkloadCategory.EXAMPLE): [ + VCommand( + SourceRoot(NAME) / RSBinary("RecursiveCalls"), label="CompileTime-RecursiveCalls" + ) + ] + } + + @staticmethod + def binaries_for_revision( + revision: ShortCommitHash # pylint: disable=W0613 + ) -> tp.List[ProjectBinaryWrapper]: + binary_map = RevisionBinaryMap( + get_local_project_git_path(SimpleCall.NAME) + ) + binary_map.specify_binary( + "build/bin/RecursiveCalls", + BinaryType.EXECUTABLE, + only_valid_in=RevisionRange("0214ccd4cebac656449ce232a69e3b385d5e63e9", "0214ccd4cebac656449ce232a69e3b385d5e63e9") #check the hash commit number on f-CalcualteDynamicWeight branch + ) + + return binary_map[revision] + + def run_tests(self) -> None: + pass + + def compile(self) -> None: + """Compile the project.""" + _do_feature_perf_cs_collection_compile( + self, "FPCSC_ENABLE_PROJECT_RECURSIVECALLS" + ) + + def recompile(self) -> None: + """Recompile the project.""" + _do_feature_perf_cs_collection_recompile(self) + + + class SynthSAContextSensitivity(VProject): """Synthetic case-study project for testing flow sensitivity."""