-
Notifications
You must be signed in to change notification settings - Fork 29
feat: snakemakeify hacker's delight #1549
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
bollu
wants to merge
15
commits into
main
Choose a base branch
from
snakehackersdel
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 10 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
04357cd
chore: peel the functionality in bv_evaluation to limit memory/time.
bollu 762e9a3
feat: snakify hackers delight
bollu 6273347
chore: refactor to move snakefile inside bv-evaluation
bollu f9703cc
Merge remote-tracking branch 'origin/main' into snakehackersdel
bollu 6dac61f
chore: add toplevel runner for hacker's delight
bollu d4ee6c2
chore: add pyproject.toml for uv
bollu 0946922
chore: add hacker's delight refactors discussed with Leo and Alex
bollu 3919cd4
chore: cleanup runner
bollu 75082fa
chore: add snakefile
bollu 4844fb8
chore: update toplevel-hackersdelight
bollu ba3043c
use absolute log paths
alexkeizer 9ab0081
ignore produced log files
alexkeizer 71e01bb
install uv and python312-numpy in flake.nix
alexkeizer 6f59125
add raw-data/HackersDelight/hackersdelight_err_data.csv to hdel_colle…
alexkeizer f14a9b1
Merge remote-tracking branch 'origin/main' into snakehackersdel
bollu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| 3.12 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,5 @@ | ||
| logs/ | ||
| __pycache__ | ||
| *.xz | ||
| *.jpeg | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,98 @@ | ||
| #!/usr/bin/env python3 | ||
| import argparse | ||
| import os | ||
| import random | ||
| import subprocess | ||
| import concurrent.futures | ||
| import shutil | ||
| import multiprocessing | ||
| import psutil | ||
| import time | ||
| import threading | ||
| import platform | ||
| from functools import partial | ||
| from pathlib import Path | ||
| import sys | ||
| from runwithlimits import * | ||
| from snakelib import * | ||
|
|
||
| configfile: "config.yaml" | ||
| workdir: "../" | ||
|
|
||
| gitroot=get_git_root() | ||
| sed=get_sed() | ||
| HACKERSDELIGHT_FILE_NAMES, = glob_wildcards(gitroot / "SSA/Projects/InstCombine/HackersDelight/{file}.lean") | ||
| hdel_nreps = config["hdel_nreps"] | ||
|
|
||
| onstart: | ||
| shell("elan --version") | ||
| shell("cd {gitroot} && lake exe cache get && lake build") | ||
| shell("uv --version") | ||
| shell("bitwuzla --version") | ||
|
|
||
| rule hdel_compare_make_lean: | ||
| input: | ||
| gitroot / "SSA/Projects/InstCombine/HackersDelight/{file}.lean" | ||
| output: | ||
| gitroot / "bv-evaluation/results/HackersDelight/{file}_{width}_{hdel_nreps}.lean" | ||
| log: | ||
| "logs/compare_make_lean_{file}_{width}_{hdel_nreps}.log" | ||
| params: | ||
| sed=sed, | ||
| shell: | ||
| "cp {input} {output} && " | ||
| "{params.sed} -i -e \"s/all_goals sorry/all_goals bv_compare'/g\" -e \"s/WIDTH/{wildcards.width}/g\" {output} " | ||
|
|
||
|
|
||
| rule hdel_compare_make_output: | ||
| params: | ||
| gitroot=gitroot, | ||
| timeout=config["hdel_timeout_sec"], | ||
| memout=config["hdel_memout_mb"], | ||
| input: | ||
| lambda wc: gitroot / f"bv-evaluation/results/HackersDelight/{wc.file}_{wc.width}_{hdel_nreps}.lean", | ||
| output: | ||
| gitroot / "bv-evaluation/results/HackersDelight/{file}_{width}_r{r}.txt" | ||
| log: | ||
| "logs/hdel_compare_make_output_{file}_{width}_{r}.log" | ||
|
alexkeizer marked this conversation as resolved.
Outdated
|
||
| resources: | ||
| # TODO: actually impose memory and time limit, using a python script. | ||
| shell: | ||
| "{params.gitroot}/bv-evaluation/runwithlimits.py " | ||
| " --timeout-sec={params.timeout} " | ||
| " --memout-mb={params.memout} " | ||
| " -- lake 2>&1 lean {input} | tee {log} > {output}" | ||
|
|
||
|
|
||
| # We can eventually split these, if we carefully understand the naming convention | ||
| # of 'collect' for hacker's delight. | ||
| # We currently make a monolithic job that runs both collect and plot, | ||
| # Since the naming convention is a little opaque to @bollu. | ||
| rule hdel_collect_and_plot: | ||
| input: | ||
| expand(gitroot / "bv-evaluation/results/HackersDelight/{file}_{width}_r{r}.txt", | ||
| file=HACKERSDELIGHT_FILE_NAMES, | ||
| width=config["hdel_bv_widths"], | ||
| r=range(hdel_nreps)) | ||
| params: | ||
| gitroot=gitroot, | ||
| nreps = lambda wc: hdel_nreps, | ||
| nthreads = lambda wc: config["hdel_nthreads"] | ||
| output: | ||
| tex=gitroot / "bv-evaluation/performance-hackersdelight.tex", | ||
| pdf_stacked=gitroot / "bv-evaluation/plots/bv_decide_stacked_perc_HackersDelight_bvw64.pdf" | ||
| # TODO: track the exact files generated by 'collect.py'. | ||
| # We currently just bother asking for the two outputs we care for. | ||
| log: | ||
| log_collect="logs/collect.log", | ||
| log_plot="logs/plot.log" | ||
| threads: 1 | ||
| shell: | ||
| "pushd {params.gitroot}/bv-evaluation && ./collect.py hackersdelight 2>&1 > {log.log_collect} && " | ||
| "./plot.py hackersdelight 2>&1 > {log.log_plot}" | ||
|
|
||
| rule all: | ||
| input: | ||
| rules.hdel_collect_and_plot.output | ||
| default_target: True | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,4 @@ | ||
| #!/usr/bin/env -S uv run | ||
| import argparse | ||
| import os | ||
| import csv | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| hdel_bv_widths: [4, 8, 16, 32, 64] # number of hackers delight widths. | ||
| hdel_nreps: 2 # number of repetitions to run hacker's delight tests. | ||
| hdel_timeout_sec: 1800 # timeout for hacker's delight test cases. | ||
| hdel_memout_mb: 8000 # memout for hacker's delight test cases. | ||
| hdel_nthreads: 8 # number of threads to use for hacker's delight tests. | ||
| seed: 42 # random number generator seed. | ||
|
|
||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,4 @@ | ||
| #!/usr/bin/env python3 | ||
|
|
||
| #!/usr/bin/env -S uv run | ||
| import argparse | ||
| import os | ||
| import pandas as pd | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| import argparse | ||
| import os | ||
| import random | ||
| import subprocess | ||
| import concurrent.futures | ||
| import shutil | ||
| import multiprocessing | ||
| import psutil | ||
| import time | ||
| import threading | ||
| import platform | ||
| from functools import partial | ||
| from pathlib import Path | ||
| import sys | ||
|
|
||
| def get_git_root() -> Path: | ||
| return Path(subprocess.check_output( ["git", "rev-parse", "--show-toplevel"]).decode().strip()) | ||
|
|
||
|
|
||
| def get_sed() -> str: | ||
| return "gsed" if platform.system() == "Darwin" else "sed" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| #!/usr/bin/env bash | ||
| uv run snakemake all --cores all --show-failed-logs | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,73 @@ | ||
| [project] | ||
| name = "lean-mlir" | ||
| version = "0.1.0" | ||
| description = "Add your description here" | ||
| readme = "README.md" | ||
| requires-python = ">=3.12" | ||
| dependencies = [ | ||
| "appdirs==1.4.4", | ||
| "argparse-dataclass==2.0.0", | ||
| "attrs==25.3.0", | ||
| "certifi==2025.8.3", | ||
| "charset-normalizer==3.4.3", | ||
| "conda-inject==1.3.2", | ||
| "configargparse==1.7.1", | ||
| "connection-pool==0.0.3", | ||
| "contourpy==1.3.1", | ||
| "cycler==0.12.1", | ||
| "docopt==0.6.2", | ||
| "docutils==0.22", | ||
| "dpath==2.2.0", | ||
| "fastjsonschema==2.21.2", | ||
| "fonttools==4.56.0", | ||
| "gitdb==4.0.12", | ||
| "gitpython==3.1.45", | ||
| "humanfriendly==10.0", | ||
| "idna==3.10", | ||
| "immutables==0.21", | ||
| "importlib-metadata==8.6.1", | ||
| "jinja2==3.1.6", | ||
| "jsonschema==4.25.1", | ||
| "jsonschema-specifications==2025.4.1", | ||
| "jupyter-core==5.8.1", | ||
| "kiwisolver==1.4.8", | ||
| "markupsafe==3.0.2", | ||
| "matplotlib==3.10.1", | ||
| "nbformat==5.10.4", | ||
| "num2words==0.5.14", | ||
| "numpy==2.2.2", | ||
| "packaging==24.2", | ||
| "pandas==2.2.3", | ||
| "pillow==11.1.0", | ||
| "platformdirs==4.3.8", | ||
| "polars==1.24.0", | ||
| "psutil==7.0.0", | ||
| "pulp==3.2.2", | ||
| "pyparsing==3.2.1", | ||
| "python-dateutil==2.9.0.post0", | ||
| "pytz==2025.1", | ||
| "pyyaml==6.0.2", | ||
| "referencing==0.36.2", | ||
| "requests==2.32.5", | ||
| "reretry==0.11.8", | ||
| "rpds-py==0.27.0", | ||
| "six==1.17.0", | ||
| "smart-open==7.3.0.post1", | ||
| "smmap==5.0.2", | ||
| "snakemake==9.9.0", | ||
| "snakemake-interface-common==1.21.0", | ||
| "snakemake-interface-executor-plugins==9.3.9", | ||
| "snakemake-interface-logger-plugins==1.2.4", | ||
| "snakemake-interface-report-plugins==1.2.0", | ||
| "snakemake-interface-storage-plugins==4.2.2", | ||
| "tabulate==0.9.0", | ||
| "throttler==1.2.2", | ||
| "traitlets==5.14.3", | ||
| "typing-extensions==4.15.0", | ||
| "tzdata==2025.1", | ||
| "urllib3==2.5.0", | ||
| "visidata==3.1.1", | ||
| "wrapt==1.17.3", | ||
| "yte==1.9.0", | ||
| "zipp==3.21.0", | ||
| ] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,21 +1,65 @@ | ||
| appdirs==1.4.4 | ||
| argparse-dataclass==2.0.0 | ||
| attrs==25.3.0 | ||
| certifi==2025.8.3 | ||
| charset-normalizer==3.4.3 | ||
| conda-inject==1.3.2 | ||
| ConfigArgParse==1.7.1 | ||
| connection_pool==0.0.3 | ||
| contourpy==1.3.1 | ||
| cycler==0.12.1 | ||
| docopt==0.6.2 | ||
| docutils==0.22 | ||
| dpath==2.2.0 | ||
| fastjsonschema==2.21.2 | ||
| fonttools==4.56.0 | ||
| gitdb==4.0.12 | ||
| GitPython==3.1.45 | ||
| humanfriendly==10.0 | ||
| idna==3.10 | ||
| immutables==0.21 | ||
| importlib_metadata==8.6.1 | ||
| Jinja2==3.1.6 | ||
| jsonschema==4.25.1 | ||
| jsonschema-specifications==2025.4.1 | ||
| jupyter_core==5.8.1 | ||
| kiwisolver==1.4.8 | ||
| MarkupSafe==3.0.2 | ||
| matplotlib==3.10.1 | ||
| nbformat==5.10.4 | ||
| num2words==0.5.14 | ||
| numpy==2.2.2 | ||
| packaging==24.2 | ||
| pandas==2.2.3 | ||
| pillow==11.1.0 | ||
| platformdirs==4.3.8 | ||
| polars==1.24.0 | ||
| psutil==7.0.0 | ||
| PuLP==3.2.2 | ||
| pyparsing==3.2.1 | ||
| python-dateutil==2.9.0.post0 | ||
| pytz==2025.1 | ||
| PyYAML==6.0.2 | ||
| referencing==0.36.2 | ||
| requests==2.32.5 | ||
| reretry==0.11.8 | ||
| rpds-py==0.27.0 | ||
| six==1.17.0 | ||
| smart_open==7.3.0.post1 | ||
| smmap==5.0.2 | ||
| snakemake==9.9.0 | ||
| snakemake-interface-common==1.21.0 | ||
| snakemake-interface-executor-plugins==9.3.9 | ||
| snakemake-interface-logger-plugins==1.2.4 | ||
| snakemake-interface-report-plugins==1.2.0 | ||
| snakemake-interface-storage-plugins==4.2.2 | ||
| tabulate==0.9.0 | ||
| throttler==1.2.2 | ||
| traitlets==5.14.3 | ||
| typing_extensions==4.15.0 | ||
| tzdata==2025.1 | ||
| urllib3==2.5.0 | ||
| visidata==3.1.1 | ||
| wrapt==1.17.3 | ||
| yte==1.9.0 | ||
| zipp==3.21.0 | ||
| num2words==0.5.14 |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be redirecting outputs to log files?
You might also want to print some prelude information before dumping
elan --versionstraight to the user.