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

Adds a BC file extension for Architecture, a bare-bones MDReport, an ArchitectureAnalysis experiment and "SynthSAWholeProgram" as a project #878

Draft
wants to merge 10 commits into
base: vara-dev
Choose a base branch
from
1 change: 1 addition & 0 deletions varats-core/varats/experiment/wllvm.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ class BCFileExtensions(Enum):
TBAA = "TBAA"
FEATURE = 'feature'
BLAME = "blame"
ARCH = "fvara-arch"
s8jsweis marked this conversation as resolved.
Show resolved Hide resolved

def __lt__(self, other: tp.Any) -> bool:
if isinstance(other, BCFileExtensions):
Expand Down
11 changes: 11 additions & 0 deletions varats/varats/data/reports/md_report.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
"""Metadata report implementation."""

from varats.report.report import BaseReport


class MDReport(BaseReport, shorthand="MD", file_type="txt"):
s8jsweis marked this conversation as resolved.
Show resolved Hide resolved
"""
An Metadata report which serves as a base class for the Architecture report.
"""

# TODO Implement the MDReport class.

Check warning on line 11 in varats/varats/data/reports/md_report.py

View workflow job for this annotation

GitHub Actions / pylint

[pylint] varats/varats/data/reports/md_report.py#L11 <511>

TODO Implement the MDReport class. (fixme)
Raw output
varats/varats/data/reports/md_report.py:11:5: W0511: TODO Implement the MDReport class. (fixme)
112 changes: 112 additions & 0 deletions varats/varats/experiments/vara/architecture_report_experiment.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
"""Implements an empty experiment that just compiles the project."""

import typing as tp

from benchbuild import Project
from benchbuild.extensions import compiler, run, time
from benchbuild.utils import actions
from benchbuild.utils.cmd import touch

Check warning on line 8 in varats/varats/experiments/vara/architecture_report_experiment.py

View workflow job for this annotation

GitHub Actions / pylint

[pylint] varats/varats/experiments/vara/architecture_report_experiment.py#L8 <611>

Unused touch imported from benchbuild.utils.cmd (unused-import)
Raw output
varats/varats/experiments/vara/architecture_report_experiment.py:8:0: W0611: Unused touch imported from benchbuild.utils.cmd (unused-import)
s8jsweis marked this conversation as resolved.
Show resolved Hide resolved

from varats.data.reports.md_report import MDReport
from varats.experiment.experiment_util import (
VersionExperiment,
ExperimentHandle,
exec_func_with_pe_error_handler,
get_default_compile_error_wrapped,
create_default_analysis_failure_handler,
create_new_success_result_filepath,
)
from varats.experiment.wllvm import RunWLLVM
from varats.project.varats_project import VProject
from varats.report.report import ReportSpecification
from varats.utils.config import get_current_config_id


class ArchitectureAnalysis(actions.ProjectStep): # type: ignore
"""Analyses a project's architecture with VaRA and generates a report."""

NAME = "ArchitectureAnalysis"
DESCRIPTION = "Analyses the bitcode with -vara-arch of VaRA."

project: VProject

def __init__(self, project: Project, experiment_handle: ExperimentHandle):
super().__init__(project=project)
self.__experiment_handle = experiment_handle

def __call__(self) -> actions.StepResult:
return self.analyze()

def analyze(self) -> actions.StepResult:

Check failure on line 40 in varats/varats/experiments/vara/architecture_report_experiment.py

View workflow job for this annotation

GitHub Actions / pylint

[pylint] varats/varats/experiments/vara/architecture_report_experiment.py#L40 <116>

Missing function or method docstring (missing-function-docstring)
Raw output
varats/varats/experiments/vara/architecture_report_experiment.py:40:4: C0116: Missing function or method docstring (missing-function-docstring)
s8jsweis marked this conversation as resolved.
Show resolved Hide resolved
#

config_id = get_current_config_id(self.project)

