Skip to content

Commit

Permalink
Merge branch 'vara-dev' into f-PerfReport
Browse files Browse the repository at this point in the history
  • Loading branch information
vulder authored Oct 23, 2023
2 parents 9c3581e + 19212e1 commit e9766d6
Show file tree
Hide file tree
Showing 5 changed files with 74 additions and 27 deletions.
10 changes: 7 additions & 3 deletions tests/test_containers.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ class TestImageBase(unittest.TestCase):
def test_distro(self) -> None:
self.assertEqual(Distro.DEBIAN, ImageBase.DEBIAN_10.distro)

def test_distro_version_number(self) -> None:
self.assertEqual(10, ImageBase.DEBIAN_10.version)
self.assertEqual(12, ImageBase.DEBIAN_12.version)


class TestContainerSupport(unittest.TestCase):
"""Test container support related functionality."""
Expand Down Expand Up @@ -96,7 +100,7 @@ def test_create_stage_10_from_pip(self) -> None:
self.check_layer_type(layers[0], FromLayer)

varats_core_install_layer = self.check_layer_type(layers[2], RunLayer)
self.assertEqual("pip3", varats_core_install_layer.command)
self.assertEqual("pip", varats_core_install_layer.command)
self.assertTupleEqual(
("install", "--ignore-installed", "varats-core", "varats"),
varats_core_install_layer.args
Expand All @@ -123,7 +127,7 @@ def test_create_stage_10_from_source(self) -> None:
self.check_layer_type(layers[0], FromLayer)

varats_core_install_layer = self.check_layer_type(layers[4], RunLayer)
self.assertEqual("pip3", varats_core_install_layer.command)
self.assertEqual("pip", varats_core_install_layer.command)
self.assertTupleEqual(("install", "/varats/varats-core"),
varats_core_install_layer.args)
mounting_parameters = "type=bind,src=varats_src,target=/varats"
Expand All @@ -133,7 +137,7 @@ def test_create_stage_10_from_source(self) -> None:
varats_core_install_layer.kwargs)

varats_install_layer = self.check_layer_type(layers[5], RunLayer)
self.assertEqual("pip3", varats_install_layer.command)
self.assertEqual("pip", varats_install_layer.command)
self.assertTupleEqual(("install", "/varats/varats"),
varats_install_layer.args)
mounting_parameters = "type=bind,src=varats_src,target=/varats"
Expand Down
36 changes: 27 additions & 9 deletions varats/varats/containers/containers.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,23 @@

class ImageBase(Enum):
"""Container image bases that can be used by projects."""
DEBIAN_10 = Distro.DEBIAN
DEBIAN_10 = (Distro.DEBIAN, 10)
DEBIAN_12 = (Distro.DEBIAN, 12)

def __init__(self, distro: Distro):
def __init__(self, distro: Distro, version_number: int):
self.__distro = distro
self.__version_number = version_number

@property
def distro(self) -> Distro:
"""Distro of the base image."""
return self.__distro

@property
def version(self) -> int:
"""Version number of the distro."""
return self.__version_number


class ImageStage(Enum):
"""The stages that make up a base image."""
Expand Down Expand Up @@ -156,7 +163,7 @@ def _create_stage_00_base_layers(stage_builder: StageBuilder) -> None:


def _create_stage_10_varats_layers(stage_builder: StageBuilder) -> None:
stage_builder.layers.run('pip3', 'install', '--upgrade', 'pip')
stage_builder.layers.run('pip', 'install', '--upgrade', 'pip')
_add_varats_layers(stage_builder)
if bb_cfg()['container']['from_source']:
add_benchbuild_layers(stage_builder.layers)
Expand Down Expand Up @@ -215,13 +222,22 @@ def wrapped(stage_builder: StageBuilder) -> None:
.run('make', '-j', str(get_number_of_jobs(bb_cfg())))
.run('make', 'install')
.workingdir('/')
# install llvm 13
# install llvm 14
.run('wget', 'https://apt.llvm.org/llvm.sh')
.run('chmod', '+x', './llvm.sh')
.run('./llvm.sh', '14', 'all')
.run('ln', '-s', '/usr/bin/clang-14', '/usr/bin/clang')
.run('ln', '-s', '/usr/bin/clang++-14', '/usr/bin/clang++')
.run('ln', '-s', '/usr/bin/lld-14', '/usr/bin/lld'))
.run('ln', '-s', '/usr/bin/lld-14', '/usr/bin/lld')),
ImageBase.DEBIAN_12:
_create_layers_helper(lambda ctx: ctx.layers
.from_("docker.io/library/debian:12")
.run('apt', 'update')
.run('apt', 'install', '-y', 'wget', 'gnupg', 'lsb-release',
'software-properties-common', 'musl-dev', 'git', 'gcc',
'libgit2-dev', 'libffi-dev', 'libyaml-dev', 'graphviz-dev',
'python3', 'python3-pip', 'python3-virtualenv', 'clang',
'lld', 'time'))
}

