Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Recursive Function (Region counting) #895

Draft
wants to merge 15 commits into
base: vara-dev
Choose a base branch
from
76 changes: 76 additions & 0 deletions varats/varats/experiments/vara/feature_weight.py
Original file line number Diff line number Diff line change
@@ -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
76 changes: 76 additions & 0 deletions varats/varats/experiments/vara/feature_weight_default.py
Original file line number Diff line number Diff line change
@@ -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
229 changes: 229 additions & 0 deletions varats/varats/projects/perf_tests/feature_perf_cs_collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,235 @@
_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"
)

Check failure on line 258 in varats/varats/projects/perf_tests/feature_perf_cs_collection.py

View workflow job for this annotation

GitHub Actions / pylint

[pylint] varats/varats/projects/perf_tests/feature_perf_cs_collection.py#L258 <301>

Line too long (93/80) (line-too-long)
Raw output
varats/varats/projects/perf_tests/feature_perf_cs_collection.py:258:0: C0301: Line too long (93/80) (line-too-long)
]
}

@staticmethod
def binaries_for_revision(
revision: ShortCommitHash # pylint: disable=W0613
) -> tp.List[ProjectBinaryWrapper]:
binary_map = RevisionBinaryMap(
get_local_project_git_path(SimpleCall.NAME)
)

Check failure on line 268 in varats/varats/projects/perf_tests/feature_perf_cs_collection.py

View workflow job for this annotation

GitHub Actions / mypy

[mypy] varats/varats/projects/perf_tests/feature_perf_cs_collection.py#L268

error: Name "get_local_project_git_path" is not defined [name-defined]
Raw output
varats/varats/projects/perf_tests/feature_perf_cs_collection.py:268:13: error: Name "get_local_project_git_path" is not defined  [name-defined]

Check failure on line 268 in varats/varats/projects/perf_tests/feature_perf_cs_collection.py

View workflow job for this annotation

GitHub Actions / pylint

[pylint] varats/varats/projects/perf_tests/feature_perf_cs_collection.py#L268 <602>

Undefined variable 'get_local_project_git_path' (undefined-variable)
Raw output
varats/varats/projects/perf_tests/feature_perf_cs_collection.py:268:12: E0602: Undefined variable 'get_local_project_git_path' (undefined-variable)
binary_map.specify_binary(
"build/bin/LongerCallee",
BinaryType.EXECUTABLE,
only_valid_in=RevisionRange("0214ccd4cebac656449ce232a69e3b385d5e63e9", "0214ccd4cebac656449ce232a69e3b385d5e63e9") #check the hash commit number on f-CalcualteDynamicWeight branch
)

Check failure on line 273 in varats/varats/projects/perf_tests/feature_perf_cs_collection.py

View workflow job for this annotation

GitHub Actions / pylint

[pylint] varats/varats/projects/perf_tests/feature_perf_cs_collection.py#L273 <301>

Line too long (192/80) (line-too-long)
Raw output
varats/varats/projects/perf_tests/feature_perf_cs_collection.py:273:0: C0301: Line too long (192/80) (line-too-long)

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"
)

Check failure on line 315 in varats/varats/projects/perf_tests/feature_perf_cs_collection.py

View workflow job for this annotation

GitHub Actions / pylint

[pylint] varats/varats/projects/perf_tests/feature_perf_cs_collection.py#L315 <301>

Line too long (93/80) (line-too-long)
Raw output
varats/varats/projects/perf_tests/feature_perf_cs_collection.py:315:0: C0301: Line too long (93/80) (line-too-long)
]
}

@staticmethod
def binaries_for_revision(
revision: ShortCommitHash # pylint: disable=W0613
) -> tp.List[ProjectBinaryWrapper]:
binary_map = RevisionBinaryMap(
get_local_project_git_path(SimpleCall.NAME)
)

Check failure on line 325 in varats/varats/projects/perf_tests/feature_perf_cs_collection.py

View workflow job for this annotation

GitHub Actions / mypy

[mypy] varats/varats/projects/perf_tests/feature_perf_cs_collection.py#L325

error: Name "get_local_project_git_path" is not defined [name-defined]
Raw output
varats/varats/projects/perf_tests/feature_perf_cs_collection.py:325:13: error: Name "get_local_project_git_path" is not defined  [name-defined]

Check failure on line 325 in varats/varats/projects/perf_tests/feature_perf_cs_collection.py

View workflow job for this annotation

GitHub Actions / pylint

[pylint] varats/varats/projects/perf_tests/feature_perf_cs_collection.py#L325 <602>

Undefined variable 'get_local_project_git_path' (undefined-variable)
Raw output
varats/varats/projects/perf_tests/feature_perf_cs_collection.py:325:12: E0602: Undefined variable 'get_local_project_git_path' (undefined-variable)
binary_map.specify_binary(
"build/bin/LongerCaller",
BinaryType.EXECUTABLE,
only_valid_in=RevisionRange("0214ccd4cebac656449ce232a69e3b385d5e63e9", "0214ccd4cebac656449ce232a69e3b385d5e63e9") #check the hash commit number on f-CalcualteDynamicWeight branch
)

Check failure on line 330 in varats/varats/projects/perf_tests/feature_perf_cs_collection.py

View workflow job for this annotation

GitHub Actions / pylint

