Skip to content
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

Add Hyper Threading benchmarks workflow #1682

Closed
wants to merge 62 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
937c619
Add workflow first implementation
Mar 20, 2024
7464004
Update workflow
Mar 22, 2024
2c7444e
Add hyper-threading-workflow.sh
Mar 22, 2024
1facb6d
Merge branch 'main' into hyper-threading-workflow
pefontana Mar 22, 2024
b651af0
Uso bash to run script
Mar 22, 2024
3bd8141
Create binaries in workflows
Mar 22, 2024
d4e9972
fix binarie path
Mar 22, 2024
4d3251e
fix
Mar 22, 2024
4281ac5
fix format
Mar 22, 2024
9d49b99
Merge branch 'main' into hyper-threading-workflow
pefontana Mar 27, 2024
9a87095
fix
Mar 27, 2024
aaa82d9
restore
Mar 27, 2024
0e76d0f
Change workflow
Mar 27, 2024
9d8322b
download script
Mar 27, 2024
137ac18
fix
Mar 27, 2024
00cc9af
move script direc
Mar 27, 2024
c19ad79
fix 2
Mar 27, 2024
1459de0
Hyperfine -r 2
Mar 27, 2024
2ddbe4b
Add --showoutput flag to hyperfine
Mar 27, 2024
d436a63
shoow hyperfine
Mar 27, 2024
fb902a5
ouput
Mar 27, 2024
6498029
remove pwd
Mar 27, 2024
3c1d278
Remove _binary
Mar 27, 2024
f99d6c0
restore last commit
Mar 27, 2024
561f5ab
Merge branch 'main' into hyper-threading-workflow
pefontana Apr 8, 2024
71bc76c
see error
Apr 8, 2024
e16fba8
move script to root
Apr 8, 2024
ad99511
github.workflow
Apr 8, 2024
4ed1353
fix
Apr 8, 2024
6a46051
fix
Apr 8, 2024
f9532ba
Revert "fix"
Apr 8, 2024
cceb7b0
Revert "fix"
Apr 8, 2024
9a95d06
remove .sh
Apr 8, 2024
feef7a6
ls
Apr 8, 2024
859b791
fix
Apr 8, 2024
be05a72
Add folder
Apr 8, 2024
4e609e9
Merge branch 'main' into hyper-threading-workflow
pefontana Apr 8, 2024
7c302d0
echo
Apr 8, 2024
aec0abf
remove names
Apr 9, 2024
fdc4e4c
Revert "remove names"
Apr 9, 2024
a1e2cfc
Merge branch 'main' into hyper-threading-workflow
pefontana Apr 9, 2024
db984ee
Merge branch 'main' into hyper-threading-workflow
pefontana Apr 10, 2024
2971934
Merge branch 'main' into hyper-threading-workflow
pefontana Apr 10, 2024
f747bfd
fix
Apr 12, 2024
3ef874e
Remove artifatcs folder
Apr 12, 2024
84a75ac
use ls
Apr 12, 2024
2e7f9b0
Compile Programs just once
Apr 12, 2024
3c2d28e
cd in workflow
Apr 12, 2024
723508e
main
Apr 12, 2024
e986c6c
--show-output
Apr 12, 2024
2dafbc5
chmod +x
Apr 12, 2024
1ead8c8
r -1
Apr 12, 2024
c146eb4
Document script
Apr 12, 2024
ada80c1
hyperfine -r 1
Apr 12, 2024
3884759
hyperfine -r 2
Apr 12, 2024
4e6d75b
post comment
Apr 12, 2024
13a86d0
thread_counts=(1 2 4 6 8 16 )
Apr 12, 2024
206cf9e
remove binaries
Apr 12, 2024
37b35cf
Change text
Apr 12, 2024
cfd21d5
Add code style
Apr 12, 2024
e9f3a9f
Merge branch 'main' into hyper-threading-workflow
pefontana Apr 12, 2024
502017e
little fix
Apr 12, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
122 changes: 122 additions & 0 deletions .github/workflows/hyper_threading_benchmarks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
name: Benchmark Hyper Threading

on:
pull_request:
branches: [ '**' ]

jobs:
benchmark:
runs-on: ubuntu-latest
steps:
- name: Checkout PR
uses: actions/checkout@v2
with:
ref: ${{ github.head_ref }}

- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: '3.9'

- name: Install Dependencies
run: |
pip install -r requirements.txt
sudo apt update
sudo apt-get install -y hyperfine

- name: Install Rust
uses: dtolnay/[email protected]
with:
components: rustfmt, clippy