for binary in self.project.binaries:
result_file = create_new_success_result_filepath(
self.__experiment_handle,
MDReport,
self.project, binary,
config_id
)

opt_params = [
"-O0", "-g0", "-fvara-GB",
"-S", "-fvara-arch",
f"-vara-report-outfile={result_file}",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You mixed two things here: clang options and opt options.
In this analysis step, you want to produce a report by running a certain VaRA analysis.
This works similar to the BlameReportGeneration step and requires opt.
The flags "-O0", "-g0", "-fvara-GB", "-fvara-arch" are all compiler flags which have to be passed to clang.
You have to set them before you add the Compile step (see comment below).

As far as opt parameters go, you have to pass --enable-new-pm=0, f"-vara-report-outfile={result_file}" and an option that enables the analysis pass. However, you have to implement that pass on the VaRA side first.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have we already discussed how to go about implementing the pass on VaRA’s side? Or shall I look into this myself?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we have briefly talked about how that works in general, but no details yet.
You can take a look at existing passes to figure out how a pass for creating an ArchitectureReport could look like, e.g., BlameReportCreatorPass in vara/Report/BlameReport.h.

get_cached_bc_file_path(

Check failure on line 57 in varats/varats/experiments/vara/architecture_report_experiment.py

View workflow job for this annotation

GitHub Actions / mypy

[mypy] varats/varats/experiments/vara/architecture_report_experiment.py#L57

error: Name "get_cached_bc_file_path" is not defined [name-defined]
Raw output
varats/varats/experiments/vara/architecture_report_experiment.py:57:17: error: Name "get_cached_bc_file_path" is not defined  [name-defined]

Check failure on line 57 in varats/varats/experiments/vara/architecture_report_experiment.py

View workflow job for this annotation

GitHub Actions / pylint

[pylint] varats/varats/experiments/vara/architecture_report_experiment.py#L57 <602>

Undefined variable 'get_cached_bc_file_path' (undefined-variable)
Raw output
varats/varats/experiments/vara/architecture_report_experiment.py:57:16: E0602: Undefined variable 'get_cached_bc_file_path' (undefined-variable)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Import this from wllvm.py. Same goes for the BCFileExtensions.

self.project, binary, [
BCFileExtensions.NO_OPT,

Check failure on line 59 in varats/varats/experiments/vara/architecture_report_experiment.py

View workflow job for this annotation

GitHub Actions / mypy

[mypy] varats/varats/experiments/vara/architecture_report_experiment.py#L59

error: Name "BCFileExtensions" is not defined [name-defined]
Raw output
varats/varats/experiments/vara/architecture_report_experiment.py:59:25: error: Name "BCFileExtensions" is not defined  [name-defined]

Check failure on line 59 in varats/varats/experiments/vara/architecture_report_experiment.py

View workflow job for this annotation

GitHub Actions / pylint

[pylint] varats/varats/experiments/vara/architecture_report_experiment.py#L59 <602>

Undefined variable 'BCFileExtensions' (undefined-variable)
Raw output
varats/varats/experiments/vara/architecture_report_experiment.py:59:24: E0602: Undefined variable 'BCFileExtensions' (undefined-variable)
BCFileExtensions.ARCH

Check failure on line 60 in varats/varats/experiments/vara/architecture_report_experiment.py

View workflow job for this annotation

GitHub Actions / mypy

[mypy] varats/varats/experiments/vara/architecture_report_experiment.py#L60

error: Name "BCFileExtensions" is not defined [name-defined]
Raw output
varats/varats/experiments/vara/architecture_report_experiment.py:60:25: error: Name "BCFileExtensions" is not defined  [name-defined]

Check failure on line 60 in varats/varats/experiments/vara/architecture_report_experiment.py

View workflow job for this annotation

GitHub Actions / pylint

[pylint] varats/varats/experiments/vara/architecture_report_experiment.py#L60 <602>

Undefined variable 'BCFileExtensions' (undefined-variable)
Raw output
varats/varats/experiments/vara/architecture_report_experiment.py:60:24: E0602: Undefined variable 'BCFileExtensions' (undefined-variable)
]
)
]

