Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 35 additions & 6 deletions bench/generate_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,14 @@
"stress-ng --cpu 4 --cpu-ops 10",
]

# Callgrind configurations: (extra args, config name). The config name is the
# last segment of the benchmark id, e.g. `test_valgrind[<version>, <cmd>, no-inline]`.
# Callgrind configurations: (extra args, config name, requires_codspeed). The
# config name is the last segment of the benchmark id, e.g.
# `test_valgrind[<version>, <cmd>, no-inline]`. `requires_codspeed` marks configs
# that rely on CodSpeed-only options (e.g. `--cycle-estimation`); they are skipped
# for upstream Valgrind builds, which would otherwise abort with "Unknown option".
CONFIGS = [
(["--read-inline-info=no"], "no-inline"),
(["--read-inline-info=yes"], "inline"),
(["--read-inline-info=no"], "no-inline", False),
(["--read-inline-info=yes"], "inline", False),
(
[
"--trace-children=yes",
Expand All @@ -45,6 +48,7 @@
"--read-inline-info=yes",
],
"full-with-inline",
False,
),
(
[
Expand All @@ -59,9 +63,31 @@
"--dump-line=no",
],
"full-no-inline",
False,
),
(
[
"--trace-children=yes",
"--cache-sim=yes",
"--I1=32768,8,64",
"--D1=32768,8,64",
"--LL=8388608,16,64",
"--collect-systime=nsec",
"--compress-strings=no",
"--combine-dumps=yes",
"--dump-line=no",
"--read-inline-info=yes",
"--cycle-estimation=yes"
],
"full-with-inline-with-cycle-estimation",
True,
),
(["--cycle-estimation=yes"], "cycle-estimation", True),
]

# Label produced by `valgrind_version` for CodSpeed's custom build.
CODSPEED_VERSION = "valgrind.codspeed"


def valgrind_version(valgrind_path: str) -> str:
"""Return the normalized version label used in benchmark ids.
Expand All @@ -80,7 +106,7 @@ def valgrind_version(valgrind_path: str) -> str:

version = result.stdout.strip()
if "codspeed" in version:
return "valgrind.codspeed"
return CODSPEED_VERSION
return version


Expand All @@ -89,8 +115,11 @@ def build_config(valgrind_paths: list) -> dict:
benchmarks = []
for valgrind_path in valgrind_paths:
version = valgrind_version(valgrind_path)
is_codspeed = version == CODSPEED_VERSION
for cmd in COMMANDS:
for args, config_name in CONFIGS:
for args, config_name, requires_codspeed in CONFIGS:
if requires_codspeed and not is_codspeed:
continue
name = f"test_valgrind[{version}, {cmd}, {config_name}]"
exec_cmd = " ".join(
[valgrind_path, "--tool=callgrind", "--log-file=/dev/null", *args, cmd]
Expand Down
12 changes: 10 additions & 2 deletions callgrind/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,15 @@ bin_SCRIPTS = \

noinst_HEADERS = \
costs.h \
cycledecode.h \
sigkey.h \
events.h \
global.h

# Generated cost tables + legacy XED table (#included by cycledecode.c under
# CLG_WITH_CAPSTONE; the arch is selected at compile time).
EXTRA_DIST += x86_caps_lut.inc arm64_caps_lut.inc x86_uops_lut.inc

#----------------------------------------------------------------------------
# callgrind-<platform>
#----------------------------------------------------------------------------
Expand All @@ -37,6 +43,7 @@ CALLGRIND_SOURCES_COMMON = \
clo.c \
context.c \
costs.c \
cycledecode.c \
debug.c \
dump.c \
events.c \
Expand All @@ -54,11 +61,12 @@ callgrind_@VGCONF_ARCH_PRI@_@VGCONF_OS@_SOURCES = \
callgrind_@VGCONF_ARCH_PRI@_@VGCONF_OS@_CPPFLAGS = \
$(AM_CPPFLAGS_@VGCONF_PLATFORM_PRI_CAPS@)
callgrind_@VGCONF_ARCH_PRI@_@VGCONF_OS@_CFLAGS = $(LTO_CFLAGS) \
$(AM_CFLAGS_@VGCONF_PLATFORM_PRI_CAPS@) $(CALLGRIND_CFLAGS_COMMON)
$(AM_CFLAGS_@VGCONF_PLATFORM_PRI_CAPS@) $(CALLGRIND_CFLAGS_COMMON) \
@CAPSTONE_CFLAGS@
callgrind_@VGCONF_ARCH_PRI@_@VGCONF_OS@_DEPENDENCIES = \
$(TOOL_DEPENDENCIES_@VGCONF_PLATFORM_PRI_CAPS@)
callgrind_@VGCONF_ARCH_PRI@_@VGCONF_OS@_LDADD = \
$(TOOL_LDADD_@VGCONF_PLATFORM_PRI_CAPS@)
$(TOOL_LDADD_@VGCONF_PLATFORM_PRI_CAPS@) @CAPSTONE_LIBS@
callgrind_@VGCONF_ARCH_PRI@_@VGCONF_OS@_LDFLAGS = \
$(TOOL_LDFLAGS_@VGCONF_PLATFORM_PRI_CAPS@)
callgrind_@VGCONF_ARCH_PRI@_@VGCONF_OS@_LINK = \
Expand Down
Loading
Loading