From d301fb45e7fff75a96e3aabfae8f72d7fbc16c6f Mon Sep 17 00:00:00 2001 From: ailee37 <118076724+ailee37@users.noreply.github.com> Date: Wed, 4 Dec 2024 23:24:09 -0500 Subject: [PATCH 01/16] Create benchmark_1.lisp --- benchmarks/benchmark_1.lisp | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 benchmarks/benchmark_1.lisp diff --git a/benchmarks/benchmark_1.lisp b/benchmarks/benchmark_1.lisp new file mode 100644 index 0000000..fbee494 --- /dev/null +++ b/benchmarks/benchmark_1.lisp @@ -0,0 +1,3 @@ +(define (f x) (- 15 (+ x (+ 8 (* x 2))))) + +(print (let ((x 4)) (f x))) From af1a0a5eb71ee1b3f59d50c7c141491308396d15 Mon Sep 17 00:00:00 2001 From: ailee37 <118076724+ailee37@users.noreply.github.com> Date: Wed, 4 Dec 2024 23:29:28 -0500 Subject: [PATCH 02/16] Create benchmark_2.lisp --- benchmarks/benchmark_2.lisp | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 benchmarks/benchmark_2.lisp diff --git a/benchmarks/benchmark_2.lisp b/benchmarks/benchmark_2.lisp new file mode 100644 index 0000000..ed1820f --- /dev/null +++ b/benchmarks/benchmark_2.lisp @@ -0,0 +1,4 @@ +(define (cube x) + (*x (* x x))) + +(do (print (let ((x (read-num))) (+ (let ((y (+ 3 5))) (cube x)))))) From 73abe4a1dceaf05a74f069addffa2403aac94024 Mon Sep 17 00:00:00 2001 From: ailee37 <118076724+ailee37@users.noreply.github.com> Date: Wed, 4 Dec 2024 23:29:58 -0500 Subject: [PATCH 03/16] Create benchmark_3.lisp --- benchmarks/benchmark_3.lisp | 1 + 1 file changed, 1 insertion(+) create mode 100644 benchmarks/benchmark_3.lisp diff --git a/benchmarks/benchmark_3.lisp b/benchmarks/benchmark_3.lisp new file mode 100644 index 0000000..99b69ee --- /dev/null +++ b/benchmarks/benchmark_3.lisp @@ -0,0 +1 @@ +(print (if (> (* 9 8) (+ 3 7)) (+ 6 (+ 9 17)) (+ 13 (- 9 2)))) From e0d7452150e26f38dbded153b13945faf310347b Mon Sep 17 00:00:00 2001 From: Luke Choi <94572898+franchester4@users.noreply.github.com> Date: Thu, 5 Dec 2024 04:34:15 +0000 Subject: [PATCH 04/16] test fib --- benchmarks/fibonacci.lisp | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 benchmarks/fibonacci.lisp diff --git a/benchmarks/fibonacci.lisp b/benchmarks/fibonacci.lisp new file mode 100644 index 0000000..34a6c7f --- /dev/null +++ b/benchmarks/fibonacci.lisp @@ -0,0 +1,7 @@ +(define (fib n) + (if (= n 0) 1 + (if (= n 1) 1 + (+ (fib (- n 1)) (fib (- n 2))) +))) + +(print (fib 10)) \ No newline at end of file From ab7a35d15c18ecf784abe6c7dd774feeca5764a3 Mon Sep 17 00:00:00 2001 From: Richard Durkee <56232628+Richard-Durkee@users.noreply.github.com> Date: Thu, 5 Dec 2024 04:50:26 +0000 Subject: [PATCH 05/16] added benchmarks --- benchmarks/sum_list.lisp | 12 ++++++++++++ benchmarks/sum_of_squares.lisp | 21 +++++++++++++++++++++ benchmarks/unsorted_list_search.lisp | 23 +++++++++++++++++++++++ 3 files changed, 56 insertions(+) create mode 100644 benchmarks/sum_list.lisp create mode 100644 benchmarks/sum_of_squares.lisp create mode 100644 benchmarks/unsorted_list_search.lisp diff --git a/benchmarks/sum_list.lisp b/benchmarks/sum_list.lisp new file mode 100644 index 0000000..392cbe4 --- /dev/null +++ b/benchmarks/sum_list.lisp @@ -0,0 +1,12 @@ +(define (sum lst) + (if (empty? lst) + 0 + (+ (left lst) (sum (right lst))) + ) +) + +(let ((lst (pair 1 (pair 2 (pair 3 (pair 4 ())))))) + (do + (print (sum lst)) + ) +) diff --git a/benchmarks/sum_of_squares.lisp b/benchmarks/sum_of_squares.lisp new file mode 100644 index 0000000..d9f8b6b --- /dev/null +++ b/benchmarks/sum_of_squares.lisp @@ -0,0 +1,21 @@ +(define (square x) + (if (= x 0) + 0 + (+ x (square (- x 1))) + ) +) + +(define (sum-of-squares n) + (if (= n 0) + 0 + (+ (square n) (sum-of-squares (- n 1))) + ) +) + +(do + (print (sum-of-squares 0)) + (newline) + (print (sum-of-squares 5)) + (newline) + (print (sum-of-squares 10)) +) \ No newline at end of file diff --git a/benchmarks/unsorted_list_search.lisp b/benchmarks/unsorted_list_search.lisp new file mode 100644 index 0000000..e3df195 --- /dev/null +++ b/benchmarks/unsorted_list_search.lisp @@ -0,0 +1,23 @@ +(define (search list target) + (if (empty? list) + false + (if (= (left list) target) + 0 + (let ((index (search (right list) target))) + (if index + (+ 1 index) + false ) + ) + ) + ) +) + +(let ((lst (pair 1 (pair 2 (pair 3 (pair 4 ())))))) + (do + (print (search lst 1)) + (newline) + (print (search lst 0)) + (newline) + (print (search lst 4)) + ) +) \ No newline at end of file From 1514f2eaf8c60253990a68393349cbd912629e10 Mon Sep 17 00:00:00 2001 From: Woody Hulse Date: Thu, 5 Dec 2024 04:56:07 +0000 Subject: [PATCH 06/16] benchmark examples --- benchmarks/whulse-both.lisp | 37 ++++++++++++++++++++++++++++ benchmarks/whulse-constant-prop.lisp | 13 ++++++++++ benchmarks/whulse-inlining.lisp | 25 +++++++++++++++++++ 3 files changed, 75 insertions(+) create mode 100644 benchmarks/whulse-both.lisp create mode 100644 benchmarks/whulse-constant-prop.lisp create mode 100644 benchmarks/whulse-inlining.lisp diff --git a/benchmarks/whulse-both.lisp b/benchmarks/whulse-both.lisp new file mode 100644 index 0000000..b6202d7 --- /dev/null +++ b/benchmarks/whulse-both.lisp @@ -0,0 +1,37 @@ +(define (c0) 0) +(define (c1) 1) +(define (c2) 2) +(define (c3) 3) +(define (c4) 4) +(define (c5) 5) +(define (c6) 6) +(define (c7) 7) +(define (c8) 8) +(define (c9) 9) +(define (c10) 10) + +(define (add-c1-c2) (+ (c1) (c2))) +(define (add-c3-c4) (+ (c3) (c4))) +(define (add-c5-c6) (+ (c5) (c6))) + +(define (sum1) (+ (add-c1-c2) (add-c3-c4))) +(define (sum2) (+ (sum1) (add-c5-c6))) +(define (total-sum) (+ (sum2) (c7))) + +(define (funcA) (+ (c1) (c2))) +(define (funcB) (+ (funcA) (c3))) +(define (funcC) (+ (funcB) (c4))) +(define (funcD) (+ (funcC) (funcA))) +(define (funcE) (+ (funcD) (funcC))) +(define (funcF) (+ (funcE) (funcD))) + +(let ((v1 (funcF))) + (let ((v2 (if (= v1 30) false true))) + (if v2 + (let ((v3 (funcE))) + (let ((v4 (+ v3 v1))) + (let ((v5 (- v4 (c5)))) + (if (= v5 54) + (print v5) + (print 0))))) + (print 0)))) \ No newline at end of file diff --git a/benchmarks/whulse-constant-prop.lisp b/benchmarks/whulse-constant-prop.lisp new file mode 100644 index 0000000..cc7d4be --- /dev/null +++ b/benchmarks/whulse-constant-prop.lisp @@ -0,0 +1,13 @@ +(define (decrement x) + (sub1 x)) + +(define (add y z) + (+ y z)) + +(define (fib n) + (if (< n 2) + n + (add (fib (decrement n)) (fib (decrement (decrement n)))))) + +(let ((result (fib 30))) + (print result)) \ No newline at end of file diff --git a/benchmarks/whulse-inlining.lisp b/benchmarks/whulse-inlining.lisp new file mode 100644 index 0000000..5f2e00c --- /dev/null +++ b/benchmarks/whulse-inlining.lisp @@ -0,0 +1,25 @@ +(define (increment x) + (add1 x)) + +(define (computesum n) + (if (= n 0) + 0 + (+ (increment n) (computesum (sub1 n))))) + +(define (computeaccumulate n) + (if (= n 0) + 0 + (+ (increment n) (computeaccumulate (sub1 n))))) + +(define (computedoublesum n) + (if (= n 0) + 0 + (+ (+ (increment n) (increment n)) (computedoublesum (sub1 n))))) + +(let ((resultsum (computesum 1000))) + (let ((resultaccumulate (computeaccumulate 1000))) + (let ((resultdoublesum (computedoublesum 1000))) + (print (+ resultsum (+ resultaccumulate resultdoublesum))) + ) + ) +) \ No newline at end of file From 017953466c510de96dbb3a5367dee767f8ef97bd Mon Sep 17 00:00:00 2001 From: Luke Choi <94572898+franchester4@users.noreply.github.com> Date: Thu, 5 Dec 2024 05:00:47 +0000 Subject: [PATCH 07/16] add bench --- benchmarks/fibonacci.lisp | 7 ------- benchmarks/lchoi-inline.lisp | 3 +++ benchmarks/lchoi-prop.lisp | 4 ++++ benchmarks/lchoi-unroll.lisp | 4 ++++ 4 files changed, 11 insertions(+), 7 deletions(-) delete mode 100644 benchmarks/fibonacci.lisp create mode 100644 benchmarks/lchoi-inline.lisp create mode 100644 benchmarks/lchoi-prop.lisp create mode 100644 benchmarks/lchoi-unroll.lisp diff --git a/benchmarks/fibonacci.lisp b/benchmarks/fibonacci.lisp deleted file mode 100644 index 34a6c7f..0000000 --- a/benchmarks/fibonacci.lisp +++ /dev/null @@ -1,7 +0,0 @@ -(define (fib n) - (if (= n 0) 1 - (if (= n 1) 1 - (+ (fib (- n 1)) (fib (- n 2))) -))) - -(print (fib 10)) \ No newline at end of file diff --git a/benchmarks/lchoi-inline.lisp b/benchmarks/lchoi-inline.lisp new file mode 100644 index 0000000..f20e18d --- /dev/null +++ b/benchmarks/lchoi-inline.lisp @@ -0,0 +1,3 @@ +(define (f x) (* x x)) +(define (g y) (* (f y) (f y))) +(print (* (g 2) (g 2))) \ No newline at end of file diff --git a/benchmarks/lchoi-prop.lisp b/benchmarks/lchoi-prop.lisp new file mode 100644 index 0000000..d9c4487 --- /dev/null +++ b/benchmarks/lchoi-prop.lisp @@ -0,0 +1,4 @@ +(let ((x (- 5 4)) + (let ((y (* x 4)) + (let ((z (* x y)) + (print (+ x (+ y z))))))))) \ No newline at end of file diff --git a/benchmarks/lchoi-unroll.lisp b/benchmarks/lchoi-unroll.lisp new file mode 100644 index 0000000..76a875c --- /dev/null +++ b/benchmarks/lchoi-unroll.lisp @@ -0,0 +1,4 @@ +(define (leftshift num bits) + (if (< bits 1) num (* 2 (leftshift num (- bits 1))))) + +(print (leftshift 1 11)) \ No newline at end of file From 35fb0b3cf4ca4b770f4fad6551321655a7362372 Mon Sep 17 00:00:00 2001 From: Rob Lewis Date: Thu, 5 Dec 2024 10:57:40 -0500 Subject: [PATCH 08/16] remove overflowing test --- benchmarks/inline-test.lisp | 67 ------------------------------------- 1 file changed, 67 deletions(-) delete mode 100644 benchmarks/inline-test.lisp diff --git a/benchmarks/inline-test.lisp b/benchmarks/inline-test.lisp deleted file mode 100644 index d97ba43..0000000 --- a/benchmarks/inline-test.lisp +++ /dev/null @@ -1,67 +0,0 @@ -(define (triple x) (+ x (+ x x))) -(define (increment x) (+ x 1)) -(print - (triple (increment - (triple (increment - (triple (increment - (triple (increment - (triple (increment - (triple (increment - (triple (increment - (triple (increment - (triple (increment - (triple (increment - (triple (increment - (triple (increment - (triple (increment - (triple (increment - (triple (increment - (triple (increment - (triple (increment - (triple (increment - (triple (increment - (triple (increment - (triple (increment - (triple (increment - (triple (increment - (triple (increment - (triple (increment - (triple (increment - (triple (increment - (triple (increment - (triple (increment - (triple (increment - (triple (increment - (triple (increment - (triple (increment - (triple (increment - (triple (increment - (triple (increment - (triple (increment - (triple (increment - (triple (increment - (triple (increment - (triple (increment - (triple (increment - (triple (increment - (triple (increment - (triple (increment - (triple (increment - (triple (increment - (triple (increment - (triple (increment - (triple (increment - (triple (increment - (triple (increment - (triple (increment - (triple (increment - (triple (increment - (triple (increment - (triple (increment - (triple (increment - (triple (increment - (triple (increment - (triple (increment - (triple (increment - (triple (increment - (triple (increment 3))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))) From b7f80f9521df06a904b9714613f30ef97200d38c Mon Sep 17 00:00:00 2001 From: Rob Lewis Date: Thu, 5 Dec 2024 15:11:37 -0500 Subject: [PATCH 09/16] update ci action again --- .github/workflows/ci.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6bfe201..569e5d3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -23,7 +23,9 @@ jobs: uses: actions/checkout@v4 with: path: 'hw/benchmarks' - ref: ${{ github.event.pull_request.merge_commit_sha }} + ref: ${{ github.event.pull_request.head.sha }} + - name: echo commit + run: echo "sha is ${{ github.event.pull_request.head.sha }}" - name: Run benchmarks working-directory: 'hw/benchmarks' run: chmod -R 1777 ../ && su - cs1260_user -c "cd $(pwd) && eval \$(opam env) && python3 bench.py --repeat 1" From 1f19f9150cebc05fe05abd9fcf1d83ea3d67fee2 Mon Sep 17 00:00:00 2001 From: Rob Lewis Date: Thu, 5 Dec 2024 15:12:22 -0500 Subject: [PATCH 10/16] no mul --- benchmarks/lchoi-inline.lisp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/benchmarks/lchoi-inline.lisp b/benchmarks/lchoi-inline.lisp index f20e18d..2a0ea2a 100644 --- a/benchmarks/lchoi-inline.lisp +++ b/benchmarks/lchoi-inline.lisp @@ -1,3 +1,3 @@ -(define (f x) (* x x)) -(define (g y) (* (f y) (f y))) -(print (* (g 2) (g 2))) \ No newline at end of file +(define (f x) (+ x x)) +(define (g y) (+ (f y) (f y))) +(print (+ (g 2) (g 2))) \ No newline at end of file From 1822d59a315da91bd053074f34e53cf021a49e78 Mon Sep 17 00:00:00 2001 From: Rob Lewis Date: Thu, 5 Dec 2024 15:16:24 -0500 Subject: [PATCH 11/16] no mul --- benchmarks/benchmark_1.lisp | 2 +- benchmarks/benchmark_2.lisp | 2 +- benchmarks/benchmark_3.lisp | 2 +- benchmarks/lchoi-prop.lisp | 4 ++-- benchmarks/lchoi-unroll.lisp | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/benchmarks/benchmark_1.lisp b/benchmarks/benchmark_1.lisp index fbee494..84ce469 100644 --- a/benchmarks/benchmark_1.lisp +++ b/benchmarks/benchmark_1.lisp @@ -1,3 +1,3 @@ -(define (f x) (- 15 (+ x (+ 8 (* x 2))))) +(define (f x) (- 15 (+ x (+ 8 (- x 2))))) (print (let ((x 4)) (f x))) diff --git a/benchmarks/benchmark_2.lisp b/benchmarks/benchmark_2.lisp index ed1820f..f043ba1 100644 --- a/benchmarks/benchmark_2.lisp +++ b/benchmarks/benchmark_2.lisp @@ -1,4 +1,4 @@ (define (cube x) - (*x (* x x))) + (+x (+ x x))) (do (print (let ((x (read-num))) (+ (let ((y (+ 3 5))) (cube x)))))) diff --git a/benchmarks/benchmark_3.lisp b/benchmarks/benchmark_3.lisp index 99b69ee..c4b802f 100644 --- a/benchmarks/benchmark_3.lisp +++ b/benchmarks/benchmark_3.lisp @@ -1 +1 @@ -(print (if (> (* 9 8) (+ 3 7)) (+ 6 (+ 9 17)) (+ 13 (- 9 2)))) +(print (if (> (+ 9 8) (+ 3 7)) (+ 6 (+ 9 17)) (+ 13 (- 9 2)))) diff --git a/benchmarks/lchoi-prop.lisp b/benchmarks/lchoi-prop.lisp index d9c4487..43f6298 100644 --- a/benchmarks/lchoi-prop.lisp +++ b/benchmarks/lchoi-prop.lisp @@ -1,4 +1,4 @@ (let ((x (- 5 4)) - (let ((y (* x 4)) - (let ((z (* x y)) + (let ((y (+ x 4)) + (let ((z (+ x y)) (print (+ x (+ y z))))))))) \ No newline at end of file diff --git a/benchmarks/lchoi-unroll.lisp b/benchmarks/lchoi-unroll.lisp index 76a875c..ef8e4e3 100644 --- a/benchmarks/lchoi-unroll.lisp +++ b/benchmarks/lchoi-unroll.lisp @@ -1,4 +1,4 @@ (define (leftshift num bits) - (if (< bits 1) num (* 2 (leftshift num (- bits 1))))) + (if (< bits 1) num (+ (leftshift num (- bits 1)) (leftshift num (- bits 1))))) (print (leftshift 1 11)) \ No newline at end of file From 3eb4d984afd3b80a1b068328a3c715c2590566ca Mon Sep 17 00:00:00 2001 From: Rob Lewis Date: Thu, 5 Dec 2024 15:19:18 -0500 Subject: [PATCH 12/16] fix --- benchmarks/benchmark_2.lisp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/benchmarks/benchmark_2.lisp b/benchmarks/benchmark_2.lisp index f043ba1..32c9514 100644 --- a/benchmarks/benchmark_2.lisp +++ b/benchmarks/benchmark_2.lisp @@ -1,4 +1,5 @@ (define (cube x) (+x (+ x x))) -(do (print (let ((x (read-num))) (+ (let ((y (+ 3 5))) (cube x)))))) +(do (print (let ((x (read-num))) + (+ (let ((y (+ 3 5))) (cube x)) y)))) From 165a545a71387450fdb42c45ff8ee5724ab599a7 Mon Sep 17 00:00:00 2001 From: Rob Lewis Date: Thu, 5 Dec 2024 15:22:02 -0500 Subject: [PATCH 13/16] fix --- benchmarks/benchmark_2.lisp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/benchmarks/benchmark_2.lisp b/benchmarks/benchmark_2.lisp index 32c9514..00fc8cb 100644 --- a/benchmarks/benchmark_2.lisp +++ b/benchmarks/benchmark_2.lisp @@ -2,4 +2,4 @@ (+x (+ x x))) (do (print (let ((x (read-num))) - (+ (let ((y (+ 3 5))) (cube x)) y)))) + (+ (let ((y (+ 3 5))) (cube x)) 1)))) From 96faafd3b4979c0085626a3ea7186420a9e7a4ed Mon Sep 17 00:00:00 2001 From: Rob Lewis Date: Thu, 5 Dec 2024 15:24:25 -0500 Subject: [PATCH 14/16] fix --- benchmarks/benchmark_2.lisp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/benchmarks/benchmark_2.lisp b/benchmarks/benchmark_2.lisp index 00fc8cb..7313529 100644 --- a/benchmarks/benchmark_2.lisp +++ b/benchmarks/benchmark_2.lisp @@ -1,5 +1,5 @@ (define (cube x) - (+x (+ x x))) + (+ x (+ x x))) (do (print (let ((x (read-num))) (+ (let ((y (+ 3 5))) (cube x)) 1)))) From 5d6723777072db4acdaa4b2a6480ecff3f2b2f3f Mon Sep 17 00:00:00 2001 From: Rob Lewis Date: Thu, 5 Dec 2024 15:28:13 -0500 Subject: [PATCH 15/16] no gt --- benchmarks/benchmark_3.lisp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/benchmarks/benchmark_3.lisp b/benchmarks/benchmark_3.lisp index c4b802f..eb09d48 100644 --- a/benchmarks/benchmark_3.lisp +++ b/benchmarks/benchmark_3.lisp @@ -1 +1 @@ -(print (if (> (+ 9 8) (+ 3 7)) (+ 6 (+ 9 17)) (+ 13 (- 9 2)))) +(print (if (< (+ 9 8) (+ 3 7)) (+ 6 (+ 9 17)) (+ 13 (- 9 2)))) From 985b69d6e7b77e1ce1a360665dc2a5aac67cf592 Mon Sep 17 00:00:00 2001 From: Rob Lewis Date: Thu, 5 Dec 2024 15:31:06 -0500 Subject: [PATCH 16/16] fix --- benchmarks/lchoi-prop.lisp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/benchmarks/lchoi-prop.lisp b/benchmarks/lchoi-prop.lisp index 43f6298..8030657 100644 --- a/benchmarks/lchoi-prop.lisp +++ b/benchmarks/lchoi-prop.lisp @@ -1,4 +1,4 @@ -(let ((x (- 5 4)) - (let ((y (+ x 4)) - (let ((z (+ x y)) - (print (+ x (+ y z))))))))) \ No newline at end of file +(let ((x (- 5 4))) + (let ((y (+ x 4))) + (let ((z (+ x y))) + (print (+ x (+ y z)))))) \ No newline at end of file