_STAGE_LAYERS: tp.Dict[ImageStage,
Expand Down Expand Up @@ -313,7 +329,9 @@ def _set_varats_source_mount(image_context: StageBuilder, mnt_src: str) -> None:

def _setup_venv(image_context: StageBuilder) -> None:
venv_path = "/venv"
image_context.layers.run("pip3", "install", "virtualenv")
if image_context.base == ImageBase.DEBIAN_10:
image_context.layers.run("pip3", "install", "virtualenv")

image_context.layers.run("virtualenv", venv_path)
image_context.layers.env(VIRTUAL_ENV=venv_path)
image_context.layers.env(PATH=f"{venv_path}/bin:$PATH")
Expand All @@ -331,9 +349,9 @@ def from_source(
tgt_dir = image_context.varats_source_mount_target

image.run('mkdir', f'{tgt_dir}', runtime=crun)
image.run('pip3', 'install', 'setuptools', runtime=crun)
image.run('pip', 'install', 'setuptools', runtime=crun)

pip_args = ['pip3', 'install']
pip_args = ['pip', 'install']
if editable_install:
pip_args.append("-e")
_set_varats_source_mount(image_context, str(src_dir))
Expand All @@ -348,7 +366,7 @@ def from_source(
def from_pip(image: ContainerImage) -> None:
LOG.debug("installing varats from pip release.")
image.run(
'pip3',
'pip',
'install',
'--ignore-installed',
'varats-core',
Expand Down
12 changes: 10 additions & 2 deletions varats/varats/experiments/vara/feature_experiment.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
Compile,
Clean,
)
from benchbuild.utils.requirements import Requirement, SlurmMem
from plumbum import local

from varats.experiment.experiment_util import (
Expand Down Expand Up @@ -72,6 +73,8 @@ class FeatureExperiment(VersionExperiment, shorthand=""):

REPORT_SPEC = ReportSpecification()

REQUIREMENTS: tp.List[Requirement] = [SlurmMem("250G")]

@abstractmethod
def actions_for_project(self,
project: VProject) -> tp.MutableSequence[Step]:
Expand Down Expand Up @@ -180,18 +183,23 @@ def get_vara_tracing_cflags(
Returns: list of tracing specific cflags
"""
c_flags = []

if instr_type != FeatureInstrType.NONE:
c_flags += ["-fsanitize=vara", f"-fvara-instr={instr_type.value}"]

c_flags += [
"-flto", "-fuse-ld=lld", "-flegacy-pass-manager",
"-fno-omit-frame-pointer"
]
if instruction_threshold is not None:

if instruction_threshold is None:
# For test projects, do not exclude small regions
if project is not None and project.domain == ProjectDomains.TEST:
instruction_threshold = 1

if instruction_threshold is not None:
c_flags += [f"-fvara-instruction-threshold={instruction_threshold}"]

if save_temps:
c_flags += ["-Wl,-plugin-opt=save-temps"]

Expand Down Expand Up @@ -230,7 +238,7 @@ def __call__(self) -> StepResult:

def __str__(self, indent: int = 0) -> str:
return textwrap.indent(
f"* {self.project.name}: Run instrumentation verifier", indent * " "
f"* {self.project.name}: Run instrumented code", indent * " "
)

def run_traced_code(self) -> StepResult:
Expand Down
42 changes: 29 additions & 13 deletions varats/varats/projects/cpp_projects/dune.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import typing as tp

import benchbuild as bb
from benchbuild.command import WorkloadSet, Command, SourceRoot
from benchbuild.command import WorkloadSet, SourceRoot
from benchbuild.utils import cmd
from benchbuild.utils.revision_ranges import RevisionRange
from plumbum import local
Expand All @@ -16,6 +16,8 @@
BinaryType,
ProjectBinaryWrapper,
)
from varats.project.sources import FeatureSource
from varats.project.varats_command import VCommand
from varats.project.varats_project import VProject
from varats.utils.git_util import ShortCommitHash, RevisionBinaryMap

Expand All @@ -32,7 +34,13 @@ class DunePerfRegression(VProject):
If you use Dune with an experiment that uses the vara compiler,
add `-mllvm --vara-disable-phasar` to the projects `cflags` to
disable phasar passes.
This will still allow to analyse compile-time variability.
This will still allow to analyse compile-time variability.
Might need deps:
* klu
* spqr
* umfpack
* eigen3
"""

NAME = 'DunePerfRegression'
Expand All @@ -42,25 +50,26 @@ class DunePerfRegression(VProject):
SOURCE = [
PaperConfigSpecificGit(
project_name='DunePerfRegression',
remote='git@github.com:se-sic/dune-VaRA.git',
remote='https://github.com/se-sic/dune-VaRA.git',
local='dune-VaRA',
refspec='origin/HEAD',
limit=None,
shallow=False
)
),
FeatureSource()
]

CONTAINER = get_base_image(ImageBase.DEBIAN_10)

WORKLOADS = {
WorkloadSet(WorkloadCategory.EXAMPLE): [
Command(
VCommand(
SourceRoot(
"dune-VaRA/dune-performance-regressions/build-cmake/src"
) / RSBinary('dune_performance_regressions'),
label='dune_helloworld'
),
Command(
VCommand(
SourceRoot(
"dune-VaRA/dune-performance-regressions/build-cmake/src"
) / RSBinary('poisson_test'),
Expand All @@ -71,42 +80,42 @@ class DunePerfRegression(VProject):
'poisson-yasp-Q2-3d.vtu'
]
),
Command(
VCommand(
SourceRoot(
"dune-VaRA/dune-performance-regressions/build-cmake/src"
) / RSBinary('poisson_ug_pk_2d'),
label='poisson_ug_pk_2d',
creates=['poisson-UG-Pk-2d.vtu']
),
Command(
VCommand(
SourceRoot(
"dune-VaRA/dune-performance-regressions/build-cmake/src"
) / RSBinary('poisson_yasp_q1_2d'),
label='poisson_yasp_q1_2d',
creates=['poisson-yasp-q1-2d.vtu']
),
Command(
VCommand(
SourceRoot(
"dune-VaRA/dune-performance-regressions/build-cmake/src"
) / RSBinary('poisson_yasp_q1_3d'),
label='poisson_yasp_q1_3d',
creates=['poisson-yasp-q1-3d.vtu']
),
Command(
VCommand(
SourceRoot(
"dune-VaRA/dune-performance-regressions/build-cmake/src"
) / RSBinary('poisson_yasp_q2_2d'),
label='poisson_yasp_q2_2d',
creates=['poisson-yasp-q2-2d.vtu']
),
Command(
VCommand(
SourceRoot(
"dune-VaRA/dune-performance-regressions/build-cmake/src"
) / RSBinary('poisson_yasp_q2_3d'),
label='poisson_yasp_q2_3d',
creates=['poisson-yasp-q2-3d.vtu']
),
Command(
VCommand(
SourceRoot(
"dune-VaRA/dune-performance-regressions/build-cmake/src"
) / RSBinary('poisson_alugrid'),
Expand Down Expand Up @@ -184,7 +193,14 @@ def compile(self) -> None:
cxx_compiler = bb.compiler.cxx(self)

with local.cwd(version_source):
with local.env(CC=c_compiler, CXX=cxx_compiler):
with local.env(
CC=c_compiler,
CXX=cxx_compiler,
CMAKE_FLAGS=" ".join([
"-DDUNE_ENABLE_PYTHONBINDINGS=OFF",
"-DCMAKE_DISABLE_FIND_PACKAGE_MPI=TRUE"
])
):
dunecontrol = cmd['./dune-common/bin/dunecontrol']

bb.watch(dunecontrol
Expand Down
1 change: 1 addition & 0 deletions varats/varats/tools/driver_build_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,7 @@ def _build_in_container(
install_mount = 'tools/'

click.echo("Preparing container image.")
bb_cfg() # Ensure that BB config is loaded
image_name = create_dev_image(image_base, build_type)

source_mount = str(StageBuilder.varats_root / source_mount)
Expand Down

0 comments on commit e9766d6

Please sign in to comment.