- name: Compile PR Version
run: |
cargo build --release -p hyper_threading
cp target/release/hyper_threading ${{ github.workspace }}/hyper_threading_pr
cp ./examples/hyper_threading/hyper-threading-workflow.sh ${{ github.workspace }}/hyper-threading-workflow.sh

- name: Upload PR Binary
uses: actions/upload-artifact@v4
with:
name: hyper_threading_pr_binary
path: ${{ github.workspace }}/hyper_threading_pr

- name: Upload Workflow Script
uses: actions/upload-artifact@v4
with:
name: hyper_threading_workflow_script
path: ${{ github.workspace }}/hyper-threading-workflow.sh


- name: Checkout Main Branch
uses: actions/checkout@v2
with:
ref: 'main'

- name: Compile Main Version
run: |
cargo build --release -p hyper_threading
cp target/release/hyper_threading ${{ github.workspace }}/hyper_threading_main

- name: Upload Main Binary
uses: actions/upload-artifact@v4
with:
name: hyper_threading_main_binary
path: ${{ github.workspace }}/hyper_threading_main

- name: Download hyper_threading_pr_binary
uses: actions/download-artifact@v4
with:
name: hyper_threading_pr_binary
path: ${{ github.workspace }}/

- name: Download hyper_threading_workflow_script
uses: actions/download-artifact@v4
with:
name: hyper_threading_workflow_script
path: ${{ github.workspace }}/

- name: Download hyper_threading_main_binary
uses: actions/download-artifact@v4
with:
name: hyper_threading_main_binary
path: ${{ github.workspace }}/


- name: Compile programs
run: make cairo_bench_programs

- name: Run Benchmarks
run: |
cd ${{ github.workspace }}
chmod +x ./hyper_threading_main
chmod +x ./hyper_threading_pr
chmod +x hyper-threading-workflow.sh
./hyper-threading-workflow.sh

- name: Compare Results
run: |
cat result.md

- name: Find comment
uses: peter-evans/find-comment@v2
id: fc
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: 'github-actions[bot]'
body-includes: "**Hyper Thereading Benchmark results**"

- name: Create comment
if: steps.fc.outputs.comment-id == ''
uses: peter-evans/create-or-update-comment@v3
with:
issue-number: ${{ github.event.pull_request.number }}
body-path: result.md

- name: Update comment
if: steps.fc.outputs.comment-id != ''
uses: peter-evans/create-or-update-comment@v3
with:
comment-id: ${{ steps.fc.outputs.comment-id }}
body-path: result.md
edit-mode: replace
17 changes: 17 additions & 0 deletions examples/hyper_threading/hyper-threading
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash

thread_counts=(1 2 4 6 8 10 12 16 24 32 )
binary="target/release/hyper_threading"


cmd="hyperfine -r 1"

# Build the command string with all thread counts
for threads in "${thread_counts[@]}"; do
# For hyperfine, wrap each command in 'sh -c' to correctly handle the environment variable
cmd+=" -n \"threads: ${threads}\" 'sh -c \"RAYON_NUM_THREADS=${threads} ${binary}\"'"
done

# Execute the hyperfine command
echo "Executing benchmark for all thread counts"
eval $cmd
34 changes: 34 additions & 0 deletions examples/hyper_threading/hyper-threading-workflow.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/bin/bash

# Define a list of RAYON_NUM_THREADS
thread_counts=(2 4)

# Define binary names
binaries=("hyper_threading_main" "hyper_threading_pr")

echo "**Hyper Thereading Benchmark results**" >> result.md
echo "\n \n \n " >> result.md

# Iter over thread_counts
for threads in "${thread_counts[@]}"; do
# Initialize hyperfine command
cmd="hyperfine -r 2"

# Add each binary to the command with the current threads value
for binary in "${binaries[@]}"; do
cmd+=" -n \"${binary} threads: ${threads}\" 'RAYON_NUM_THREADS=${threads} ./${binary}'"
done

# Execute
echo "Running benchmark for ${threads} threads"
echo "\n \n \n " >> result.md
echo $cmd >> result.md
eval $cmd >> result.md
echo "\n \n \n " >> result.md
done

{
echo '```'
cat result.md
echo '```'
} > temp_result.md && mv temp_result.md result.md
2 changes: 0 additions & 2 deletions examples/hyper_threading/hyper-threading.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@ binary="target/release/hyper_threading"

cmd="hyperfine -r 1"

# Build the command string with all thread counts
for threads in "${thread_counts[@]}"; do
# For hyperfine, wrap each command in 'sh -c' to correctly handle the environment variable
cmd+=" -n \"threads: ${threads}\" 'sh -c \"RAYON_NUM_THREADS=${threads} ${binary}\"'"
done

Expand Down
Loading