Skip to main content

CompilerSutraPerfTool

Alpha performance experimentation for C/C++ programs and GPU kernels (OpenCL, HIP, Vulkan shaders).

Compile, run, profile, compare, and export structured JSON/CSV/XLSX artifacts — from the CLI or pip install compilersutra-perf.

Status: Alpha MVP (0.2.0). Suitable for local experimentation; not yet validated for production CI regression gates. See limitations and docs/METHODOLOGY.md.

Research goal: a unified CPU/GPU hardware & compiler observatory layer — orchestrate existing toolchains, normalize results, and keep static vs measured evidence honest. See docs/OBSERVATORY.md.


Install

pip install compilersutra-perf

Optional extras:

pip install 'compilersutra-perf[visualize]'   # HTML reports + Streamlit dashboard
pip install 'compilersutra-perf[excel]'       # XLSX result workbooks
pip install 'compilersutra-perf[pdf]'         # PDF reports (WeasyPrint)
pip install 'compilersutra-perf[dev]'         # pytest

Requirements: Python 3.11+. Linux wheels ship prebuilt native runners for CPU (and Vulkan, where available), so CPU workloads run out of the box. Other platforms (or exotic Python builds) fall back to building the runner on demand, which needs a C/C++ toolchain and cmake on PATH; perf is also recommended for full CPU profiling on Linux. GPU backends need their respective runtimes (ROCm, OpenCL, Vulkan) installed separately.

Platform wheels and old distributions: release wheels use a manylinux tag (e.g. manylinux_2_39_x86_64) for the glibc they were built on, so a wheel built on Ubuntu 24.04 may fail to load its bundled runner on Ubuntu 22.04 or older (newer glibc). The loader probes the bundled runner at startup and automatically falls back to an on-demand local build, so only an older toolchain is needed there. Hardware counter events are probed per-CPU, so vendor-specific events never break collection on other vendors (Intel vs AMD).

Native Windows: not yet supported. The runner uses POSIX APIs (fork, sched_setaffinity) and won't build on Windows natively — use WSL2. Result artifacts (JSON/CSV/XLSX/HTML reports) open fine on Windows.

Check that every system tool csperf needs is present, and install whatever is missing:

csperf quickstart --output-dir results/quickstart   # doctor + example + report
csperf doctor              # report missing tools; exit 1 if a required tool is missing
csperf doctor --install    # install missing required tools (apt/dnf/pacman/apk/brew)
csperf doctor --install --all   # also install optional GPU/profiling tools

See docs/TROUBLESHOOTING.md for perf, energy, and GPU fixes.

Develop from source (private checkout if you have access):

cd CompilerSutraPerfTool
python3 -m venv .venv && source .venv/bin/activate
pip install -e '.[dev]'
# Native runners are compiled on demand at first run; build them explicitly with:
cmake -S native/runtime -B build/native && cmake --build build/native

To produce a platform wheel that embeds prebuilt runners (used by the release pipeline):

CSPERF_BUNDLE_NATIVE=1 python -m build --wheel

Quick start

csperf list-backends
csperf quickstart --output-dir results/quickstart
csperf list-energy-backends
csperf run --input examples/cpp/matrix_traversal.cpp --backend cpu \
  --warmup-runs 1 --repeat-runs 3 --output results/cpu.json
csperf profile results/cpu.json
csperf diff results/run-a.json results/run-b.json --csv results/compare.csv
# Auto-compare -O0 / -O1 / -O2 / -O3 runtimes (writes results/optimize/ + comparison report):
csperf run --input examples/cpp/matrix_traversal.cpp --diff-optimize --no-perf --report-format both
# Energy (Linux RAPL / AMD GPU when available):
csperf run --input examples/cpp/matrix_traversal.cpp --backend cpu \
  --energy-backend amd-cpu --output results/cpu-energy.json

Each run writes results/<name>.json, .csv, and .xlsx (when openpyxl is installed).


Backends