run_cmd = opt[opt_params]

Check failure on line 65 in varats/varats/experiments/vara/architecture_report_experiment.py

View workflow job for this annotation

GitHub Actions / mypy

[mypy] varats/varats/experiments/vara/architecture_report_experiment.py#L65

error: Name "opt" is not defined [name-defined]
Raw output
varats/varats/experiments/vara/architecture_report_experiment.py:65:23: error: Name "opt" is not defined  [name-defined]

Check failure on line 65 in varats/varats/experiments/vara/architecture_report_experiment.py

View workflow job for this annotation

GitHub Actions / pylint

[pylint] varats/varats/experiments/vara/architecture_report_experiment.py#L65 <602>

Undefined variable 'opt' (undefined-variable)
Raw output
varats/varats/experiments/vara/architecture_report_experiment.py:65:22: E0602: Undefined variable 'opt' (undefined-variable)

exec_func_with_pe_error_handler(
run_cmd,
create_default_analysis_failure_handler(
self.__experiment_handle, self.project, MDReport
)
)

return actions.StepResult.OK


# Please take care when changing this file, see docs experiments/just_compile
s8jsweis marked this conversation as resolved.
Show resolved Hide resolved
class ArchitectureReport(VersionExperiment, shorthand="ARE"):
s8jsweis marked this conversation as resolved.
Show resolved Hide resolved
"""Generates an Architecture report file."""

NAME = "GenerateArchitectureReport"

REPORT_SPEC = ReportSpecification(MDReport)

def actions_for_project(
self, project: Project
) -> tp.MutableSequence[actions.Step]:
"""Returns the specified steps to run the project(s) specified in the
call in a fixed order."""

# Add the required runtime extensions to the project(s).
project.runtime_extension = run.RuntimeExtension(project, self) \
<< time.RunWithTime()

# Add the required compiler extensions to the project(s).
project.compiler_extension = compiler.RunCompiler(project, self) \
<< RunWLLVM() \
<< run.WithTimeout()

project.compile = get_default_compile_error_wrapped(
self.get_handle(), project, self.REPORT_SPEC.main_report
)

s8jsweis marked this conversation as resolved.
Show resolved Hide resolved
analysis_actions = []
analysis_actions.append(actions.Compile(project))
s8jsweis marked this conversation as resolved.
Show resolved Hide resolved
analysis_actions.append(EmptyAnalysis(project, self.get_handle()))

Check failure on line 106 in varats/varats/experiments/vara/architecture_report_experiment.py

View workflow job for this annotation

GitHub Actions / mypy

[mypy] varats/varats/experiments/vara/architecture_report_experiment.py#L106

error: Name "EmptyAnalysis" is not defined [name-defined]
Raw output
varats/varats/experiments/vara/architecture_report_experiment.py:106:33: error: Name "EmptyAnalysis" is not defined  [name-defined]

Check failure on line 106 in varats/varats/experiments/vara/architecture_report_experiment.py

View workflow job for this annotation

GitHub Actions / pylint

[pylint] varats/varats/experiments/vara/architecture_report_experiment.py#L106 <602>

Undefined variable 'EmptyAnalysis' (undefined-variable)
Raw output
varats/varats/experiments/vara/architecture_report_experiment.py:106:32: E0602: Undefined variable 'EmptyAnalysis' (undefined-variable)
s8jsweis marked this conversation as resolved.
Show resolved Hide resolved
analysis_actions.append(actions.Clean(project))

return analysis_actions



Check failure on line 112 in varats/varats/experiments/vara/architecture_report_experiment.py

View workflow job for this annotation

GitHub Actions / pylint

[pylint] varats/varats/experiments/vara/architecture_report_experiment.py#L112 <305>

