-
Notifications
You must be signed in to change notification settings - Fork 479
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
Renamed to ASTSize, changed to Maybe CoverageIndex #6081
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,14 @@ | ||
{-# OPTIONS_GHC -fno-warn-unused-top-binds #-} | ||
{-# LANGUAGE NoImplicitPrelude #-} | ||
|
||
module PlutusBenchmark.NoFib.Knights.Sort | ||
( insertSort, | ||
mergeSort, | ||
quickSort | ||
) where | ||
|
||
import PlutusTx.Prelude qualified as Tx | ||
import PlutusTx.Builtins as Tx | ||
import PlutusTx.Prelude as Tx | ||
|
||
{-# INLINABLE insertSort #-} | ||
insertSort :: (Tx.Ord a) => [a] -> [a] | ||
|
@@ -25,8 +27,8 @@ mergeSort xs | |
= if (n <=1 ) then xs | ||
else | ||
(mergeList | ||
( mergeSort (take (n `div` 2) xs)) | ||
( mergeSort (drop (n `div` 2) xs))) | ||
( mergeSort (take (n `divideInteger` 2) xs)) | ||
( mergeSort (drop (n `divideInteger` 2) xs))) | ||
where | ||
n = length xs | ||
|
||
|
@@ -99,9 +101,9 @@ randomIntegers s1 s2 = | |
if 1 <= s2 && s2 <= 2147483398 then | ||
rands s1 s2 | ||
else | ||
error "randomIntegers: Bad second seed." | ||
error () -- "randomIntegers: Bad second seed." | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there a reason not to use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good idea There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I think the reason for that is that |
||
else | ||
error "randomIntegers: Bad first seed." | ||
error () -- "randomIntegers: Bad first seed." | ||
|
||
{-# INLINABLE rands #-} | ||
rands :: Integer -> Integer -> [Integer] | ||
|
@@ -110,11 +112,11 @@ rands s1 s2 | |
else | ||
z : rands s1'' s2'' | ||
where | ||
k = s1 `div` 53668 | ||
k = s1 `divideInteger` 53668 | ||
s1' = 40014 * (s1 - k * 53668) - k * 12211 | ||
s1'' = if s1' < 0 then s1' + 2147483563 else s1' | ||
|
||
k' = s2 `div` 52774 | ||
k' = s2 `divideInteger` 52774 | ||
s2' = 40692 * (s2 - k' * 52774) - k' * 3791 | ||
s2'' = if s2' < 0 then s2' + 2147483399 else s2' | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
({cpu: 1474894000 | ||
| mem: 7526812}) | ||
| mem: 7526812}) |
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.
I changed this because I was compiling with -O0 , and it complained that there was no unfolding for GHC.++ in quickSort. Turns out this module was using too much of ghc stdlib. Is it good that I changed it @kwxm?
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.
Hmmm. The Haskell programs that these are based on are about 30 years old and are probably a bit old-fashioned to modern eyes: a lot of stuff that's commonly used these days just didn't exist when they were written. I just ported them with minimal changes and resisted the temptation to start "improving" them. My inclination would be to leave them as they are because changing the source makes it harder to see what changes are due to changes in our compiler: the differences in this file (which are quite small!) seem to have made the PIR for the whole program quite significantly different (current version, new version), which presumably accounts for the budget changes that show up later. Unless the programs stop working completely it's probably better not to change them.