Backend Status Notes
CPU Execute + profile Native C++ runner, LLVM IR (clang), Linux perf counters, warmup/repeat, optional --cpu-affinity
HIP Execute + profile hipcc compile-and-run, ROCm devices, rocprofv3 (then v2/v1)
OpenCL Execute Native kernel launch, device selection, warmup/repeat
Vulkan Execute via csrun / validate Prefer CompilerSutraRun YAML execute (CSRUN_BIN); else GLSL → SPIR-V + module validation
gpu alias Auto-route .hip → HIP, .cl → OpenCL, shaders → Vulkan
CUDA / Metal Planned Listed in registry but not executable
macOS CPU Experimental Execution works; profiling uses powermetrics (needs passwordless sudo)

Compiler selection and flags

Use --compiler to select the compiler explicitly, or select the toolchain with environment variables; pass optimization and language flags with --compiler-flag.

Choose compiler (CPU)

# Default: clang / clang++
csperf run --input program.cpp --backend cpu --output results/clang.json

# GCC
CC=gcc CXX=g++ csperf run --input program.cpp --backend cpu --output results/gcc.json

# Explicit compiler override env vars (highest priority after CXX_COMPILER)
CXX=g++-13 csperf run --input program.cpp --backend cpu --output results/gpp13.json

Resolution order: CXX_COMPILER / C_COMPILER → CXX / CC → default (clang++ / clang).

HIP always uses hipcc when available.

Add compiler flags

Repeat --compiler-flag for each option. -O3 is added by default unless you pass another -O* flag (for example --compiler-flag=-O0):

csperf run --input program.cpp --backend cpu \
  --compiler-flag=-march=native \
  --compiler-flag=-funroll-loops \
  --compiler-flag=-fopenmp \
  --output results/optimized.json

csperf run --input program.cpp --compiler-flag=-std=c++20 --output results/cpp20.json

CXXFLAGS / CFLAGS are not read — pass flags explicitly.

Compare two compilers (batch)

For a folder of .c/.cpp files, use the batch script with JSON compiler configs:

python scripts/compiler_diff_batch.py examples/cpp \
  --config1 configs/compiler_gcc.sample.json \
  --config2 configs/compiler_clang.sample.json

Sample config (configs/compiler_gcc.sample.json):

{
  "compiler_family": "gcc",
  "cc": "gcc",
  "cxx": "g++",
  "compiler_flags": ["-O3", "-march=native"]
}

Outputs: per-file JSON/CSV diffs, summary.csv, and summary.xlsx.

Compare two saved runs

csperf diff results/gcc.json results/clang.json \
  --csv results/gcc-vs-clang.csv \
  --derived-config configs/derived_metrics.sample.json

Common run options

Flag Purpose
--warmup-runs N Warmup iterations before measurement (default 3)
--repeat-runs N Measured trials with summary stats (default 15)
--no-perf Skip hardware counter collection
--plan-only Print compile/run commands without executing
--build-dir PATH Output directory for binary and IR
--cpu-affinity 0,1 Pin CPU execution (Linux)
--device-index N GPU device for HIP / OpenCL / Vulkan
--backend gpu Auto-select GPU backend from file type
--compiler=PATH Select the CPU compiler binary
--compiler-flag=FLAG Append compile flag (repeatable)
--program-arg ARG Pass an argument to the workload (repeatable)
--stdin-file PATH Provide workload stdin
--execution-timeout SECONDS Bound each workload execution
--diff-optimize Run -O0…-O3, write per-level results and runtime comparison
--energy / --no-energy Enable or disable energy measurement (on by default when backends exist)
--energy-backend KEY Select backends (auto, amd-cpu, amd-gpu, …); see list-energy-backends
--json Machine-readable stdout
--version Print package version

OpenCL kernel arguments:

csperf run --input examples/opencl/saxpy.cl --backend opencl --device-index 0 \
  --kernel-name saxpy \
  --kernel-arg buffer:float:read:4096:1.0 \
  --kernel-arg scalar:uint32:4096 \
  --readback-arg 2

Inspect planned commands:

csperf run --input program.cpp --plan-only

Results and visualization

Artifacts per run:

  • JSON — full structured result (metrics, execution with host_platform and metrics_availability, hardware, diagnostics)
  • CSV — sectioned spreadsheet-friendly report with dotted metric paths and units
  • XLSX — Results + Metadata sheets (requires [excel] extra)
csperf profile results/cpu.json
csperf visualize results/cpu.json results/gpu.json --output report.html
csperf visualize results/cpu.json --format pdf --output report.pdf
csperf visualize results/cpu.json --format both --output report
csperf list-report-formats
pip install 'compilersutra-perf[visualize]' && csperf dashboard results/cpu.json

Energy and power domains appear in the HTML/PDF report when the run collected a power block. See docs/ENERGY.md and docs/REPORT.md.

Failed runs exit non-zero (1) and include actionable hints when tooling is missing. See exit codes in USAGE.


Limitations

Read these before trusting numbers in papers or CI:

  • Alpha — methodology and backend coverage are still evolving.
  • CPU runs support --execution-timeout to bound workload execution.
  • CPU runs support repeated --program-arg values and --stdin-file; manifests can define the same settings.
  • --experiment / --opt-config — apply compile macros and optional extra flags; plugin entry points remain planned for 0.3.0.
  • Optional extras track, tune, and distributed are reserved for later releases and are not wired into the CLI.
  • OpenCL — program may recompile each trial; interpret kernel times carefully.
  • CUDA / Metal — not implemented despite registry entries.
  • Native runners — Linux wheels bundle prebuilt native runners; other platforms build on demand from the bundled sources (needs a C/C++ toolchain and cmake).

Best supported today: Linux CPU compile/run/profile with perf configured, plus HIP/OpenCL exploration with manual interpretation.


Documentation

Public getting started guide:

https://www.compilersutra.com/docs/project/compilersutra-perf/getting-started/

In-tree guides (source checkout):

Doc Topic
docs/GETTING_STARTED.md First workload
docs/USAGE.md CLI reference
docs/ENERGY.md Energy / power backends
docs/REPORT.md Modular HTML/PDF reports
docs/METHODOLOGY.md What metrics mean and platform caveats
docs/TESTING.md Validation
docs/ARCHITECTURE.md Design
CONTRIBUTING.md Contributions
CHANGELOG.md Release notes

License

Apache License 2.0 — see LICENSE.

Author: Priya Pandey · CompilerSutra

Metadata

Release files for compilersutra-perf 0.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for compilersutra-perf 0.3.0
File Size Uploaded Provenance Actions
compilersutra_perf-0.3.0.tar.gz 244.4 kB With provenance Details for compilersutra_perf-0.3.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for compilersutra-perf 0.3.0
File Interpreter ABI Platform Actions
compilersutra_perf-0.3.0-py3-none-any.whl Python 3 none any Details for compilersutra_perf-0.3.0-py3-none-any.whl

Total release size: 502.6 kB

Release files / compilersutra_perf-0.3.0.tar.gz

Download URL compilersutra_perf-0.3.0.tar.gz
Size 244.4 kB
Tags Source
SHA-256 checksum
How to use checksums
e065d58e691eac3d118722251577ce7afdede3b847d6bf51c14c878246a437e5
BLAKE2b-256 checksum
How to use checksums
3c776dd01041084c0f01762c33a41a978688c92ec66162ad77d434b418518fb5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 8, 2026.

Transparency log

Release files / compilersutra_perf-0.3.0-py3-none-any.whl

Download URL compilersutra_perf-0.3.0-py3-none-any.whl
Size 258.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1bf8dadb402ce411002a1b956224336b23b85af099b5b5bc789fa7c2c8c3f1f3
BLAKE2b-256 checksum
How to use checksums
60299ce0c043c4e575e59f6b5ed7e0c6fea98f0f6e106f8ad40c5394bf86a70a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 8, 2026.

Transparency log

Security for compilersutra-perf 0.3.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for compilersutra_perf-0.3.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 8, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page