Trailing newlines (trailing-newlines)
Raw output
varats/varats/experiments/vara/architecture_report_experiment.py:112:0: C0305: Trailing newlines (trailing-newlines)
s8jsweis marked this conversation as resolved.
Show resolved Hide resolved
71 changes: 71 additions & 0 deletions varats/varats/projects/cpp_projects/featureperfcscollection.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
"""Based on the project file for opencv."""
import typing as tp

import benchbuild as bb
from benchbuild.utils.cmd import make, cmake
from benchbuild.utils.settings import get_number_of_jobs
from plumbum import local

from varats.containers.containers import get_base_image, ImageBase

Check warning on line 9 in varats/varats/projects/cpp_projects/featureperfcscollection.py

View workflow job for this annotation

GitHub Actions / pylint

[pylint] varats/varats/projects/cpp_projects/featureperfcscollection.py#L9 <611>

Unused get_base_image imported from varats.containers.containers (unused-import)
Raw output
varats/varats/projects/cpp_projects/featureperfcscollection.py:9:0: W0611: Unused get_base_image imported from varats.containers.containers (unused-import)

Check warning on line 9 in varats/varats/projects/cpp_projects/featureperfcscollection.py

View workflow job for this annotation

GitHub Actions / pylint

[pylint] varats/varats/projects/cpp_projects/featureperfcscollection.py#L9 <611>

Unused ImageBase imported from varats.containers.containers (unused-import)
Raw output
varats/varats/projects/cpp_projects/featureperfcscollection.py:9:0: W0611: Unused ImageBase imported from varats.containers.containers (unused-import)
from varats.paper.paper_config import PaperConfigSpecificGit
from varats.project.project_domain import ProjectDomains
from varats.project.project_util import (
ProjectBinaryWrapper,
BinaryType,
get_local_project_git_path,
verify_binaries,
)
from varats.project.varats_project import VProject
from varats.utils.git_util import ShortCommitHash, RevisionBinaryMap
from varats.utils.settings import bb_cfg


class OpenCV(VProject):
"""Open Source Computer Vision Library."""

NAME = 'featureperfcscollection'
GROUP = 'cpp_projects'
DOMAIN = ProjectDomains.CPP_LIBRARY

SOURCE = [
PaperConfigSpecificGit(
project_name="featureperfcscollection",
remote="[email protected]:se-sic/FeaturePerfCSCollection.git",
local="featureperfcscollection",
refspec="origin/HEAD",
limit=None,
shallow=False
)
]
s8jsweis marked this conversation as resolved.
Show resolved Hide resolved

@staticmethod
def binaries_for_revision(
revision: ShortCommitHash
) -> tp.List[ProjectBinaryWrapper]:
binary_map = RevisionBinaryMap(get_local_project_git_path(OpenCV.NAME))

# TODO: please add correct binary names

Check warning on line 47 in varats/varats/projects/cpp_projects/featureperfcscollection.py

View workflow job for this annotation

GitHub Actions / pylint

[pylint] varats/varats/projects/cpp_projects/featureperfcscollection.py#L47 <511>

TODO: please add correct binary names (fixme)
Raw output
varats/varats/projects/cpp_projects/featureperfcscollection.py:47:9: W0511: TODO: please add correct binary names (fixme)
binary_map.specify_binary("MISSING", BinaryType.EXECUTABLE)

return binary_map[revision]

def run_tests(self) -> None:
pass

def compile(self) -> None:
"""Compile the project."""
opencv_source = local.path(self.source_of(self.primary_source))

c_compiler = bb.compiler.cc(self)
cxx_compiler = bb.compiler.cxx(self)
build_folder = opencv_source / "build"
build_folder.mkdir()
with local.cwd(build_folder):

with local.env(CC=str(c_compiler), CXX=str(cxx_compiler)):
bb.watch(cmake)("../projects/SynthSAWholeProgram")

bb.watch(make)("-j", get_number_of_jobs(bb_cfg()))

with local.cwd(opencv_source):
verify_binaries(self)
Loading