From daeb0df342d1d7c74c8f32722083af7e8f7647ef Mon Sep 17 00:00:00 2001 From: RuoyuZhou Date: Sat, 10 Oct 2026 04:32:40 +0200 Subject: [PATCH] refactor: consolidate maintenance tools and flatten Runtime sources --- .github/CODEOWNERS | 2 +- .github/scripts/validate_repo_management.py | 6 +- .github/workflows/ci-macos.yml | 8 +- .github/workflows/ci.yml | 4 +- .github/workflows/closure-probe.yml | 8 +- .github/workflows/gates-nightly.yml | 8 +- .github/workflows/platform-evidence.yml | 4 +- .github/workflows/release.yml | 16 +-- .pre-commit-config.yaml | 6 +- CMakeLists.txt | 2 +- CONTRIBUTING.md | 6 +- README.md | 6 +- benchmarks/README.md | 4 +- docs/development/repository-layout.md | 27 ++--- docs/development/testing-and-gates.md | 10 +- docs/gates/README.md | 4 +- examples/STANDARD.md | 4 +- pyproject.toml | 2 +- {simulator/gfsim => runtime}/CMakeLists.txt | 0 {simulator/gfsim => runtime}/model_input.cpp | 0 {simulator/gfsim => runtime}/sim_executor.cpp | 0 .../gfsim => runtime}/system_runner.cpp | 0 tests/compiler/IR/CMakeLists.txt | 6 +- .../lit/CodeGen/Inputs/enum_carrier.py | 2 +- .../lit/CodeGen/Inputs/queue-emission.py | 10 +- .../compiler/lit/Source/Inputs/bits-concat.py | 2 +- .../lit/Source/Inputs/bits-count-zeros.py | 2 +- .../lit/Source/Inputs/bits-popcount.py | 2 +- .../Source/Inputs/bits-priority-encoding.py | 2 +- .../compiler/lit/Source/Inputs/bounded-for.py | 2 +- .../lit/Source/Inputs/case-statements.py | 2 +- .../lit/Source/Inputs/defaults-composition.py | 2 +- .../Source/Inputs/dependent-width-binding.py | 2 +- .../lit/Source/Inputs/direct-call-graph.py | 2 +- .../compiler/lit/Source/Inputs/enum-source.py | 4 +- .../lit/Source/Inputs/fixed-predicates.py | 2 +- .../lit/Source/Inputs/fixed-slices.py | 2 +- .../Source/Inputs/fixed-unsigned-shifts.py | 2 +- .../lit/Source/Inputs/fixed-widening.py | 2 +- .../lit/Source/Inputs/frontend-branches.py | 2 +- .../lit/Source/Inputs/history-pipeline/run.py | 2 +- .../lit/Source/Inputs/history-resident/run.py | 2 +- .../lit/Source/Inputs/history-routed/run.py | 2 +- .../Source/Inputs/history-scheduling/run.py | 4 +- .../Source/Inputs/history-slot-issue/run.py | 2 +- .../lit/Source/Inputs/multi-rule-writes.py | 2 +- .../lit/Source/Inputs/pure-scalar-helpers.py | 2 +- .../lit/Source/Inputs/pythonic-memory.py | 2 +- .../lit/Source/Inputs/queue-source.py | 6 +- .../record-projection-simplification.py | 2 +- .../lit/Source/Inputs/rob-behavioral.py | 2 +- .../Source/Inputs/source-check-execution.py | 2 +- .../lit/Source/Inputs/source-checks.py | 2 +- .../Inputs/source-historical-features.py | 2 +- .../source-historical-scalar-parameterized.py | 2 +- .../Inputs/source-observation-groups.py | 2 +- .../Source/Inputs/source_computed_outputs.py | 2 +- .../Source/Inputs/source_exact_integers.py | 2 +- .../lit/Source/Inputs/source_exact_select.py | 2 +- .../lit/Source/Inputs/source_exact_shift.py | 2 +- .../Source/Inputs/source_local_bindings.py | 2 +- .../lit/Source/Inputs/static-divrem.py | 2 +- .../lit/Source/Inputs/table-methods.py | 2 +- .../lit/Source/source-observation-native.test | 2 +- tests/compiler/oracles/README.md | 2 +- .../integration/source-preview/CMakeLists.txt | 6 +- tests/system/test_model_abi.py | 4 +- tests/system/test_resource_runtime.py | 2 +- tests/system/test_source_preview_workflow.py | 4 +- tests/unit/test_build_measurement.py | 2 +- tests/unit/test_gate_topology.py | 32 ++--- tests/unit/test_generated_rtl_audit.py | 2 +- tests/unit/test_process_usage.py | 6 +- ...lease_evidence_and_platform_constraints.py | 4 +- tests/unit/test_repository_layout.py | 36 +----- tests/unit/test_retirement_presets.py | 110 +++++++++++++++++- .../test_toolchain_compiler_requirements.py | 2 +- tools/README.md | 31 +++-- {flows/tools => tools}/check_api_hygiene.py | 4 +- .../check_frontend_retirement.py | 36 ++++-- {flows/tools => tools}/check_generated_rtl.py | 0 .../install_llvm_and_build.sh | 8 +- {flows/scripts => tools}/lib.sh | 2 +- .../materialize_source_preview.py | 2 +- .../measure_build_resources.py | 8 +- .../tools => tools}/measure_source_build.py | 2 +- {flows/tools => tools}/process_usage.py | 0 {flows/scripts => tools}/pyc | 8 +- {flows/scripts => tools}/pyc.ps1 | 12 +- {flows/scripts => tools}/run_api_tests.sh | 0 {flows/scripts => tools}/run_examples.sh | 0 {flows/tools => tools}/summarize_gate_run.py | 2 +- 92 files changed, 336 insertions(+), 222 deletions(-) rename {simulator/gfsim => runtime}/CMakeLists.txt (100%) rename {simulator/gfsim => runtime}/model_input.cpp (100%) rename {simulator/gfsim => runtime}/sim_executor.cpp (100%) rename {simulator/gfsim => runtime}/system_runner.cpp (100%) rename {flows/tools => tools}/check_api_hygiene.py (95%) rename {flows/tools => tools}/check_frontend_retirement.py (93%) rename {flows/tools => tools}/check_generated_rtl.py (100%) rename {flows/scripts => tools}/install_llvm_and_build.sh (81%) rename {flows/scripts => tools}/lib.sh (97%) rename {flows/tools => tools}/materialize_source_preview.py (99%) rename {flows/tools => tools}/measure_build_resources.py (99%) rename {flows/tools => tools}/measure_source_build.py (99%) rename {flows/tools => tools}/process_usage.py (100%) rename {flows/scripts => tools}/pyc (93%) rename {flows/scripts => tools}/pyc.ps1 (96%) rename {flows/scripts => tools}/run_api_tests.sh (100%) rename {flows/scripts => tools}/run_examples.sh (100%) rename {flows/tools => tools}/summarize_gate_run.py (99%) diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 80ecb71ab..0c699868a 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -12,7 +12,7 @@ # Current source compiler and Runtime ownership. /compiler/ @zhoubot @xiekunpeng /schemas/ @zhoubot @xiekunpeng -/simulator/gfsim/ @zhoubot @xiekunpeng +/runtime/ @zhoubot @xiekunpeng /tests/compiler/ @zhoubot @xiekunpeng /tests/runtime/ @zhoubot @xiekunpeng /tests/integration/ @zhoubot @xiekunpeng diff --git a/.github/scripts/validate_repo_management.py b/.github/scripts/validate_repo_management.py index 3a4607b3b..e11ed7598 100644 --- a/.github/scripts/validate_repo_management.py +++ b/.github/scripts/validate_repo_management.py @@ -72,7 +72,7 @@ def ancestors(name: str, active: frozenset[str] = frozenset()) -> set[str]: errors.append(f"release publication job {name} bypasses accept-candidate") rebuild_markers = ( - "flows/scripts/pyc build", + "tools/pyc build", "cmake --build", "python3 -m build", "create_wheel.py", @@ -213,7 +213,7 @@ def main() -> int: require(command in ci, f"CI is missing required gate: {command}", errors) for forbidden in ( "llvm.sh", - "flows/scripts/pyc build", + "tools/pyc build", "setup-verilator", "run_examples.sh", "run_api_tests.sh", @@ -249,7 +249,7 @@ def main() -> int: "run_examples.sh", "run_api_tests.sh", "pytest tests/unit -m unit", - "flows/tools/check_api_hygiene.py", + "tools/check_api_hygiene.py", "mkdocs build --strict", ): require( diff --git a/.github/workflows/ci-macos.yml b/.github/workflows/ci-macos.yml index 975deceb7..8379fde45 100644 --- a/.github/workflows/ci-macos.yml +++ b/.github/workflows/ci-macos.yml @@ -40,7 +40,7 @@ jobs: - name: Build staged toolchain run: | LLVM_CONFIG="$(brew --prefix "llvm@${LLVM_VERSION}")/bin/llvm-config" \ - bash flows/scripts/pyc build \ + bash tools/pyc build \ --build-dir "$PWD/.pycircuit_out/toolchain/build" \ --install-prefix "$PWD/.pycircuit_out/toolchain/install" @@ -95,7 +95,7 @@ jobs: export PYC_TOOLCHAIN_ROOT="$PWD/.pycircuit_out/toolchain/install" export PATH="$PYC_TOOLCHAIN_ROOT/bin:$PATH" unset PYCC - bash flows/scripts/run_examples.sh --tier gate + bash tools/run_examples.sh --tier gate - name: Smoke test installed wheel shell: bash @@ -107,10 +107,10 @@ jobs: export PYC_TOOLCHAIN_ROOT="$(python -c 'import pycircuit, pathlib; print((pathlib.Path(pycircuit.__file__).resolve().parent / "_toolchain").as_posix())')" export PYC_USE_INSTALLED_PYTHON_PACKAGE=1 unset PYCC - bash flows/scripts/run_examples.sh --tier gate + bash tools/run_examples.sh --tier gate - name: Check installed toolchain retirement inventory - run: python flows/tools/check_frontend_retirement.py --install-root "$PWD/.pycircuit_out/toolchain/install" + run: python tools/check_frontend_retirement.py --install-root "$PWD/.pycircuit_out/toolchain/install" - name: Upload wheel uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2ab3c606f..f350773e2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -66,10 +66,10 @@ jobs: packaging/wheel/platform_tags.py \ python/pycircuit/packaged_toolchain.py \ python/pycircuit/cli.py \ - flows/tools/summarize_gate_run.py + tools/summarize_gate_run.py - name: Run API hygiene gate - run: python flows/tools/check_api_hygiene.py python/pycircuit examples docs README.md + run: python tools/check_api_hygiene.py python/pycircuit examples docs README.md capture-publication-gates: name: "G0: Capture and Publication Unit Gates" diff --git a/.github/workflows/closure-probe.yml b/.github/workflows/closure-probe.yml index 3c22335f5..df5202759 100644 --- a/.github/workflows/closure-probe.yml +++ b/.github/workflows/closure-probe.yml @@ -59,7 +59,7 @@ jobs: - name: Build integrated toolchain run: | export PYC_PYTHON_EXECUTABLE="$(command -v python3)" - PYC_BUILD_TESTING=ON bash flows/scripts/pyc build --build-dir "$PWD/.pycircuit_out/toolchain/build" --install-prefix "$PWD/.pycircuit_out/toolchain/install" + PYC_BUILD_TESTING=ON bash tools/pyc build --build-dir "$PWD/.pycircuit_out/toolchain/build" --install-prefix "$PWD/.pycircuit_out/toolchain/install" - name: Repository contract closure id: contracts @@ -68,7 +68,7 @@ jobs: SKIP=pyc-api-hygiene pre-commit run --all-files python3 .github/scripts/validate_repo_management.py pytest tests/unit -m unit - python3 flows/tools/check_api_hygiene.py python/pycircuit examples docs README.md + python3 tools/check_api_hygiene.py python/pycircuit examples docs README.md mkdocs build --strict - name: pyCircuit closure (examples) @@ -77,7 +77,7 @@ jobs: run: | export PYC_TOOLCHAIN_ROOT="$PWD/.pycircuit_out/toolchain/install" export PATH="$PYC_TOOLCHAIN_ROOT/bin:$PATH" - bash flows/scripts/run_examples.sh --tier nightly + bash tools/run_examples.sh --tier nightly - name: pyCircuit closure (API nightly) id: api @@ -85,7 +85,7 @@ jobs: run: | export PYC_TOOLCHAIN_ROOT="$PWD/.pycircuit_out/toolchain/install" export PATH="$PYC_TOOLCHAIN_ROOT/bin:$PATH" - bash flows/scripts/run_api_tests.sh --tier nightly + bash tools/run_api_tests.sh --tier nightly - name: Upload probe gate logs if: always() diff --git a/.github/workflows/gates-nightly.yml b/.github/workflows/gates-nightly.yml index f7cb4bfc0..280d6a7cb 100644 --- a/.github/workflows/gates-nightly.yml +++ b/.github/workflows/gates-nightly.yml @@ -54,7 +54,7 @@ jobs: - name: Build staged toolchain run: | LLVM_CONFIG=/usr/lib/llvm-${LLVM_VERSION}/bin/llvm-config \ - bash flows/scripts/pyc build \ + bash tools/pyc build \ --build-dir "$PWD/.pycircuit_out/toolchain/build" \ --install-prefix "$PWD/.pycircuit_out/toolchain/install" @@ -67,14 +67,14 @@ jobs: export PATH="$PYC_TOOLCHAIN_ROOT/bin:$PATH" export PYC_GATE_RUN_ID="${PYC_GATE_RUN_ID}" unset PYCC || true - bash flows/scripts/run_api_tests.sh --tier nightly + bash tools/run_api_tests.sh --tier nightly - name: Run examples (nightly) id: examples_nightly if: ${{ !cancelled() && steps.api_nightly.outcome != 'skipped' }} run: | export PYC_TOOLCHAIN_ROOT="$PWD/.pycircuit_out/toolchain/install" - bash flows/scripts/run_examples.sh --tier nightly + bash tools/run_examples.sh --tier nightly - name: Write gate summary if: always() @@ -91,7 +91,7 @@ jobs: } api_status="$(map_outcome "${{ steps.api_nightly.outcome }}")" examples_status="$(map_outcome "${{ steps.examples_nightly.outcome }}")" - python3 flows/tools/summarize_gate_run.py \ + python3 tools/summarize_gate_run.py \ --run-id "${PYC_GATE_RUN_ID}" \ --row "api-nightly:nightly:${api_status}" \ --row "examples-nightly:nightly:${examples_status}" \ diff --git a/.github/workflows/platform-evidence.yml b/.github/workflows/platform-evidence.yml index 726956dd1..1c17e0784 100644 --- a/.github/workflows/platform-evidence.yml +++ b/.github/workflows/platform-evidence.yml @@ -295,7 +295,7 @@ jobs: export CFLAGS="-ffile-prefix-map=$GITHUB_WORKSPACE=. -fdebug-prefix-map=$GITHUB_WORKSPACE=." export CXXFLAGS="$CFLAGS" export PYC_PYTHON_EXECUTABLE="$(command -v python3)" - LLVM_CONFIG="${llvm_config}" bash flows/scripts/pyc build --build-dir "$PWD/.pycircuit_out/toolchain/build" --install-prefix "$PWD/.pycircuit_out/toolchain/install" + LLVM_CONFIG="${llvm_config}" bash tools/pyc build --build-dir "$PWD/.pycircuit_out/toolchain/build" --install-prefix "$PWD/.pycircuit_out/toolchain/install" mkdir -p candidate python3 packaging/wheel/create_wheel.py --install-dir "$PWD/.pycircuit_out/toolchain/install" --out-dir candidate --wheel-version "${{ inputs.version }}" --platform "${{ matrix.platform }}" wheel="$(find candidate -maxdepth 1 -name 'pycircuit_hisi-*.whl' -print -quit)" @@ -355,7 +355,7 @@ jobs: $env:CFLAGS = $prefixMaps $env:CXXFLAGS = $prefixMaps $env:PYC_PYTHON_EXECUTABLE = (Get-Command python3).Source - pwsh -NoProfile -File flows/scripts/pyc.ps1 build --llvm-config "$llvmConfig" --build-dir "$PWD/.pycircuit_out/toolchain/build" --install-prefix "$PWD/.pycircuit_out/toolchain/install" + pwsh -NoProfile -File tools/pyc.ps1 build --llvm-config "$llvmConfig" --build-dir "$PWD/.pycircuit_out/toolchain/build" --install-prefix "$PWD/.pycircuit_out/toolchain/install" if ($LASTEXITCODE -ne 0) { throw "the platform SDK build failed with exit code $LASTEXITCODE" } New-Item -ItemType Directory -Force -Path candidate | Out-Null python3 packaging/wheel/create_wheel.py --install-dir "$PWD/.pycircuit_out/toolchain/install" --out-dir candidate --wheel-version "${{ inputs.version }}" --platform "${{ matrix.platform }}" diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 0cec41e47..3f77e5c62 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -84,21 +84,21 @@ jobs: - name: Build integrated toolchain run: | export PYC_PYTHON_EXECUTABLE="$(command -v python3)" - PYC_BUILD_TESTING=ON bash flows/scripts/pyc build --build-dir "$PWD/.pycircuit_out/toolchain/build" --install-prefix "$PWD/.pycircuit_out/toolchain/install" + PYC_BUILD_TESTING=ON bash tools/pyc build --build-dir "$PWD/.pycircuit_out/toolchain/build" --install-prefix "$PWD/.pycircuit_out/toolchain/install" - name: Run repository contract closure run: | SKIP=pyc-api-hygiene pre-commit run --all-files python3 .github/scripts/validate_repo_management.py pytest tests/unit -m unit - python3 flows/tools/check_api_hygiene.py python/pycircuit examples docs README.md + python3 tools/check_api_hygiene.py python/pycircuit examples docs README.md mkdocs build --strict - name: Run full pyCircuit closure run: | export PYC_TOOLCHAIN_ROOT="$PWD/.pycircuit_out/toolchain/install" export PATH="$PYC_TOOLCHAIN_ROOT/bin:$PATH" - bash flows/scripts/run_api_tests.sh --tier nightly - bash flows/scripts/run_examples.sh --tier nightly - python3 flows/tools/check_frontend_retirement.py --install-root "$PYC_TOOLCHAIN_ROOT" + bash tools/run_api_tests.sh --tier nightly + bash tools/run_examples.sh --tier nightly + python3 tools/check_frontend_retirement.py --install-root "$PYC_TOOLCHAIN_ROOT" - name: Upload release gate logs if: always() uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7 @@ -323,7 +323,7 @@ jobs: export CFLAGS="-ffile-prefix-map=$GITHUB_WORKSPACE=. -fdebug-prefix-map=$GITHUB_WORKSPACE=." export CXXFLAGS="$CFLAGS" export PYC_PYTHON_EXECUTABLE="$(command -v python3)" - LLVM_CONFIG="${llvm_config}" bash flows/scripts/pyc build --build-dir "$PWD/.pycircuit_out/toolchain/build" --install-prefix "$PWD/.pycircuit_out/toolchain/install" + LLVM_CONFIG="${llvm_config}" bash tools/pyc build --build-dir "$PWD/.pycircuit_out/toolchain/build" --install-prefix "$PWD/.pycircuit_out/toolchain/install" mkdir candidate python3 packaging/wheel/create_wheel.py --install-dir "$PWD/.pycircuit_out/toolchain/install" --out-dir candidate --wheel-version "${{ inputs.version }}" --platform "${{ matrix.platform }}" wheel="$(find candidate -maxdepth 1 -name 'pycircuit_hisi-*.whl' -print -quit)" @@ -383,7 +383,7 @@ jobs: $env:CFLAGS = $prefixMaps $env:CXXFLAGS = $prefixMaps $env:PYC_PYTHON_EXECUTABLE = (Get-Command python3).Source - pwsh -NoProfile -File flows/scripts/pyc.ps1 build --llvm-config "$llvmConfig" --build-dir "$PWD/.pycircuit_out/toolchain/build" --install-prefix "$PWD/.pycircuit_out/toolchain/install" + pwsh -NoProfile -File tools/pyc.ps1 build --llvm-config "$llvmConfig" --build-dir "$PWD/.pycircuit_out/toolchain/build" --install-prefix "$PWD/.pycircuit_out/toolchain/install" if ($LASTEXITCODE -ne 0) { throw "the platform SDK build failed with exit code $LASTEXITCODE" } New-Item -ItemType Directory -Force -Path candidate | Out-Null python3 packaging/wheel/create_wheel.py --install-dir "$PWD/.pycircuit_out/toolchain/install" --out-dir candidate --wheel-version "${{ inputs.version }}" --platform "${{ matrix.platform }}" @@ -677,7 +677,7 @@ jobs: arch: x64 toolset: "14.4" - name: Redownload stable assets and verify exact bytes before execution - # flows/scripts and this step are POSIX shell; Git Bash ships with the + # tools and this step are POSIX shell; Git Bash ships with the # windows-2022 image, so the same script runs on all three lanes. shell: bash env: diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 36654986b..bff382e95 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -14,14 +14,14 @@ repos: rev: v0.11.8 hooks: - id: ruff - exclude: ^(docs/gates/logs/|python/agentic-circuit/|compiler/|simulator/gfsim/|schemas/|examples/agentic-circuit/|tests/(python|mlir|cpp|integration|goldens)/agentic-circuit/|tools/agentic-circuit/|toolchains/|designs/blocks/BypassUnit/|designs/blocks/RegisterFile/) + exclude: ^(docs/gates/logs/|python/agentic-circuit/|compiler/|runtime/|schemas/|examples/agentic-circuit/|tests/(python|mlir|cpp|integration|goldens)/agentic-circuit/|tools/agentic-circuit/|toolchains/|designs/blocks/BypassUnit/|designs/blocks/RegisterFile/) - repo: https://github.com/psf/black rev: 24.10.0 hooks: - id: black # pyproject.toml force-excludes source-span-sensitive compiler fixtures. - exclude: ^(docs/gates/logs/|python/agentic-circuit/|compiler/|simulator/gfsim/|schemas/|examples/agentic-circuit/|tests/(python|mlir|cpp|integration|goldens)/agentic-circuit/|tools/agentic-circuit/|toolchains/) + exclude: ^(docs/gates/logs/|python/agentic-circuit/|compiler/|runtime/|schemas/|examples/agentic-circuit/|tests/(python|mlir|cpp|integration|goldens)/agentic-circuit/|tools/agentic-circuit/|toolchains/) - repo: https://github.com/DavidAnson/markdownlint-cli2 rev: v0.18.1 @@ -35,7 +35,7 @@ repos: hooks: - id: pyc-api-hygiene name: pyCircuit API hygiene gate - entry: python3 flows/tools/check_api_hygiene.py + entry: python3 tools/check_api_hygiene.py language: system files: ^(python/pycircuit/|examples/|docs/|README\.md$|CONTRIBUTING\.md$) exclude: ^(docs/gates/logs/|python/pycircuit/api_contract\.py$) diff --git a/CMakeLists.txt b/CMakeLists.txt index d6650ddc3..adb72bd86 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -22,7 +22,7 @@ if(PYC_BUILD_TESTING) enable_testing() endif() if(PYC_BUILD_RUNTIME_LIB) - add_subdirectory(simulator/gfsim) + add_subdirectory(runtime) endif() if(PYC_BUILD_COMPILER_DEV) find_package(Python3 REQUIRED COMPONENTS Interpreter) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index d8f9887fa..cef3914ed 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -25,7 +25,7 @@ also use Icarus where supported. python3 -m venv .venv source .venv/bin/activate python -m pip install -e ".[dev,docs]" -bash flows/scripts/pyc build +bash tools/pyc build ``` Build from this checkout and keep generated files in `.pycircuit_out/`. Do not @@ -37,8 +37,8 @@ Start with the smallest test proving the change. PR CI runs bounded Python, repository, formatting and documentation checks. API and example tests use: ```bash -bash flows/scripts/run_api_tests.sh --tier gate -bash flows/scripts/run_examples.sh --tier gate +bash tools/run_api_tests.sh --tier gate +bash tools/run_examples.sh --tier gate ``` Use `--tier nightly` for full registered coverage. Long oracle, mutation, diff --git a/README.md b/README.md index 6795f97e5..0f792adbb 100644 --- a/README.md +++ b/README.md @@ -107,7 +107,7 @@ cd pyCircuit python3 -m venv .venv source .venv/bin/activate python -m pip install -e . -PYC_BUILD_TESTING=OFF bash flows/scripts/pyc build +PYC_BUILD_TESTING=OFF bash tools/pyc build export PYC_TOOLCHAIN_ROOT="$PWD/.pycircuit_out/toolchain/install" export PATH="$PYC_TOOLCHAIN_ROOT/bin:$PATH" @@ -164,8 +164,8 @@ test dependencies, including GoogleTest and lit. With that testing build installed, run the bounded checks from the repository root: ```sh -bash flows/scripts/run_api_tests.sh --tier gate -bash flows/scripts/run_examples.sh --tier gate +bash tools/run_api_tests.sh --tier gate +bash tools/run_examples.sh --tier gate ``` For a nondefault build, set `PYC_BUILD_DIR` and `PYC_TOOLCHAIN_ROOT` as described diff --git a/benchmarks/README.md b/benchmarks/README.md index 72891e1df..7333d1a91 100644 --- a/benchmarks/README.md +++ b/benchmarks/README.md @@ -8,12 +8,12 @@ Historical benchmark implementations remain in Git, outside the active route. The source-unit workload measures shared definitions at 1/16/64 instances and distinct leaves at 1/8/32 sources. Its generator and driver are owned here and -in `flows/tools/`, respectively; see the [repository map](../docs/development/repository-layout.md). Generate +in `tools/`, respectively; see the [repository map](../docs/development/repository-layout.md). Generate fixtures with `benchmarks/source-units/generate.py`, or run the full public-driver measurement from the checkout: ```sh -python flows/tools/measure_source_build.py --prefix --output-dir .pycircuit_out/measurement-measure +python tools/measure_source_build.py --prefix --output-dir .pycircuit_out/measurement-measure ``` The output directory must be absent or empty. Prefix metadata must match the diff --git a/docs/development/repository-layout.md b/docs/development/repository-layout.md index f44ebbbc5..456db8768 100644 --- a/docs/development/repository-layout.md +++ b/docs/development/repository-layout.md @@ -12,12 +12,12 @@ verification; similar names do not imply duplicate implementations. | Types, hardware semantics or source lowering | `compiler/lib/Compiler/` and `compiler/lib/Dialect/ACIR/` | | Common IR transformations | `compiler/lib/Transforms/` | | Generated C++ or Verilog | Existing emitters in `compiler/lib/Compiler/` | -| Runtime lifecycle, scheduling or observations | `include/gfsim/` and `simulator/gfsim/` | +| Runtime lifecycle, scheduling or observations | `include/gfsim/` and `runtime/` | | Standard RTL storage leaves | `include/verilog/` | | Public build/install integration | Root `CMakeLists.txt`, `cmake/` and `packaging/` | | Reproduce a compiler or Runtime defect | The owning suite under `tests/` | | Add or document a complete example | `examples//` and `examples/catalog.json` | -| Run a gate or measure a build | `flows/scripts/` and `flows/tools/` | +| Run a gate or measure a build | `tools/` | | Regenerate maintained source data | `tools/` | ## Tracked top-level folders @@ -29,25 +29,24 @@ and retired compiler paths are absent from the active tree. | --- | --- | --- | | `.codex/` | Project-local management and independent-review skills; no product code. | [Governance](project-governance.md) | | `.github/` | CI, issue/PR templates, repository policy and release automation. Actions share setup; workflows retain their distinct trigger and permission boundaries. | [Repository management](repository-management.md) | -| `benchmarks/` | Source-unit workload generation. Measurement drivers remain in `flows/tools/`. | [Benchmark guide](https://github.com/PTO-ISA/pyCircuit/blob/main/benchmarks/README.md) | +| `benchmarks/` | Source-unit workload generation. Measurement drivers remain in `tools/`. | [Benchmark guide](https://github.com/PTO-ISA/pyCircuit/blob/main/benchmarks/README.md) | | `cmake/` | Installed package configuration and generated-module/example build helpers. | [Installation](../getting-started/installation.md) | | `compiler/` | Native MLIR compiler, common hardware IR and both emitters. | [Compiler pipeline](../architecture/compiler-pipeline.md) | | `docs/` | Current guides, language reference, branding and preserved contract history. | [Documentation home](../index.md) | | `examples/` | Flat, independently buildable hardware designs and their verification assets. | [Example catalog](https://github.com/PTO-ISA/pyCircuit/blob/main/examples/README.md) | -| `flows/` | Repository build, gate, preview and measurement orchestration. | [Testing and gates](testing-and-gates.md) | | `include/` | Installed C++ Runtime interfaces/templates and standard Verilog storage leaves. | [Runtime semantics](../architecture/simulation.md) | | `packaging/` | SDK identity, relocation, platform/release validation and wheel assembly. | [Build profiles](../getting-started/installation.md) | | `python/` | The single importable `pycircuit` package, directly under `python/`. | [Source-unit workflow](source-unit-workflow.md) | | `schemas/` | Current SDK, consumer-lock, release-index and version-map JSON formats. | [SDK contracts](https://github.com/PTO-ISA/pyCircuit/tree/main/schemas) | -| `simulator/` | Compiled implementation of the shared Runtime library. | [System execution](../architecture/system-execution.md) | +| `runtime/` | Compiled implementation of the shared Runtime library. | [System execution](../architecture/system-execution.md) | | `tests/` | Compiler, Runtime, public-flow, packaging and unit verification. | [Test ownership below](#test-ownership) | | `toolchains/` | Pinned LLVM source/version provenance. This is a reference record; build entrypoints perform their own exact version checks. | [LLVM pin](https://github.com/PTO-ISA/pyCircuit/blob/main/toolchains/llvm.lock.json) | -| `tools/` | Source-table generation and example-catalog maintenance. | [Tool guide](https://github.com/PTO-ISA/pyCircuit/blob/main/tools/README.md) | +| `tools/` | Build, gates, previews, measurements, source-data generation and example-catalog maintenance. | [Tool guide](https://github.com/PTO-ISA/pyCircuit/blob/main/tools/README.md) | ## Compiler and Runtime boundaries ```text -python/pycircuit/ syntax capture and public driver +python/pycircuit/ syntax capture and public driver compiler/ include/pycircuit/ public compiler headers and TableGen definitions lib/Compiler/ source resolution, lowering, link and emit @@ -58,22 +57,24 @@ compiler/ include/ gfsim/ installed Runtime headers and templates verilog/ installed managed storage leaves -simulator/gfsim/ compiled Runtime implementation +runtime/ compiled Runtime implementation ``` `python/pycircuit/` is the importable Python package. Package discovery starts at `python/`; redundant project and `src` wrapper layers are removed. -`include/gfsim/` and `simulator/gfsim/` jointly implement the Runtime component: +`include/gfsim/` and `runtime/` jointly implement the Runtime component: one contains public headers/templates, the other compiled sources. Moving them into one flat folder would change include and install paths without removing a responsibility. Likewise, `compiler/include/` serves compiler developers while root `include/` serves generated-model consumers. `cmake/` is installed for downstream builds; `compiler/cmake/` is private to the -native compiler build. `flows/tools/` runs repository operations; -`tools/` regenerates maintained source data. These are separate owners, -not alternate public compilation routes. +native compiler build. `tools/` groups repository maintenance commands in one +place, including build, verification, measurement and source-data generation. +Its [tool guide](https://github.com/PTO-ISA/pyCircuit/blob/main/tools/README.md) +lists each entrypoint. SDK and wheel assembly retain separate owners under +`packaging/`. The retired primitive-selection catalog, its standalone RTL variants and its private generator/report tests have been removed together. Current count-zero, @@ -130,7 +131,7 @@ performance work have separate trackers linked there. - Root `CMakeLists.txt` owns build, install and package targets. - Root `CMakePresets.json` provides current native build presets. -- `flows/scripts/pyc` and `flows/scripts/pyc.ps1` configure/build/install through +- `tools/pyc` and `tools/pyc.ps1` configure/build/install through that same graph. The API and example scripts select existing test tiers. - `pyproject.toml` owns the Python package, CLI and Python development checks. diff --git a/docs/development/testing-and-gates.md b/docs/development/testing-and-gates.md index 74ef707e9..cb6ed291e 100644 --- a/docs/development/testing-and-gates.md +++ b/docs/development/testing-and-gates.md @@ -10,11 +10,11 @@ A command, test file or historical acceptance entry is not a passing result. Use two entry points over the existing CTest, lit, pytest and example verifier: ```bash -bash flows/scripts/run_api_tests.sh --tier gate -bash flows/scripts/run_examples.sh --tier gate +bash tools/run_api_tests.sh --tier gate +bash tools/run_examples.sh --tier gate # Full registered coverage, including the gate subset: -bash flows/scripts/run_api_tests.sh --tier nightly -bash flows/scripts/run_examples.sh --tier nightly +bash tools/run_api_tests.sh --tier nightly +bash tools/run_examples.sh --tier nightly ``` For an existing nondefault build/install pair, export both paths before running @@ -25,7 +25,7 @@ export PYC_BUILD_DIR=/absolute/path/to/build export PYC_TOOLCHAIN_ROOT=/absolute/path/to/install cmake --build "$PYC_BUILD_DIR" --parallel 4 cmake --install "$PYC_BUILD_DIR" --prefix "$PYC_TOOLCHAIN_ROOT" -bash flows/scripts/run_api_tests.sh --tier gate +bash tools/run_api_tests.sh --tier gate ``` Both default to `gate`; `--list` reports the CTest selection without building or diff --git a/docs/gates/README.md b/docs/gates/README.md index 524daafc3..497aefd1e 100644 --- a/docs/gates/README.md +++ b/docs/gates/README.md @@ -31,8 +31,8 @@ PR CI runs bounded Python, repository and documentation checks. Full API and example coverage runs through the existing nightly entrypoints: ```bash -bash flows/scripts/run_api_tests.sh --tier nightly -bash flows/scripts/run_examples.sh --tier nightly +bash tools/run_api_tests.sh --tier nightly +bash tools/run_examples.sh --tier nightly ``` Nightly and release upload the run directory with `actions/upload-artifact`. diff --git a/examples/STANDARD.md b/examples/STANDARD.md index 03d546d09..6ce5b2c82 100644 --- a/examples/STANDARD.md +++ b/examples/STANDARD.md @@ -113,12 +113,12 @@ prefix does not accept a historical design or replace its full timing test. ## Test ownership and tiers -`flows/scripts/run_examples.sh --tier gate|nightly` owns example build and +`tools/run_examples.sh --tier gate|nightly` owns example build and behavior acceptance through the shared CMake helper and verifier. Gate runs the six smoke designs listed in `examples/CMakeLists.txt`; nightly runs the complete registered set. Long stimuli stay intact in nightly. API contract, negative-admission and compiler analysis fixtures belong under `tests/` and run -through `flows/scripts/run_api_tests.sh`, independently of example acceptance. +through `tools/run_api_tests.sh`, independently of example acceptance. ## Sampling and runner configuration diff --git a/pyproject.toml b/pyproject.toml index fff4bdf07..57cf3e545 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -111,7 +111,7 @@ ignore = ["E501"] "tests/system/fixtures/source_system/*.py" = ["N802", "F821"] "tests/system/fixtures/source_system/atomic_bench.py" = ["B011"] # Hardware assertion. "examples/**/*.py" = ["F401", "F841", "I001", "N803", "N806", "N999", "T201"] -"flows/tools/*.py" = ["T201"] +"tools/*.py" = ["T201"] "cmake/prepare_output.py" = ["T201"] "cmake/verify_example.py" = ["T201"] "packaging/wheel/get_wheel_plat_name.py" = ["T201"] diff --git a/simulator/gfsim/CMakeLists.txt b/runtime/CMakeLists.txt similarity index 100% rename from simulator/gfsim/CMakeLists.txt rename to runtime/CMakeLists.txt diff --git a/simulator/gfsim/model_input.cpp b/runtime/model_input.cpp similarity index 100% rename from simulator/gfsim/model_input.cpp rename to runtime/model_input.cpp diff --git a/simulator/gfsim/sim_executor.cpp b/runtime/sim_executor.cpp similarity index 100% rename from simulator/gfsim/sim_executor.cpp rename to runtime/sim_executor.cpp diff --git a/simulator/gfsim/system_runner.cpp b/runtime/system_runner.cpp similarity index 100% rename from simulator/gfsim/system_runner.cpp rename to runtime/system_runner.cpp diff --git a/tests/compiler/IR/CMakeLists.txt b/tests/compiler/IR/CMakeLists.txt index 6d7f8da32..4e40b360a 100644 --- a/tests/compiler/IR/CMakeLists.txt +++ b/tests/compiler/IR/CMakeLists.txt @@ -124,9 +124,9 @@ add_gfsim_test(ACIRObservationTests "${_runtime_tests}/ObservationTest.cpp") add_gfsim_test(ACIRSimExecutorTests "${_runtime_tests}/SimExecutorTest.cpp" "${_runtime_tests}/RunnerCallbacksTest.cpp" "${_runtime_tests}/RunnerObservationGroupsTest.cpp" - "${PYCIRCUIT_REPO_ROOT}/simulator/gfsim/system_runner.cpp" - "${PYCIRCUIT_REPO_ROOT}/simulator/gfsim/model_input.cpp" - "${PYCIRCUIT_REPO_ROOT}/simulator/gfsim/sim_executor.cpp") + "${PYCIRCUIT_REPO_ROOT}/runtime/system_runner.cpp" + "${PYCIRCUIT_REPO_ROOT}/runtime/model_input.cpp" + "${PYCIRCUIT_REPO_ROOT}/runtime/sim_executor.cpp") set(LLVM_EXTERNAL_LIT "" CACHE FILEPATH "Path to the executable LLVM lit test runner") if(NOT LLVM_EXTERNAL_LIT) diff --git a/tests/compiler/lit/CodeGen/Inputs/enum_carrier.py b/tests/compiler/lit/CodeGen/Inputs/enum_carrier.py index 9aab79b96..c543480f2 100644 --- a/tests/compiler/lit/CodeGen/Inputs/enum_carrier.py +++ b/tests/compiler/lit/CodeGen/Inputs/enum_carrier.py @@ -981,7 +981,7 @@ def check_cpp(name, label, data, templated=False): p for p in ( runtime_root / "lib/libpyc6_runtime.a", - runtime_root / "simulator/gfsim/libpyc6_runtime.a", + runtime_root / "runtime/libpyc6_runtime.a", ) if p.is_file() ) diff --git a/tests/compiler/lit/CodeGen/Inputs/queue-emission.py b/tests/compiler/lit/CodeGen/Inputs/queue-emission.py index 2b746d9e2..51a610589 100644 --- a/tests/compiler/lit/CodeGen/Inputs/queue-emission.py +++ b/tests/compiler/lit/CodeGen/Inputs/queue-emission.py @@ -48,7 +48,7 @@ repo / "include/verilog/fifo.v", Path(args.emitter).resolve(), Path(args.optimizer).resolve(), - Path(args.emitter).resolve().parent.parent / "simulator/gfsim/libpyc6_runtime.a", + Path(args.emitter).resolve().parent.parent / "runtime/libpyc6_runtime.a", ] initial_hashes = { str(p): hashlib.sha256(p.read_bytes()).hexdigest() for p in bound_inputs @@ -124,9 +124,7 @@ def native(name, define): sources = [ bundle / x["path"] for x in receipt["files"] if x["path"].endswith(".cpp") ] - runtime = ( - Path(args.emitter).resolve().parent.parent / "simulator/gfsim/libpyc6_runtime.a" - ) + runtime = Path(args.emitter).resolve().parent.parent / "runtime/libpyc6_runtime.a" runner = work / (name + "-runner") run( [ @@ -779,9 +777,7 @@ def row(clock, valid="1", take="0", reset=0, unknown=False): sources = [ work / "cpp" / x["path"] for x in receipt["files"] if x["path"].endswith(".cpp") ] - runtime = ( - Path(args.emitter).resolve().parent.parent / "simulator/gfsim/libpyc6_runtime.a" - ) + runtime = Path(args.emitter).resolve().parent.parent / "runtime/libpyc6_runtime.a" runner = work / "runner" run( [ diff --git a/tests/compiler/lit/Source/Inputs/bits-concat.py b/tests/compiler/lit/Source/Inputs/bits-concat.py index bde467b24..2612a978a 100644 --- a/tests/compiler/lit/Source/Inputs/bits-concat.py +++ b/tests/compiler/lit/Source/Inputs/bits-concat.py @@ -415,7 +415,7 @@ def Top(value: ac.u5) -> {"out": ac.u7}: ( path for path in ( - toolroot / "simulator/gfsim/libpyc6_runtime.a", + toolroot / "runtime/libpyc6_runtime.a", toolroot / "lib/libpyc6_runtime.a", ) if path.is_file() diff --git a/tests/compiler/lit/Source/Inputs/bits-count-zeros.py b/tests/compiler/lit/Source/Inputs/bits-count-zeros.py index 16a88ca89..0fa131894 100644 --- a/tests/compiler/lit/Source/Inputs/bits-count-zeros.py +++ b/tests/compiler/lit/Source/Inputs/bits-count-zeros.py @@ -655,7 +655,7 @@ def bind(): ( path for path in ( - toolroot / "simulator/gfsim/libpyc6_runtime.a", + toolroot / "runtime/libpyc6_runtime.a", toolroot / "lib/libpyc6_runtime.a", ) if path.is_file() diff --git a/tests/compiler/lit/Source/Inputs/bits-popcount.py b/tests/compiler/lit/Source/Inputs/bits-popcount.py index 153063ca5..7f8a87d55 100644 --- a/tests/compiler/lit/Source/Inputs/bits-popcount.py +++ b/tests/compiler/lit/Source/Inputs/bits-popcount.py @@ -561,7 +561,7 @@ def bind(): ( path for path in ( - toolroot / "simulator/gfsim/libpyc6_runtime.a", + toolroot / "runtime/libpyc6_runtime.a", toolroot / "lib/libpyc6_runtime.a", ) if path.is_file() diff --git a/tests/compiler/lit/Source/Inputs/bits-priority-encoding.py b/tests/compiler/lit/Source/Inputs/bits-priority-encoding.py index 09a74c478..62b0324b3 100644 --- a/tests/compiler/lit/Source/Inputs/bits-priority-encoding.py +++ b/tests/compiler/lit/Source/Inputs/bits-priority-encoding.py @@ -1055,7 +1055,7 @@ def Top(value: ac.u5) -> {"out": ac.u4}: ( p for p in ( - root / "simulator/gfsim/libpyc6_runtime.a", + root / "runtime/libpyc6_runtime.a", root / "lib/libpyc6_runtime.a", ) if p.is_file() diff --git a/tests/compiler/lit/Source/Inputs/bounded-for.py b/tests/compiler/lit/Source/Inputs/bounded-for.py index 751528d75..ac47ae08f 100644 --- a/tests/compiler/lit/Source/Inputs/bounded-for.py +++ b/tests/compiler/lit/Source/Inputs/bounded-for.py @@ -292,7 +292,7 @@ def compile_source(output, *, accepted=True, replace=False): runtime = next( path for path in ( - toolroot / "simulator/gfsim/libpyc6_runtime.a", + toolroot / "runtime/libpyc6_runtime.a", toolroot / "lib/libpyc6_runtime.a", ) if path.is_file() diff --git a/tests/compiler/lit/Source/Inputs/case-statements.py b/tests/compiler/lit/Source/Inputs/case-statements.py index 428ee0b70..6fe6c0e02 100644 --- a/tests/compiler/lit/Source/Inputs/case-statements.py +++ b/tests/compiler/lit/Source/Inputs/case-statements.py @@ -119,7 +119,7 @@ def managed_snapshot(path): next( p for p in ( - runtime_root / "simulator/gfsim/libpyc6_runtime.a", + runtime_root / "runtime/libpyc6_runtime.a", runtime_root / "lib/libpyc6_runtime.a", ) if p.is_file() diff --git a/tests/compiler/lit/Source/Inputs/defaults-composition.py b/tests/compiler/lit/Source/Inputs/defaults-composition.py index 746d79109..f37b6827b 100644 --- a/tests/compiler/lit/Source/Inputs/defaults-composition.py +++ b/tests/compiler/lit/Source/Inputs/defaults-composition.py @@ -76,7 +76,7 @@ def snapshot(directory): ( path for path in ( - toolroot / "simulator/gfsim/libpyc6_runtime.a", + toolroot / "runtime/libpyc6_runtime.a", toolroot / "lib/libpyc6_runtime.a", ) if path.is_file() diff --git a/tests/compiler/lit/Source/Inputs/dependent-width-binding.py b/tests/compiler/lit/Source/Inputs/dependent-width-binding.py index ffd6ceb28..4cfcb4b3e 100644 --- a/tests/compiler/lit/Source/Inputs/dependent-width-binding.py +++ b/tests/compiler/lit/Source/Inputs/dependent-width-binding.py @@ -448,7 +448,7 @@ def Top(en_a: ac.u1, en_b: ac.u1, da: ac.u8, db: ac.u8) -> Pair: path for path in ( Path(args.source_compiler).resolve().parent.parent - / "simulator/gfsim/libpyc6_runtime.a", + / "runtime/libpyc6_runtime.a", Path(args.source_compiler).resolve().parent.parent / "lib/libpyc6_runtime.a", ) diff --git a/tests/compiler/lit/Source/Inputs/direct-call-graph.py b/tests/compiler/lit/Source/Inputs/direct-call-graph.py index 10c9bcc61..bfe5bef4b 100644 --- a/tests/compiler/lit/Source/Inputs/direct-call-graph.py +++ b/tests/compiler/lit/Source/Inputs/direct-call-graph.py @@ -501,7 +501,7 @@ def compile_source(path, output, accepted=True, replace=False, interfaces=()): ( path for path in ( - toolroot / "simulator/gfsim/libpyc6_runtime.a", + toolroot / "runtime/libpyc6_runtime.a", toolroot / "lib/libpyc6_runtime.a", ) if path.is_file() diff --git a/tests/compiler/lit/Source/Inputs/enum-source.py b/tests/compiler/lit/Source/Inputs/enum-source.py index c5a6aa7db..6138d4d42 100644 --- a/tests/compiler/lit/Source/Inputs/enum-source.py +++ b/tests/compiler/lit/Source/Inputs/enum-source.py @@ -673,7 +673,7 @@ def declaration( runtime = next( p for p in ( - runtime_root / "simulator/gfsim/libpyc6_runtime.a", + runtime_root / "runtime/libpyc6_runtime.a", runtime_root / "lib/libpyc6_runtime.a", ) if p.is_file() @@ -3836,7 +3836,7 @@ def declaration( runtime = next( p for p in ( - runtime_root / "simulator/gfsim/libpyc6_runtime.a", + runtime_root / "runtime/libpyc6_runtime.a", runtime_root / "lib/libpyc6_runtime.a", ) if p.is_file() diff --git a/tests/compiler/lit/Source/Inputs/fixed-predicates.py b/tests/compiler/lit/Source/Inputs/fixed-predicates.py index ab94141b9..af253d64d 100644 --- a/tests/compiler/lit/Source/Inputs/fixed-predicates.py +++ b/tests/compiler/lit/Source/Inputs/fixed-predicates.py @@ -292,7 +292,7 @@ def Top(x: ac.u2, y: ac.u2, condition: ac.u1) -> ProbeResult: ( path for path in ( - toolroot / "simulator/gfsim/libpyc6_runtime.a", + toolroot / "runtime/libpyc6_runtime.a", toolroot / "lib/libpyc6_runtime.a", ) if path.is_file() diff --git a/tests/compiler/lit/Source/Inputs/fixed-slices.py b/tests/compiler/lit/Source/Inputs/fixed-slices.py index 6e5bf3d3f..f3bd8877f 100644 --- a/tests/compiler/lit/Source/Inputs/fixed-slices.py +++ b/tests/compiler/lit/Source/Inputs/fixed-slices.py @@ -538,7 +538,7 @@ def compile_source(output, accepted=True, replace=False): ( path for path in ( - toolroot / "simulator/gfsim/libpyc6_runtime.a", + toolroot / "runtime/libpyc6_runtime.a", toolroot / "lib/libpyc6_runtime.a", ) if path.is_file() diff --git a/tests/compiler/lit/Source/Inputs/fixed-unsigned-shifts.py b/tests/compiler/lit/Source/Inputs/fixed-unsigned-shifts.py index e780179c0..e48dc938f 100644 --- a/tests/compiler/lit/Source/Inputs/fixed-unsigned-shifts.py +++ b/tests/compiler/lit/Source/Inputs/fixed-unsigned-shifts.py @@ -335,7 +335,7 @@ def compile_source(output, accepted=True, replace=False): ( path for path in ( - toolroot / "simulator/gfsim/libpyc6_runtime.a", + toolroot / "runtime/libpyc6_runtime.a", toolroot / "lib/libpyc6_runtime.a", ) if path.is_file() diff --git a/tests/compiler/lit/Source/Inputs/fixed-widening.py b/tests/compiler/lit/Source/Inputs/fixed-widening.py index e05e60c9a..d943a6332 100644 --- a/tests/compiler/lit/Source/Inputs/fixed-widening.py +++ b/tests/compiler/lit/Source/Inputs/fixed-widening.py @@ -432,7 +432,7 @@ def compile_source(path, output, accepted=True, replace=False, interfaces=()): ( path for path in ( - toolroot / "simulator/gfsim/libpyc6_runtime.a", + toolroot / "runtime/libpyc6_runtime.a", toolroot / "lib/libpyc6_runtime.a", ) if path.is_file() diff --git a/tests/compiler/lit/Source/Inputs/frontend-branches.py b/tests/compiler/lit/Source/Inputs/frontend-branches.py index cb3804b01..2a0e98dfc 100644 --- a/tests/compiler/lit/Source/Inputs/frontend-branches.py +++ b/tests/compiler/lit/Source/Inputs/frontend-branches.py @@ -668,7 +668,7 @@ def drive_function(name, label): p for p in ( toolroot / "lib/libpyc6_runtime.a", - toolroot / "simulator/gfsim/libpyc6_runtime.a", + toolroot / "runtime/libpyc6_runtime.a", ) if p.is_file() ) diff --git a/tests/compiler/lit/Source/Inputs/history-pipeline/run.py b/tests/compiler/lit/Source/Inputs/history-pipeline/run.py index 0bc63b98c..b23ae6cda 100644 --- a/tests/compiler/lit/Source/Inputs/history-pipeline/run.py +++ b/tests/compiler/lit/Source/Inputs/history-pipeline/run.py @@ -43,7 +43,7 @@ def main(): runtime = next( path for path in ( - prefix / "simulator/gfsim/libpyc6_runtime.a", + prefix / "runtime/libpyc6_runtime.a", prefix / "lib/libpyc6_runtime.a", ) if path.is_file() diff --git a/tests/compiler/lit/Source/Inputs/history-resident/run.py b/tests/compiler/lit/Source/Inputs/history-resident/run.py index 2c27915a2..6b1db73a2 100644 --- a/tests/compiler/lit/Source/Inputs/history-resident/run.py +++ b/tests/compiler/lit/Source/Inputs/history-resident/run.py @@ -177,7 +177,7 @@ def main(): runtime = next( p for p in ( - prefix / "simulator/gfsim/libpyc6_runtime.a", + prefix / "runtime/libpyc6_runtime.a", prefix / "lib/libpyc6_runtime.a", ) if p.is_file() diff --git a/tests/compiler/lit/Source/Inputs/history-routed/run.py b/tests/compiler/lit/Source/Inputs/history-routed/run.py index ee373b552..65836c7b8 100644 --- a/tests/compiler/lit/Source/Inputs/history-routed/run.py +++ b/tests/compiler/lit/Source/Inputs/history-routed/run.py @@ -121,7 +121,7 @@ def main(): runtime = next( path for path in ( - prefix / "simulator/gfsim/libpyc6_runtime.a", + prefix / "runtime/libpyc6_runtime.a", prefix / "lib/libpyc6_runtime.a", ) if path.is_file() diff --git a/tests/compiler/lit/Source/Inputs/history-scheduling/run.py b/tests/compiler/lit/Source/Inputs/history-scheduling/run.py index bad9083be..52be1edb7 100644 --- a/tests/compiler/lit/Source/Inputs/history-scheduling/run.py +++ b/tests/compiler/lit/Source/Inputs/history-scheduling/run.py @@ -281,8 +281,8 @@ def main(): oracle_path, fixtures.parent.parent / "source-historical-scheduling.test", repo / "CMakeLists.txt", - repo / "simulator/gfsim/CMakeLists.txt", - *sorted((repo / "simulator/gfsim").glob("*.cpp")), + repo / "runtime/CMakeLists.txt", + *sorted((repo / "runtime").glob("*.cpp")), *sorted((repo / "include/gfsim").rglob("*")), *sorted((repo / "include/verilog").glob("*.v")), repo / "cmake/pycircuitConfig.cmake.in", diff --git a/tests/compiler/lit/Source/Inputs/history-slot-issue/run.py b/tests/compiler/lit/Source/Inputs/history-slot-issue/run.py index a80d6a048..aef9cf46d 100644 --- a/tests/compiler/lit/Source/Inputs/history-slot-issue/run.py +++ b/tests/compiler/lit/Source/Inputs/history-slot-issue/run.py @@ -102,7 +102,7 @@ def main(): p for p in ( prefix / "lib/libpyc6_runtime.a", - prefix / "simulator/gfsim/libpyc6_runtime.a", + prefix / "runtime/libpyc6_runtime.a", ) if p.is_file() ) diff --git a/tests/compiler/lit/Source/Inputs/multi-rule-writes.py b/tests/compiler/lit/Source/Inputs/multi-rule-writes.py index d0c0bc80e..c0bed2b98 100644 --- a/tests/compiler/lit/Source/Inputs/multi-rule-writes.py +++ b/tests/compiler/lit/Source/Inputs/multi-rule-writes.py @@ -1379,7 +1379,7 @@ def initialize(four=False): ( path for path in ( - toolroot / "simulator/gfsim/libpyc6_runtime.a", + toolroot / "runtime/libpyc6_runtime.a", toolroot / "lib/libpyc6_runtime.a", ) if path.is_file() diff --git a/tests/compiler/lit/Source/Inputs/pure-scalar-helpers.py b/tests/compiler/lit/Source/Inputs/pure-scalar-helpers.py index 1cbbb3b99..1258a569d 100644 --- a/tests/compiler/lit/Source/Inputs/pure-scalar-helpers.py +++ b/tests/compiler/lit/Source/Inputs/pure-scalar-helpers.py @@ -223,7 +223,7 @@ def managed_snapshot(path): runtime = next( p for p in ( - runtime_root / "simulator/gfsim/libpyc6_runtime.a", + runtime_root / "runtime/libpyc6_runtime.a", runtime_root / "lib/libpyc6_runtime.a", ) if p.is_file() diff --git a/tests/compiler/lit/Source/Inputs/pythonic-memory.py b/tests/compiler/lit/Source/Inputs/pythonic-memory.py index ced9ba773..55cb7233a 100644 --- a/tests/compiler/lit/Source/Inputs/pythonic-memory.py +++ b/tests/compiler/lit/Source/Inputs/pythonic-memory.py @@ -712,7 +712,7 @@ def feed( ( path for path in ( - toolroot / "simulator/gfsim/libpyc6_runtime.a", + toolroot / "runtime/libpyc6_runtime.a", toolroot / "lib/libpyc6_runtime.a", ) if path.is_file() diff --git a/tests/compiler/lit/Source/Inputs/queue-source.py b/tests/compiler/lit/Source/Inputs/queue-source.py index 72aa28153..ce659fa0d 100644 --- a/tests/compiler/lit/Source/Inputs/queue-source.py +++ b/tests/compiler/lit/Source/Inputs/queue-source.py @@ -75,7 +75,7 @@ def digest(path): for path in ( Path(args.source_compiler).resolve().parent.parent / "lib/libpyc6_runtime.a", Path(args.source_compiler).resolve().parent.parent - / "simulator/gfsim/libpyc6_runtime.a", + / "runtime/libpyc6_runtime.a", ) if path.is_file() ) @@ -259,7 +259,7 @@ def fault_checks(): runtime = next( path for path in ( - runtime_root / "simulator/gfsim/libpyc6_runtime.a", + runtime_root / "runtime/libpyc6_runtime.a", runtime_root / "lib/libpyc6_runtime.a", ) if path.is_file() @@ -683,7 +683,7 @@ def visit(family, path=(), families=families, owners=owners): runtime = next( path for path in ( - runtime_root / "simulator/gfsim/libpyc6_runtime.a", + runtime_root / "runtime/libpyc6_runtime.a", runtime_root / "lib/libpyc6_runtime.a", ) if path.is_file() diff --git a/tests/compiler/lit/Source/Inputs/record-projection-simplification.py b/tests/compiler/lit/Source/Inputs/record-projection-simplification.py index c0b5c94b6..88ab8183c 100644 --- a/tests/compiler/lit/Source/Inputs/record-projection-simplification.py +++ b/tests/compiler/lit/Source/Inputs/record-projection-simplification.py @@ -534,7 +534,7 @@ def native_compile( ( path for path in ( - toolroot / "simulator/gfsim/libpyc6_runtime.a", + toolroot / "runtime/libpyc6_runtime.a", toolroot / "lib/libpyc6_runtime.a", ) if path.is_file() diff --git a/tests/compiler/lit/Source/Inputs/rob-behavioral.py b/tests/compiler/lit/Source/Inputs/rob-behavioral.py index 6e6bec662..af8869c37 100644 --- a/tests/compiler/lit/Source/Inputs/rob-behavioral.py +++ b/tests/compiler/lit/Source/Inputs/rob-behavioral.py @@ -75,7 +75,7 @@ def snapshot(directory): ( path for path in ( - toolroot / "simulator/gfsim/libpyc6_runtime.a", + toolroot / "runtime/libpyc6_runtime.a", toolroot / "lib/libpyc6_runtime.a", ) if path.is_file() diff --git a/tests/compiler/lit/Source/Inputs/source-check-execution.py b/tests/compiler/lit/Source/Inputs/source-check-execution.py index 3a7d77b4d..0143a0bf5 100644 --- a/tests/compiler/lit/Source/Inputs/source-check-execution.py +++ b/tests/compiler/lit/Source/Inputs/source-check-execution.py @@ -73,7 +73,7 @@ def main(): runtime = next( path for path in ( - runtime_root / "simulator/gfsim/libpyc6_runtime.a", + runtime_root / "runtime/libpyc6_runtime.a", runtime_root / "lib/libpyc6_runtime.a", ) if path.is_file() diff --git a/tests/compiler/lit/Source/Inputs/source-checks.py b/tests/compiler/lit/Source/Inputs/source-checks.py index 3fe6be568..b65c12ff5 100644 --- a/tests/compiler/lit/Source/Inputs/source-checks.py +++ b/tests/compiler/lit/Source/Inputs/source-checks.py @@ -877,7 +877,7 @@ def generic(path, destination): runtime = next( path for path in ( - runtime_root / "simulator/gfsim/libpyc6_runtime.a", + runtime_root / "runtime/libpyc6_runtime.a", runtime_root / "lib/libpyc6_runtime.a", ) if path.is_file() diff --git a/tests/compiler/lit/Source/Inputs/source-historical-features.py b/tests/compiler/lit/Source/Inputs/source-historical-features.py index 2c4503064..31452d15e 100644 --- a/tests/compiler/lit/Source/Inputs/source-historical-features.py +++ b/tests/compiler/lit/Source/Inputs/source-historical-features.py @@ -158,7 +158,7 @@ def compile_unit(name, providers=()): runtime = next( path for path in ( - runtime_root / "simulator/gfsim/libpyc6_runtime.a", + runtime_root / "runtime/libpyc6_runtime.a", runtime_root / "lib/libpyc6_runtime.a", ) if path.is_file() diff --git a/tests/compiler/lit/Source/Inputs/source-historical-scalar-parameterized.py b/tests/compiler/lit/Source/Inputs/source-historical-scalar-parameterized.py index da29b7b2c..bdd36c0e8 100644 --- a/tests/compiler/lit/Source/Inputs/source-historical-scalar-parameterized.py +++ b/tests/compiler/lit/Source/Inputs/source-historical-scalar-parameterized.py @@ -114,7 +114,7 @@ def main(): runtime = next( path for path in ( - native_root / "simulator/gfsim/libpyc6_runtime.a", + native_root / "runtime/libpyc6_runtime.a", native_root / "lib/libpyc6_runtime.a", ) if path.is_file() diff --git a/tests/compiler/lit/Source/Inputs/source-observation-groups.py b/tests/compiler/lit/Source/Inputs/source-observation-groups.py index 775dff5bf..a558168f8 100644 --- a/tests/compiler/lit/Source/Inputs/source-observation-groups.py +++ b/tests/compiler/lit/Source/Inputs/source-observation-groups.py @@ -214,7 +214,7 @@ def main(): runtime = next( path for path in ( - prefix / "simulator/gfsim/libpyc6_runtime.a", + prefix / "runtime/libpyc6_runtime.a", prefix / "lib/libpyc6_runtime.a", ) if path.is_file() diff --git a/tests/compiler/lit/Source/Inputs/source_computed_outputs.py b/tests/compiler/lit/Source/Inputs/source_computed_outputs.py index c78ebfe2e..b8b101315 100644 --- a/tests/compiler/lit/Source/Inputs/source_computed_outputs.py +++ b/tests/compiler/lit/Source/Inputs/source_computed_outputs.py @@ -144,7 +144,7 @@ def snapshot(path): # Both supported layouts belong to the same checkout's compiler build/install. toolroot = Path(args.source_compiler).resolve().parent.parent candidates = [ - toolroot / "simulator/gfsim/libpyc6_runtime.a", + toolroot / "runtime/libpyc6_runtime.a", toolroot / "lib/libpyc6_runtime.a", ] runtime = next((p for p in candidates if p.is_file()), None) diff --git a/tests/compiler/lit/Source/Inputs/source_exact_integers.py b/tests/compiler/lit/Source/Inputs/source_exact_integers.py index 6e4dcc9dd..97cecf71e 100644 --- a/tests/compiler/lit/Source/Inputs/source_exact_integers.py +++ b/tests/compiler/lit/Source/Inputs/source_exact_integers.py @@ -98,7 +98,7 @@ def snapshot(path): ( p for p in ( - toolroot / "simulator/gfsim/libpyc6_runtime.a", + toolroot / "runtime/libpyc6_runtime.a", toolroot / "lib/libpyc6_runtime.a", ) if p.is_file() diff --git a/tests/compiler/lit/Source/Inputs/source_exact_select.py b/tests/compiler/lit/Source/Inputs/source_exact_select.py index 08dd41922..a56f719ec 100644 --- a/tests/compiler/lit/Source/Inputs/source_exact_select.py +++ b/tests/compiler/lit/Source/Inputs/source_exact_select.py @@ -98,7 +98,7 @@ def snapshot(path): ( p for p in ( - toolroot / "simulator/gfsim/libpyc6_runtime.a", + toolroot / "runtime/libpyc6_runtime.a", toolroot / "lib/libpyc6_runtime.a", ) if p.is_file() diff --git a/tests/compiler/lit/Source/Inputs/source_exact_shift.py b/tests/compiler/lit/Source/Inputs/source_exact_shift.py index e7587445c..251a59590 100644 --- a/tests/compiler/lit/Source/Inputs/source_exact_shift.py +++ b/tests/compiler/lit/Source/Inputs/source_exact_shift.py @@ -99,7 +99,7 @@ def snapshot(path): ( p for p in ( - toolroot / "simulator/gfsim/libpyc6_runtime.a", + toolroot / "runtime/libpyc6_runtime.a", toolroot / "lib/libpyc6_runtime.a", ) if p.is_file() diff --git a/tests/compiler/lit/Source/Inputs/source_local_bindings.py b/tests/compiler/lit/Source/Inputs/source_local_bindings.py index abca1ffa1..5eb45e4e2 100644 --- a/tests/compiler/lit/Source/Inputs/source_local_bindings.py +++ b/tests/compiler/lit/Source/Inputs/source_local_bindings.py @@ -105,7 +105,7 @@ def snapshot(path): ( p for p in ( - toolroot / "simulator/gfsim/libpyc6_runtime.a", + toolroot / "runtime/libpyc6_runtime.a", toolroot / "lib/libpyc6_runtime.a", ) if p.is_file() diff --git a/tests/compiler/lit/Source/Inputs/static-divrem.py b/tests/compiler/lit/Source/Inputs/static-divrem.py index 6fee651b6..99f5c9c80 100644 --- a/tests/compiler/lit/Source/Inputs/static-divrem.py +++ b/tests/compiler/lit/Source/Inputs/static-divrem.py @@ -513,7 +513,7 @@ def shift(bits, count): ( p for p in ( - toolroot / "simulator/gfsim/libpyc6_runtime.a", + toolroot / "runtime/libpyc6_runtime.a", toolroot / "lib/libpyc6_runtime.a", ) if p.is_file() diff --git a/tests/compiler/lit/Source/Inputs/table-methods.py b/tests/compiler/lit/Source/Inputs/table-methods.py index 1412c31fe..540e68beb 100644 --- a/tests/compiler/lit/Source/Inputs/table-methods.py +++ b/tests/compiler/lit/Source/Inputs/table-methods.py @@ -168,7 +168,7 @@ def managed_snapshot(path): runtime = next( p for p in ( - runtime_root / "simulator/gfsim/libpyc6_runtime.a", + runtime_root / "runtime/libpyc6_runtime.a", runtime_root / "lib/libpyc6_runtime.a", ) if p.is_file() diff --git a/tests/compiler/lit/Source/source-observation-native.test b/tests/compiler/lit/Source/source-observation-native.test index f9e0607d1..7e5198554 100644 --- a/tests/compiler/lit/Source/source-observation-native.test +++ b/tests/compiler/lit/Source/source-observation-native.test @@ -39,7 +39,7 @@ # STAGE: pyc_sink_->slots->Stage( # Build the generated DUT and run the native driver against it. -# RUN: RTLIB=$(dirname %pycircuit_source_unit)/../simulator/gfsim/libpyc6_runtime.a; test -f "$RTLIB" || RTLIB=$(dirname %pycircuit_source_unit)/../lib/libpyc6_runtime.a; %cxx -std=c++20 -O1 -I%src/include -I%t.dir/cpp %t.dir/observation_native_driver.cpp %t.dir/cpp/sources/native/observation_native.cpp "$RTLIB" -o %t.dir/observation_native_driver +# RUN: RTLIB=$(dirname %pycircuit_source_unit)/../runtime/libpyc6_runtime.a; test -f "$RTLIB" || RTLIB=$(dirname %pycircuit_source_unit)/../lib/libpyc6_runtime.a; %cxx -std=c++20 -O1 -I%src/include -I%t.dir/cpp %t.dir/observation_native_driver.cpp %t.dir/cpp/sources/native/observation_native.cpp "$RTLIB" -o %t.dir/observation_native_driver # RUN: %t.dir/observation_native_driver | %FileCheck %s --check-prefix=NATIVE # NATIVE: ok five descriptors configured # NATIVE: ok descriptors strictly increase by key diff --git a/tests/compiler/oracles/README.md b/tests/compiler/oracles/README.md index 3bd814e5c..de9d61c15 100644 --- a/tests/compiler/oracles/README.md +++ b/tests/compiler/oracles/README.md @@ -23,7 +23,7 @@ The queue migration docstrings were preserved in moving the text. Large model files are inherited code, not a new oracle framework; this extraction deliberately does not redesign or duplicate their algorithms. -Run through `flows/scripts/run_api_tests.sh --tier nightly` when validation is +Run through `tools/run_api_tests.sh --tier nightly` when validation is scheduled. The 2026-10-07 user-directed review/extraction does **not** run these oracles, generated DUT coverage or nightly. Syntax/AST checks do not establish behavioral acceptance of the moved files or changed checker assertions. diff --git a/tests/integration/source-preview/CMakeLists.txt b/tests/integration/source-preview/CMakeLists.txt index e4d3bdcc6..56d895eb0 100644 --- a/tests/integration/source-preview/CMakeLists.txt +++ b/tests/integration/source-preview/CMakeLists.txt @@ -103,7 +103,7 @@ add_custom_command(OUTPUT "${_final}" -o "${_final}" --replace DEPENDS ${_link_dependencies} ${_python_sources} "${_design_helper}" VERBATIM) -set(_materializer "${PYCIRCUIT_REPOSITORY_ROOT}/flows/tools/materialize_source_preview.py") +set(_materializer "${PYCIRCUIT_REPOSITORY_ROOT}/tools/materialize_source_preview.py") set(_artifacts "${CMAKE_BINARY_DIR}/artifacts") set(_stamp "${CMAKE_BINARY_DIR}/preview-artifacts.stamp") add_custom_command(OUTPUT "${_stamp}" @@ -123,13 +123,13 @@ add_custom_target(preview-artifacts DEPENDS "${_stamp}") add_custom_target(preview-build COMMAND "${CMAKE_COMMAND}" -S "${_artifacts}/cpp" -B "${CMAKE_BINARY_DIR}/model-cpp" -G Ninja - "-DPYCIRCUIT_RUNTIME_ROOT=${PYCIRCUIT_REPOSITORY_ROOT}/simulator/gfsim" + "-DPYCIRCUIT_RUNTIME_ROOT=${PYCIRCUIT_REPOSITORY_ROOT}/runtime" "-DPYCIRCUIT_TEST_CONSUMER=${PYCIRCUIT_TEST_CONSUMER}" -DCMAKE_EXPORT_COMPILE_COMMANDS=ON COMMAND "${CMAKE_COMMAND}" --build "${CMAKE_BINARY_DIR}/model-cpp" --parallel 4 COMMAND "${CMAKE_COMMAND}" -S "${_artifacts}/verilog" -B "${CMAKE_BINARY_DIR}/model-verilog" -G Ninja - "-DPYCIRCUIT_RUNTIME_ROOT=${PYCIRCUIT_REPOSITORY_ROOT}/simulator/gfsim" + "-DPYCIRCUIT_RUNTIME_ROOT=${PYCIRCUIT_REPOSITORY_ROOT}/runtime" "-DPYCIRCUIT_TEST_CONSUMER=${PYCIRCUIT_TEST_CONSUMER}" -DCMAKE_EXPORT_COMPILE_COMMANDS=ON COMMAND "${CMAKE_COMMAND}" --build "${CMAKE_BINARY_DIR}/model-verilog" --parallel 4 diff --git a/tests/system/test_model_abi.py b/tests/system/test_model_abi.py index 47f762385..2f0630a47 100644 --- a/tests/system/test_model_abi.py +++ b/tests/system/test_model_abi.py @@ -64,7 +64,7 @@ def _build_dut(build: Path, design: str, native: Path) -> tuple[Path, Path]: str(model_build), "-G", "Ninja", - "-DPYCIRCUIT_RUNTIME_ROOT=" + str(ROOT / "simulator/gfsim"), + "-DPYCIRCUIT_RUNTIME_ROOT=" + str(ROOT / "runtime"), ] ) source_preview._checked( @@ -311,7 +311,7 @@ def _build_host_fault_library( str(model_build), "-G", "Ninja", - "-DPYCIRCUIT_RUNTIME_ROOT=" + str(ROOT / "simulator/gfsim"), + "-DPYCIRCUIT_RUNTIME_ROOT=" + str(ROOT / "runtime"), ] ) source_preview._checked( diff --git a/tests/system/test_resource_runtime.py b/tests/system/test_resource_runtime.py index bd1736b50..e5abb67f2 100644 --- a/tests/system/test_resource_runtime.py +++ b/tests/system/test_resource_runtime.py @@ -16,7 +16,7 @@ pytestmark = pytest.mark.system ROOT = Path(__file__).resolve().parents[2] -MEASURER = ROOT / "flows/tools/measure_build_resources.py" +MEASURER = ROOT / "tools/measure_build_resources.py" INSTALL = Path( os.environ.get( "PYCIRCUIT_TEST_PREFIX", ROOT / ".pycircuit_out/measurement-04-install" diff --git a/tests/system/test_source_preview_workflow.py b/tests/system/test_source_preview_workflow.py index f510db15f..955a373f3 100644 --- a/tests/system/test_source_preview_workflow.py +++ b/tests/system/test_source_preview_workflow.py @@ -20,7 +20,7 @@ ROOT = Path(__file__).resolve().parents[2] FIXTURE = ROOT / "tests/integration/source-preview" -MATERIALIZER = ROOT / "flows/tools/materialize_source_preview.py" +MATERIALIZER = ROOT / "tools/materialize_source_preview.py" _ORACLE: ModuleType | None = None _RESET_REPLAY_SOURCE = r"""#include "gfsim/SimExecutor.h" #include "runner_metadata.hpp" @@ -332,7 +332,7 @@ def _build_materialized_models(artifacts: Path, build_root: Path) -> dict[str, P str(model_build), "-G", "Ninja", - "-DPYCIRCUIT_RUNTIME_ROOT=" + str(ROOT / "simulator/gfsim"), + "-DPYCIRCUIT_RUNTIME_ROOT=" + str(ROOT / "runtime"), "-DCMAKE_EXPORT_COMPILE_COMMANDS=ON", ] ) diff --git a/tests/unit/test_build_measurement.py b/tests/unit/test_build_measurement.py index 9c576af73..3448f45bd 100644 --- a/tests/unit/test_build_measurement.py +++ b/tests/unit/test_build_measurement.py @@ -13,7 +13,7 @@ pytestmark = pytest.mark.unit ROOT = Path(__file__).resolve().parents[2] -MEASUREMENT_TOOL = ROOT / "flows/tools/measure_source_build.py" +MEASUREMENT_TOOL = ROOT / "tools/measure_source_build.py" def _measurement_tool(): diff --git a/tests/unit/test_gate_topology.py b/tests/unit/test_gate_topology.py index db17e6332..5f42537cb 100644 --- a/tests/unit/test_gate_topology.py +++ b/tests/unit/test_gate_topology.py @@ -29,7 +29,7 @@ def test_pull_request_ci_is_python_only_and_deduplicates_api_hygiene() -> None: ci = _read(".github/workflows/ci.yml") assert "SKIP=pyc-api-hygiene pre-commit run --files" in ci - assert ci.count("flows/tools/check_api_hygiene.py") == 1 + assert ci.count("tools/check_api_hygiene.py") == 1 assert "pytest" in ci assert ci.count("mkdocs build --strict") == 1 @@ -37,7 +37,7 @@ def test_pull_request_ci_is_python_only_and_deduplicates_api_hygiene() -> None: "llvm.sh", "setup-verilator", "setup-native-test-tools", - "flows/scripts/pyc build", + "tools/pyc build", *FULL_CLOSURE_SCRIPTS, ): assert forbidden not in ci @@ -66,7 +66,7 @@ def test_native_tool_bootstrap_is_confined_to_existing_linux_closure_jobs() -> N build = next( index for index, step in enumerate(steps) - if "flows/scripts/pyc build" in step.get("run", "") + if "tools/pyc build" in step.get("run", "") ) assert python < installs[0] < build assert steps[python]["with"]["python-version"] == "3.14.6" @@ -107,19 +107,19 @@ def test_release_runs_each_closure_lane_and_repository_gate_once() -> None: release = _read(".github/workflows/release.yml") for script in FULL_CLOSURE_SCRIPTS: - assert release.count(f"bash flows/scripts/{script}") == 1, script + assert release.count(f"bash tools/{script}") == 1, script assert release.count("pytest tests/unit -m unit") == 1 - assert release.count("flows/tools/check_api_hygiene.py") == 1 - assert "flows/tools/check_decision_status.py" not in release + assert release.count("tools/check_api_hygiene.py") == 1 + assert "tools/check_decision_status.py" not in release assert release.count("mkdocs build --strict") == 1 assert release.count("pre-commit run --all-files") == 1 assert "SKIP=pyc-api-hygiene pre-commit run --all-files" in release - assert "PYC_BUILD_TESTING=ON bash flows/scripts/pyc build" in release + assert "PYC_BUILD_TESTING=ON bash tools/pyc build" in release assert '--build-dir "$PWD/.pycircuit_out/toolchain/build"' in release assert '--install-prefix "$PWD/.pycircuit_out/toolchain/install"' in release - assert "-DPYC_BUILD_COMPILER_DEV=ON" in _read("flows/scripts/pyc") + assert "-DPYC_BUILD_COMPILER_DEV=ON" in _read("tools/pyc") def test_release_build_verify_accept_publish_barriers_and_permissions() -> None: @@ -154,7 +154,7 @@ def test_release_build_verify_accept_publish_barriers_and_permissions() -> None: def test_api_and_example_entrypoints_are_separate_and_tiered() -> None: - scripts = {name: _read(f"flows/scripts/{name}") for name in FULL_CLOSURE_SCRIPTS} + scripts = {name: _read(f"tools/{name}") for name in FULL_CLOSURE_SCRIPTS} examples = scripts["run_examples.sh"] api = scripts["run_api_tests.sh"] assert "examples" in examples and "ctest" in examples @@ -174,11 +174,11 @@ def test_api_and_example_entrypoints_are_separate_and_tiered() -> None: "run_sims_nightly.sh", "run_semantic_regressions_v6.sh", ): - assert not (ROOT / "flows/scripts" / retired).exists() + assert not (ROOT / "tools" / retired).exists() for workflow in ("release.yml", "gates-nightly.yml"): text = _read(f".github/workflows/{workflow}") for script in FULL_CLOSURE_SCRIPTS: - assert text.count(f"bash flows/scripts/{script} --tier nightly") == 1 + assert text.count(f"bash tools/{script} --tier nightly") == 1 @pytest.mark.parametrize("script", FULL_CLOSURE_SCRIPTS) @@ -188,7 +188,7 @@ def test_entrypoints_reject_invalid_selection_before_toolchain_access( import subprocess result = subprocess.run( - ["bash", str(ROOT / "flows/scripts" / script), "--tier", "typo"], + ["bash", str(ROOT / "tools" / script), "--tier", "typo"], capture_output=True, text=True, timeout=5, @@ -263,7 +263,7 @@ def test_list_tests_rejects_empty_real_ctest_selection(tmp_path: Path) -> None: "-c", 'source "$1"; pyc_list_tests api "$2" "$3"', "gate-topology", - str(ROOT / "flows/scripts/lib.sh"), + str(ROOT / "tools/lib.sh"), ] env = {**os.environ, "PYC_PYTHON_EXECUTABLE": sys.executable} selected = subprocess.run( @@ -289,7 +289,7 @@ def test_list_tests_rejects_empty_real_ctest_selection(tmp_path: Path) -> None: def test_api_nightly_keeps_all_current_public_flow_oracles() -> None: - api = _read("flows/scripts/run_api_tests.sh") + api = _read("tools/run_api_tests.sh") declaration = re.search(r"nightly_python_tests=\((.*?)\)", api, re.DOTALL) assert declaration is not None listed = re.findall(r"tests/system/test_[a-z_]+\.py", declaration.group(1)) @@ -402,7 +402,7 @@ def test_windows_manifest_steps_check_native_exit_codes() -> None: def test_lanes_running_check_acir_install_ripgrep() -> None: """The release closure calls the current source compiler retirement gate.""" release = _read(".github/workflows/release.yml") - assert "flows/tools/check_frontend_retirement.py" in release + assert "tools/check_frontend_retirement.py" in release assert "run_agentic_circuit.sh" not in release @@ -431,7 +431,7 @@ def test_closure_scripts_do_not_pipe_python_into_an_early_exit_consumer() -> Non """ offenders: list[str] = [] - for script in sorted((ROOT / "flows/scripts").glob("*.sh")): + for script in sorted((ROOT / "tools").glob("*.sh")): for number, line in enumerate( script.read_text(encoding="utf-8").splitlines(), 1 ): diff --git a/tests/unit/test_generated_rtl_audit.py b/tests/unit/test_generated_rtl_audit.py index 0bdbdacd8..eabd5318e 100644 --- a/tests/unit/test_generated_rtl_audit.py +++ b/tests/unit/test_generated_rtl_audit.py @@ -8,7 +8,7 @@ pytestmark = pytest.mark.unit ROOT = Path(__file__).resolve().parents[2] -CHECKER = ROOT / "flows/tools/check_generated_rtl.py" +CHECKER = ROOT / "tools/check_generated_rtl.py" def run_checker( diff --git a/tests/unit/test_process_usage.py b/tests/unit/test_process_usage.py index b33e64587..8b78750dd 100644 --- a/tests/unit/test_process_usage.py +++ b/tests/unit/test_process_usage.py @@ -16,9 +16,9 @@ pytestmark = pytest.mark.unit ROOT = Path(__file__).resolve().parents[2] -USAGE_TOOL = ROOT / "flows/tools/process_usage.py" -RESOURCE_TOOL = ROOT / "flows/tools/measure_build_resources.py" -RESOURCE_TOOLS = ROOT / "flows/tools" +USAGE_TOOL = ROOT / "tools/process_usage.py" +RESOURCE_TOOL = ROOT / "tools/measure_build_resources.py" +RESOURCE_TOOLS = ROOT / "tools" STEMS = ["types", "leaf", "design_top"] diff --git a/tests/unit/test_release_evidence_and_platform_constraints.py b/tests/unit/test_release_evidence_and_platform_constraints.py index ad6d31a92..67abe2401 100644 --- a/tests/unit/test_release_evidence_and_platform_constraints.py +++ b/tests/unit/test_release_evidence_and_platform_constraints.py @@ -41,9 +41,7 @@ def test_release_uses_live_validation_and_uploads_untracked_logs() -> None: def test_release_retirement_gate_checks_the_single_public_driver_contract() -> None: - source = (ROOT / "flows/tools/check_frontend_retirement.py").read_text( - encoding="utf-8" - ) + source = (ROOT / "tools/check_frontend_retirement.py").read_text(encoding="utf-8") wheel_builder = (ROOT / "packaging/wheel/create_wheel.py").read_text( encoding="utf-8" ) diff --git a/tests/unit/test_repository_layout.py b/tests/unit/test_repository_layout.py index ea689d8d7..dbf06c300 100644 --- a/tests/unit/test_repository_layout.py +++ b/tests/unit/test_repository_layout.py @@ -9,22 +9,6 @@ ROOT = Path(__file__).resolve().parents[2] pytestmark = pytest.mark.unit -FLOW_TOOLS = { - "check_api_hygiene.py", - "check_generated_rtl.py", - "check_frontend_retirement.py", - "measure_source_build.py", - "process_usage.py", - "measure_build_resources.py", - "materialize_source_preview.py", - "summarize_gate_run.py", -} - -PYCIRCUIT_TOOLS = { - "example_catalog.py", - "generate_source_identifier_unicode.py", -} - def _tracked_paths() -> list[str]: return subprocess.run( @@ -43,26 +27,14 @@ def test_active_product_roots_are_documented() -> None: for root in ( "python/pycircuit/", "compiler/", - "simulator/gfsim/", + "runtime/", "examples/counter/", "tests/", - "flows/", + "tools/", ): assert f"`{root}`" in layout -def test_flow_and_product_tools_have_distinct_roots() -> None: - flow_tools = { - path.name for path in (ROOT / "flows/tools").glob("*.py") if path.is_file() - } - pycircuit_tools = { - path.name for path in (ROOT / "tools").glob("*.py") if path.is_file() - } - - assert flow_tools == FLOW_TOOLS - assert pycircuit_tools == PYCIRCUIT_TOOLS - - def test_package_discovery_excludes_retired_siblings_and_namespace_debris( tmp_path: Path, ) -> None: @@ -151,7 +123,7 @@ def test_host_sources_avoid_unprotected_int128() -> None: for directory in ( "include/gfsim", "compiler", - "simulator/gfsim", + "runtime", "tests/runtime", "tests/compiler", ): @@ -172,7 +144,7 @@ def test_cmake_package_exports_only_the_approved_runtime_and_compiler_components None ): config = (ROOT / "cmake/pycircuitConfig.cmake.in").read_text(encoding="utf-8") - runtime = (ROOT / "simulator/gfsim/CMakeLists.txt").read_text(encoding="utf-8") + runtime = (ROOT / "runtime/CMakeLists.txt").read_text(encoding="utf-8") root_cmake = (ROOT / "CMakeLists.txt").read_text(encoding="utf-8") assert "pycircuit::pyc6_runtime" in runtime diff --git a/tests/unit/test_retirement_presets.py b/tests/unit/test_retirement_presets.py index ea00ff8e6..361ce23ed 100644 --- a/tests/unit/test_retirement_presets.py +++ b/tests/unit/test_retirement_presets.py @@ -6,13 +6,14 @@ import importlib.util import json from pathlib import Path +from types import ModuleType import pytest pytestmark = pytest.mark.unit ROOT = Path(__file__).resolve().parents[2] PRESETS = ROOT / "CMakePresets.json" -RETIREMENT_GATE = ROOT / "flows/tools/check_frontend_retirement.py" +RETIREMENT_GATE = ROOT / "tools/check_frontend_retirement.py" RETIRED_TARGETS = ("pycc", "pyc-opt", "acc", "acc.py", "acir-opt") RETIRED_OPTIONS = ("PYC_BUILD_MLIR_TOOLS", "PYC_BUILD_AGENTIC_CIRCUIT_TESTS") @@ -32,12 +33,119 @@ def _write(path: Path, value: dict) -> None: path.write_text(json.dumps(value, indent=2) + "\n", encoding="utf-8") +@pytest.fixture +def isolated_production_scan( + tmp_path: Path, monkeypatch: pytest.MonkeyPatch +) -> tuple[ModuleType, Path, Path]: + gate = _gate() + tools = tmp_path / "tools" + tools.mkdir() + scanner = tools / "check_frontend_retirement.py" + scanner.write_text(RETIREMENT_GATE.read_text(encoding="utf-8"), encoding="utf-8") + monkeypatch.setattr(gate, "ROOT", tmp_path) + monkeypatch.setattr(gate, "PRODUCTION_ROOTS", (tools,)) + monkeypatch.setattr(gate, "__file__", str(scanner)) + monkeypatch.setattr(gate, "scan_cmake_presets", lambda _path: []) + return gate, scanner, tools + + +@pytest.fixture +def isolated_public_surface_scan( + tmp_path: Path, monkeypatch: pytest.MonkeyPatch +) -> tuple[ModuleType, Path]: + gate = _gate() + package = tmp_path / "python/pycircuit" + package.mkdir(parents=True) + package_init = package / "__init__.py" + package_init.write_text( + (ROOT / "python/pycircuit/__init__.py").read_text(encoding="utf-8"), + encoding="utf-8", + ) + monkeypatch.setattr(gate, "ROOT", tmp_path) + return gate, package_init + + def test_current_presets_pass_the_production_retirement_scan() -> None: failures = _gate().scan_cmake_presets(PRESETS) assert failures == [] +def test_current_production_tree_passes_the_retirement_scan() -> None: + assert _gate().scan_production() == [] + + +def test_current_static_public_surface_passes_the_retirement_scan() -> None: + # The checker owns the literal __all__ declaration. The later u1..u64 loop + # remains dynamic language-surface authority outside this mechanical test. + assert _gate().scan_public_surface() == [] + + +def test_public_surface_scan_rejects_a_removed_static_export( + isolated_public_surface_scan: tuple[ModuleType, Path], +) -> None: + gate, package_init = isolated_public_surface_scan + source = package_init.read_text(encoding="utf-8") + package_init.write_text(source.replace(' "struct",\n', "", 1), encoding="utf-8") + + failures = gate.scan_public_surface() + + assert len(failures) == 1 + assert "public Python exports differ" in failures[0] + assert "'struct'" not in failures[0] + + +def test_public_surface_scan_rejects_an_added_retired_static_export( + isolated_public_surface_scan: tuple[ModuleType, Path], +) -> None: + gate, package_init = isolated_public_surface_scan + source = package_init.read_text(encoding="utf-8") + package_init.write_text( + source.replace( + ' "module",\n', + ' "module",\n "agentic_circuit",\n', + 1, + ), + encoding="utf-8", + ) + + failures = gate.scan_public_surface() + + assert len(failures) == 1 + assert "public Python exports differ" in failures[0] + assert "'agentic_circuit'" in failures[0] + + +def test_scanner_rejection_patterns_do_not_flag_the_scanner_itself( + isolated_production_scan: tuple[ModuleType, Path, Path], +) -> None: + gate, scanner, _tools = isolated_production_scan + scanner_lines = scanner.read_text(encoding="utf-8").splitlines() + + assert any( + pattern.search(line) + for pattern, _description in gate.RETIRED_TEXT + for line in scanner_lines + ) + assert scanner.resolve() not in gate.production_files() + assert gate.scan_production() == [] + + +def test_retirement_scan_still_checks_other_tools_helpers( + isolated_production_scan: tuple[ModuleType, Path, Path], +) -> None: + gate, scanner, tools = isolated_production_scan + helper = tools / "maintenance_helper.py" + helper.write_text("QueueGraphGenerator\n", encoding="utf-8") + + production_files = gate.production_files() + failures = gate.scan_production() + + assert scanner.resolve() not in production_files + assert helper.resolve() in production_files + assert failures == ["tools/maintenance_helper.py:1: retired QueueGraph engine"] + + def test_production_scan_routes_cmake_presets_through_the_retirement_guard( tmp_path: Path, monkeypatch: pytest.MonkeyPatch ) -> None: diff --git a/tests/unit/test_toolchain_compiler_requirements.py b/tests/unit/test_toolchain_compiler_requirements.py index 507b41f54..582b9edbf 100644 --- a/tests/unit/test_toolchain_compiler_requirements.py +++ b/tests/unit/test_toolchain_compiler_requirements.py @@ -34,7 +34,7 @@ def test_runtime_only_configuration_does_not_find_compiler_dependencies() -> Non 0 ] - assert "add_subdirectory(simulator/gfsim)" in runtime_block + assert "add_subdirectory(runtime)" in runtime_block assert "find_package(LLVM" not in runtime_block assert "find_package(MLIR" not in runtime_block diff --git a/tools/README.md b/tools/README.md index 66539a7e8..e37dde65c 100644 --- a/tools/README.md +++ b/tools/README.md @@ -1,13 +1,30 @@ -# Repository maintenance tools +# Repository tools + +Build, validate and maintain the checkout from one directory. Run these commands +from the repository root; generated outputs belong under `.pycircuit_out/`. + +```sh +bash tools/pyc build +bash tools/run_api_tests.sh --tier gate +bash tools/run_examples.sh --tier gate +``` | Tool | Responsibility | | --- | --- | +| [pyc](pyc), [pyc.ps1](pyc.ps1) | Configure, build and install the toolchain on POSIX or Windows. | +| [install_llvm_and_build.sh](install_llvm_and_build.sh) | Discover a Homebrew LLVM installation and invoke the build helper. | +| [lib.sh](lib.sh) | Shared shell discovery, configuration and gate receipts. | +| [run_api_tests.sh](run_api_tests.sh), [run_examples.sh](run_examples.sh) | Select the existing gate or nightly test suites. | +| [check_api_hygiene.py](check_api_hygiene.py), [check_frontend_retirement.py](check_frontend_retirement.py) | Check the active Python surface and reject retired compilation routes. | +| [check_generated_rtl.py](check_generated_rtl.py) | Audit generated RTL. | +| [materialize_source_preview.py](materialize_source_preview.py) | Materialize source-owned preview artifacts. | +| [measure_source_build.py](measure_source_build.py), [measure_build_resources.py](measure_build_resources.py), [process_usage.py](process_usage.py) | Measure build costs and process resource use. | +| [summarize_gate_run.py](summarize_gate_run.py) | Summarize gate evidence. | | [example_catalog.py](example_catalog.py) | Render example navigation and publish verified generated-output excerpts. | | [generate_source_identifier_unicode.py](generate_source_identifier_unicode.py) | Regenerate pinned Unicode source-identifier tables and provenance. | -Build, validation and measurement orchestration lives in [`flows/`](../flows/), -installed CMake helpers in [`cmake/`](../cmake/), and SDK/wheel assembly in -[`packaging/`](../packaging/). These generators do not implement another compiler. -The public commands are `pycircuit compile`, `link`, `emit` and `run`. -See the [repository map](../docs/development/repository-layout.md) for owners. -Generated outputs belong under `.pycircuit_out/`. +Installed build helpers live in [`cmake/`](../cmake/); SDK and wheel assembly +live in [`packaging/`](../packaging/). The public compiler commands remain +`pycircuit compile`, `link`, `emit` and `run`. +See the [repository map](../docs/development/repository-layout.md) for source owners +and [testing guide](../docs/development/testing-and-gates.md) for gate selection. diff --git a/flows/tools/check_api_hygiene.py b/tools/check_api_hygiene.py similarity index 95% rename from flows/tools/check_api_hygiene.py rename to tools/check_api_hygiene.py index 12e9ffded..4993d52ca 100755 --- a/flows/tools/check_api_hygiene.py +++ b/tools/check_api_hygiene.py @@ -15,8 +15,8 @@ import sys from pathlib import Path -ROOT = Path(__file__).resolve().parents[2] -sys.path.insert(0, str(ROOT / "flows" / "tools")) +ROOT = Path(__file__).resolve().parents[1] +sys.path.insert(0, str(ROOT / "tools")) from check_frontend_retirement import scan_production # noqa: E402 DEFAULT_TARGETS = ("python/pycircuit",) diff --git a/flows/tools/check_frontend_retirement.py b/tools/check_frontend_retirement.py similarity index 93% rename from flows/tools/check_frontend_retirement.py rename to tools/check_frontend_retirement.py index 8647eda3d..c0d481548 100755 --- a/flows/tools/check_frontend_retirement.py +++ b/tools/check_frontend_retirement.py @@ -11,7 +11,7 @@ import sys from pathlib import Path -ROOT = Path(__file__).resolve().parents[2] +ROOT = Path(__file__).resolve().parents[1] PRODUCTION_ROOTS = ( ROOT / "python/pycircuit", ROOT / "compiler", @@ -24,10 +24,6 @@ ROOT / "tools", ROOT / ".github/workflows", ROOT / "pyproject.toml", - ROOT / "flows/scripts/pyc", - ROOT / "flows/scripts/pyc.ps1", - ROOT / "flows/scripts/lib.sh", - ROOT / "flows/scripts/install_llvm_and_build.sh", ) RETIRED_TEXT = ( (re.compile(r"AgenticCircuit::"), "retired CMake target alias"), @@ -145,7 +141,9 @@ def production_files() -> list[Path]: for part in path.parts ) ) - return sorted(set(files)) + # The checker contains the retired spellings as rejection data. All other + # maintenance tools remain production scan inputs, including new helpers. + return sorted(set(files) - {Path(__file__).resolve()}) def scan_production() -> list[str]: @@ -217,7 +215,31 @@ def scan_public_surface() -> list[str]: exported = set(ast.literal_eval(statement.value)) except (ValueError, TypeError): exported = set() - expected = {"module", "rule", "system", "log", "report"} + expected = { + "module", + "rule", + "struct", + "bits", + "table", + "queue", + "encoding", + "enum_to_bits", + "enum_from_bits", + "concat", + "popcount", + "count_leading_zeros", + "count_trailing_zeros", + "priority_encode", + "onehot_encode", + "system", + "dff", + "dffe", + "sync_mem", + "sync_mem_dp", + "byte_mem", + "log", + "report", + } if exported != expected: failures.append( f"public Python exports differ from the approved source surface: {sorted(exported or ())}" diff --git a/flows/tools/check_generated_rtl.py b/tools/check_generated_rtl.py similarity index 100% rename from flows/tools/check_generated_rtl.py rename to tools/check_generated_rtl.py diff --git a/flows/scripts/install_llvm_and_build.sh b/tools/install_llvm_and_build.sh similarity index 81% rename from flows/scripts/install_llvm_and_build.sh rename to tools/install_llvm_and_build.sh index 8df523cf1..335097c12 100644 --- a/flows/scripts/install_llvm_and_build.sh +++ b/tools/install_llvm_and_build.sh @@ -1,10 +1,10 @@ #!/usr/bin/env bash # 安装 LLVM(含 MLIR)+ 构建 pyCircuit source compiler/runtime -# 在终端中执行: bash flows/scripts/install_llvm_and_build.sh +# 在终端中执行: bash tools/install_llvm_and_build.sh set -euo pipefail SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)" -ROOT_DIR="$(cd -- "${SCRIPT_DIR}/../.." && pwd)" +ROOT_DIR="$(cd -- "${SCRIPT_DIR}/.." && pwd)" source "${SCRIPT_DIR}/lib.sh" echo "[1/3] 安装 LLVM 22、CMake、Ninja(Homebrew,LLVM 体积较大请耐心等待)..." @@ -22,6 +22,6 @@ fi echo "[3/3] 构建 source compiler/runtime..." cd "${ROOT_DIR}" -flows/scripts/pyc build +tools/pyc build -echo "完成。可运行: flows/scripts/pyc smoke" +echo "完成。可运行: tools/pyc smoke" diff --git a/flows/scripts/lib.sh b/tools/lib.sh similarity index 97% rename from flows/scripts/lib.sh rename to tools/lib.sh index 58a4b8da9..b16644285 100644 --- a/flows/scripts/lib.sh +++ b/tools/lib.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash set -euo pipefail -PYC_ROOT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")/../.." && pwd)" +PYC_ROOT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")/.." && pwd)" pyc_log() { echo "[pyc] $*"; } pyc_warn() { echo "[pyc][warn] $*" >&2; } diff --git a/flows/tools/materialize_source_preview.py b/tools/materialize_source_preview.py similarity index 99% rename from flows/tools/materialize_source_preview.py rename to tools/materialize_source_preview.py index f85b06fe1..fcd846610 100644 --- a/flows/tools/materialize_source_preview.py +++ b/tools/materialize_source_preview.py @@ -9,7 +9,7 @@ import tempfile from pathlib import Path -ROOT = Path(__file__).resolve().parents[2] +ROOT = Path(__file__).resolve().parents[1] sys.path[:0] = [ str(ROOT / "python"), ] diff --git a/flows/tools/measure_build_resources.py b/tools/measure_build_resources.py similarity index 99% rename from flows/tools/measure_build_resources.py rename to tools/measure_build_resources.py index f565668a5..041781c53 100644 --- a/flows/tools/measure_build_resources.py +++ b/tools/measure_build_resources.py @@ -26,8 +26,8 @@ from process_usage import run_sampled -REPO = Path(__file__).resolve().parents[2] -BUILD_MEASURER = REPO / "flows/tools/measure_source_build.py" +REPO = Path(__file__).resolve().parents[1] +BUILD_MEASURER = REPO / "tools/measure_source_build.py" GENERATOR = REPO / "benchmarks/source-units/generate.py" PARALLEL_JOBS = 4 SELECTED_SIZES = {"shared": (1, 16), "distinct": (1, 8)} @@ -1075,8 +1075,8 @@ def main() -> int: ) toolchain_metadata_hash = _sha256(metadata_path) measurement_inputs = [ - REPO / "flows/tools/process_usage.py", - REPO / "flows/tools/measure_build_resources.py", + REPO / "tools/process_usage.py", + REPO / "tools/measure_build_resources.py", REPO / "tests/unit/test_process_usage.py", REPO / "tests/system/test_resource_runtime.py", GENERATOR, diff --git a/flows/tools/measure_source_build.py b/tools/measure_source_build.py similarity index 99% rename from flows/tools/measure_source_build.py rename to tools/measure_source_build.py index 050627b88..30c1607f7 100644 --- a/flows/tools/measure_source_build.py +++ b/tools/measure_source_build.py @@ -25,7 +25,7 @@ from pathlib import Path from typing import Any -REPO = Path(__file__).resolve().parents[2] +REPO = Path(__file__).resolve().parents[1] GENERATOR = REPO / "benchmarks/source-units/generate.py" SIZES = {"shared": (1, 16, 64), "distinct": (1, 8, 32)} PARALLEL_JOBS = 4 diff --git a/flows/tools/process_usage.py b/tools/process_usage.py similarity index 100% rename from flows/tools/process_usage.py rename to tools/process_usage.py diff --git a/flows/scripts/pyc b/tools/pyc similarity index 93% rename from flows/scripts/pyc rename to tools/pyc index 16574c395..4aaeb05b0 100755 --- a/flows/scripts/pyc +++ b/tools/pyc @@ -2,13 +2,13 @@ set -euo pipefail SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)" -ROOT_DIR="$(cd -- "${SCRIPT_DIR}/../.." && pwd)" +ROOT_DIR="$(cd -- "${SCRIPT_DIR}/.." && pwd)" # shellcheck source=lib.sh source "${SCRIPT_DIR}/lib.sh" usage() { cat <<'EOF' -Usage: flows/scripts/pyc +Usage: tools/pyc build configures and installs the pyCircuit source compiler and pyc6 runtime. The compiler requires LLVM/MLIR 22.1.8 exactly. Set LLVM_DIR and MLIR_DIR, or @@ -79,7 +79,7 @@ case "${cmd}" in fi [[ -x "${PYC_TOOLCHAIN_ROOT}/bin/pycircuit" ]] || pyc_die "missing installed pycircuit driver under ${PYC_TOOLCHAIN_ROOT}" export PYC_TOOLCHAIN_ROOT - bash "${ROOT_DIR}/flows/scripts/run_examples.sh" --tier gate + bash "${ROOT_DIR}/tools/run_examples.sh" --tier gate ;; - *) pyc_die "unknown command: ${cmd} (run: flows/scripts/pyc help)" ;; + *) pyc_die "unknown command: ${cmd} (run: tools/pyc help)" ;; esac diff --git a/flows/scripts/pyc.ps1 b/tools/pyc.ps1 similarity index 96% rename from flows/scripts/pyc.ps1 rename to tools/pyc.ps1 index ce7e2cefa..e5ca24fc7 100644 --- a/flows/scripts/pyc.ps1 +++ b/tools/pyc.ps1 @@ -2,8 +2,8 @@ <# pyCircuit 6 Windows build wrapper. -PowerShell counterpart of flows/scripts/pyc plus the toolchain discovery in -flows/scripts/lib.sh. It provides the `build` subcommand with the same +PowerShell counterpart of tools/pyc plus the toolchain discovery in +tools/lib.sh. It provides the `build` subcommand with the same semantics as the bash wrapper: * configure the repository root with the Ninja generator, Release build, @@ -40,7 +40,7 @@ $ErrorActionPreference = "Stop" $script:PycircuitRequiredLlvmMajor = 22 $script:ScriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path -$script:RootDir = (Resolve-Path (Join-Path $script:ScriptDir "..\..")).Path +$script:RootDir = (Resolve-Path (Join-Path $script:ScriptDir "..")).Path function Write-PycLog { param([string]$Message) @@ -60,7 +60,7 @@ function Exit-PycDie { function Get-PycUsage { @" -Usage: flows/scripts/pyc.ps1 +Usage: tools/pyc.ps1 Commands: build Configure+build+install source compiler/runtime into a staged toolchain @@ -330,12 +330,12 @@ switch ($Command) { Invoke-BuildCommand -BuildArguments $Arguments } "smoke" { - Exit-PycDie "smoke is not supported on Windows: flows/scripts/run_examples.sh are bash-only flows. Run them on the Linux or macOS lane." + Exit-PycDie "smoke is not supported on Windows: tools/run_examples.sh are bash-only flows. Run them on the Linux or macOS lane." } { $_ -in @("-h", "--help", "help") } { Get-PycUsage | Write-Host } default { - Exit-PycDie "unknown command: $Command (run: flows/scripts/pyc.ps1 help)" + Exit-PycDie "unknown command: $Command (run: tools/pyc.ps1 help)" } } diff --git a/flows/scripts/run_api_tests.sh b/tools/run_api_tests.sh similarity index 100% rename from flows/scripts/run_api_tests.sh rename to tools/run_api_tests.sh diff --git a/flows/scripts/run_examples.sh b/tools/run_examples.sh similarity index 100% rename from flows/scripts/run_examples.sh rename to tools/run_examples.sh diff --git a/flows/tools/summarize_gate_run.py b/tools/summarize_gate_run.py similarity index 99% rename from flows/tools/summarize_gate_run.py rename to tools/summarize_gate_run.py index 49a91d849..26fc3cdb9 100644 --- a/flows/tools/summarize_gate_run.py +++ b/tools/summarize_gate_run.py @@ -14,7 +14,7 @@ def _repo_root() -> Path: - return Path(__file__).resolve().parents[2] + return Path(__file__).resolve().parents[1] KNOWN_SUMMARIES: tuple[tuple[str, str, str], ...] = (