[pylint] varats/varats/projects/perf_tests/feature_perf_cs_collection.py#L330 <301>

Line too long (192/80) (line-too-long)
Raw output
varats/varats/projects/perf_tests/feature_perf_cs_collection.py:330:0: C0301: Line too long (192/80) (line-too-long)

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"
)

Check failure on line 372 in varats/varats/projects/perf_tests/feature_perf_cs_collection.py

View workflow job for this annotation

GitHub Actions / pylint

[pylint] varats/varats/projects/perf_tests/feature_perf_cs_collection.py#L372 <301>

Line too long (89/80) (line-too-long)
Raw output
varats/varats/projects/perf_tests/feature_perf_cs_collection.py:372:0: C0301: Line too long (89/80) (line-too-long)
]
}

@staticmethod
def binaries_for_revision(
revision: ShortCommitHash # pylint: disable=W0613
) -> tp.List[ProjectBinaryWrapper]:
binary_map = RevisionBinaryMap(
get_local_project_git_path(SimpleCall.NAME)
)

Check failure on line 382 in varats/varats/projects/perf_tests/feature_perf_cs_collection.py

View workflow job for this annotation

GitHub Actions / mypy

[mypy] varats/varats/projects/perf_tests/feature_perf_cs_collection.py#L382

error: Name "get_local_project_git_path" is not defined [name-defined]
Raw output
varats/varats/projects/perf_tests/feature_perf_cs_collection.py:382:13: error: Name "get_local_project_git_path" is not defined  [name-defined]

Check failure on line 382 in varats/varats/projects/perf_tests/feature_perf_cs_collection.py

View workflow job for this annotation

GitHub Actions / pylint

[pylint] varats/varats/projects/perf_tests/feature_perf_cs_collection.py#L382 <602>

Undefined variable 'get_local_project_git_path' (undefined-variable)
Raw output
varats/varats/projects/perf_tests/feature_perf_cs_collection.py:382:12: E0602: Undefined variable 'get_local_project_git_path' (undefined-variable)
binary_map.specify_binary(
"build/bin/SimpleCall",
BinaryType.EXECUTABLE,
only_valid_in=RevisionRange("0214ccd4cebac656449ce232a69e3b385d5e63e9", "0214ccd4cebac656449ce232a69e3b385d5e63e9") #check the hash commit number on f-CalcualteDynamicWeight branch
)

Check failure on line 387 in varats/varats/projects/perf_tests/feature_perf_cs_collection.py

View workflow job for this annotation

GitHub Actions / pylint

[pylint] varats/varats/projects/perf_tests/feature_perf_cs_collection.py#L387 <301>

Line too long (192/80) (line-too-long)
Raw output
varats/varats/projects/perf_tests/feature_perf_cs_collection.py:387:0: C0301: Line too long (192/80) (line-too-long)

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"
)

Check failure on line 429 in varats/varats/projects/perf_tests/feature_perf_cs_collection.py

View workflow job for this annotation

GitHub Actions / pylint

[pylint] varats/varats/projects/perf_tests/feature_perf_cs_collection.py#L429 <301>

Line too long (97/80) (line-too-long)
Raw output
varats/varats/projects/perf_tests/feature_perf_cs_collection.py:429:0: C0301: Line too long (97/80) (line-too-long)
]
}

@staticmethod
def binaries_for_revision(
revision: ShortCommitHash # pylint: disable=W0613
) -> tp.List[ProjectBinaryWrapper]:
binary_map = RevisionBinaryMap(
get_local_project_git_path(SimpleCall.NAME)
)

Check failure on line 439 in varats/varats/projects/perf_tests/feature_perf_cs_collection.py

View workflow job for this annotation

GitHub Actions / mypy

[mypy] varats/varats/projects/perf_tests/feature_perf_cs_collection.py#L439

error: Name "get_local_project_git_path" is not defined [name-defined]
Raw output
varats/varats/projects/perf_tests/feature_perf_cs_collection.py:439:13: error: Name "get_local_project_git_path" is not defined  [name-defined]

Check failure on line 439 in varats/varats/projects/perf_tests/feature_perf_cs_collection.py

View workflow job for this annotation

GitHub Actions / pylint

[pylint] varats/varats/projects/perf_tests/feature_perf_cs_collection.py#L439 <602>

Undefined variable 'get_local_project_git_path' (undefined-variable)
Raw output
varats/varats/projects/perf_tests/feature_perf_cs_collection.py:439:12: E0602: Undefined variable 'get_local_project_git_path' (undefined-variable)
binary_map.specify_binary(
"build/bin/RecursiveCalls",
BinaryType.EXECUTABLE,
only_valid_in=RevisionRange("0214ccd4cebac656449ce232a69e3b385d5e63e9", "0214ccd4cebac656449ce232a69e3b385d5e63e9") #check the hash commit number on f-CalcualteDynamicWeight branch
)

Check failure on line 444 in varats/varats/projects/perf_tests/feature_perf_cs_collection.py

View workflow job for this annotation

GitHub Actions / pylint

[pylint] varats/varats/projects/perf_tests/feature_perf_cs_collection.py#L444 <301>

Line too long (192/80) (line-too-long)
Raw output
varats/varats/projects/perf_tests/feature_perf_cs_collection.py:444:0: C0301: Line too long (192/80) (line-too-long)

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."""

Expand Down
Loading