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

Bitwise operations #4733

Closed
wants to merge 107 commits into from
Closed
Show file tree
Hide file tree
Changes from 84 commits
Commits
Show all changes
107 commits
Select commit Hold shift + click to select a range
0ce86be
Start on bitwise primitive implementations in Core
kozross Jun 24, 2022
8af8684
Merge branch 'master' into koz/bitwise
kozross Jun 26, 2022
2ec6f0e
Remaining implementations of bitwise operations
kozross Jun 27, 2022
0e0ae36
Plutus Core builtins for bitwise ops
kozross Jun 27, 2022
d1579a6
More bitwise operation checks, fix bug in complement
kozross Jun 28, 2022
e89cfd2
Finish tests for AND, IOR, XOR, complement
kozross Jun 28, 2022
139532e
Popcount bugfix, tests for popcount
kozross Jun 28, 2022
06d0f9b
Tests for bit indexing
kozross Jun 29, 2022
15206d4
Tests for bit writing, some for find first set
kozross Jun 29, 2022
ce10c0b
Merge branch 'master' into koz/bitwise
kozross Jun 29, 2022
fb1c854
Finish find first set tests
kozross Jun 29, 2022
8ef6322
Fix rotate bug, test for rotations
kozross Jun 30, 2022
b9ef84c
Merge branch 'master' into koz/bitwise
kozross Jul 3, 2022
23d5a38
Fix rotation bugs, rotation tests
kozross Jul 4, 2022
ecde7e4
Reimplement shift similarly to rotate, shift tests
kozross Jul 4, 2022
0576121
Shifting tests
kozross Jul 4, 2022
409f710
Finish bytestring conversion tests
kozross Jul 5, 2022
e984cf1
Merge branch 'master' into koz/bitwise
kozross Jul 5, 2022
a2f1748
PlutusTx bitwise builtins
kozross Jul 6, 2022
5acf262
Fix Nix issues, ensure we don't break on line length
kozross Jul 6, 2022
9b9ea9e
Tests for IntegerToByteString primitive, finish #4252
kozross Jul 6, 2022
86c96d2
Merge branch 'master' into koz/bitwise
kozross Jul 10, 2022
25968aa
Remove -fsimpl-tick-factor parameter
kozross Jul 10, 2022
7e5a1fb
Add note for overPtrLen safety, remove commented code
kozross Jul 10, 2022
2610321
Restore simpl-tick with comment, document Bitwise
kozross Jul 11, 2022
b7180e4
Remove -Werror in source files
kozross Jul 11, 2022
bd53cdd
Merge branch 'master' into koz/bitwise
kozross Jul 18, 2022
2e3d054
Benchmarks for bitwise binary ops
kozross Jul 19, 2022
c80681e
Merge branch 'master' into koz/bitwise
kozross Jul 20, 2022
470baee
Refactor of bitwise binary ops, more accurate measurements
kozross Jul 20, 2022
1eb89ce
More rigid benching methodology, 3-stage loop
kozross Jul 20, 2022
30d7884
Merge branch 'master' into koz/bitwise
kozross Jul 20, 2022
293f4c8
Rewrite to use arrays of Ptrs
kozross Jul 21, 2022
86b9973
Define a big-smaller-small loop generically
kozross Jul 21, 2022
620e51e
Merge branch 'master' into koz/bitwise
kozross Jul 21, 2022
2af430a
Merge branch 'master' into koz/bitwise
kozross Jul 25, 2022
5ed1dd3
Better benches, settle on implementation
kozross Jul 25, 2022
22d329c
Add benches for remaining binary bitwise ops
kozross Jul 26, 2022
b97329c
Merge branch 'master' into koz/bitwise
kozross Jul 31, 2022
d8077c1
NOINLINE packZipWith
kozross Aug 1, 2022
7d735d8
Retry 2-step loop unrolls
kozross Aug 1, 2022
adad03d
3-step inlining
kozross Aug 1, 2022
089044e
More bitwise AND implementations, big comparison
kozross Aug 1, 2022
d162ead
Refactor, more measurements, measure complement
kozross Aug 1, 2022
1040977
Popcount benchmarks
kozross Aug 2, 2022
0a9f7e3
Refactor bench implementations, add rotation benches
kozross Aug 4, 2022
04f1531
Start benchmark writeup
kozross Aug 4, 2022
8144f87
Merge branch 'master' into koz/bitwise
kozross Aug 7, 2022
09dd2dd
Writeup for popcount, another narrow bench
kozross Aug 8, 2022
3bc7b48
Merge branch 'master' into koz/bitwise
kozross Aug 8, 2022
812672c
Implement more options for bigger inputs, make benches bigger
kozross Aug 9, 2022
801b581
Merge branch 'master' into koz/bitwise
kozross Aug 9, 2022
c6b6ba9
Tune FFI settings, more AND benches
kozross Aug 10, 2022
c659c50
Merge branch 'master' into koz/bitwise
kozross Aug 10, 2022
079e568
Merge branch 'master' into koz/bitwise
kozross Aug 11, 2022
e6166c7
Refactor popcount benchmarks
kozross Aug 11, 2022
87e21f9
Refactor complement benches
kozross Aug 12, 2022
c83c7f6
Merge branch 'master' into koz/bitwise
kozross Aug 14, 2022
0b82ca5
More benches for popcount, complement
kozross Aug 16, 2022
2f7dc4c
Merge branch 'master' into koz/bitwise
kozross Aug 17, 2022
581924f
Benches for homogeneity testing
kozross Aug 17, 2022
996fe3c
Better AND benches, CLZ benches
kozross Aug 18, 2022
c293800
Merge branch 'master' into koz/bitwise
kozross Aug 18, 2022
3ad984e
Benches for bit access, compare CLZ C implementations
kozross Aug 19, 2022
2e1feca
Merge branch 'master' into koz/bitwise
kozross Aug 21, 2022
03bc299
Bit write benches
kozross Aug 21, 2022
8d0f21b
Merge branch 'master' into koz/bitwise
kozross Aug 22, 2022
78dcf10
Bitwise shift bench preliminary
kozross Aug 24, 2022
4cdd39b
Define and bench a faster byte-size shift
kozross Aug 24, 2022
87b659b
Much faster shift in C
kozross Aug 24, 2022
cc76263
Merge branch 'master' into koz/bitwise
kozross Aug 24, 2022
4a9c80b
Remove Implementation module, bitwise rotation benches
kozross Aug 24, 2022
c4d9af9
C bitwise rotation, clear away un-needed benches and implementations
kozross Aug 24, 2022
d0fcc9e
Benches for BS to Integer conversion
kozross Aug 25, 2022
677666e
Merge branch 'master' into koz/bitwise
kozross Aug 25, 2022
2a258a5
Merge block converter with other benches
kozross Aug 25, 2022
c6a675c
Integer to ByteString conversion benches
kozross Aug 26, 2022
5f3d2ed
Merge branch 'master' into koz/bitwise
kozross Aug 28, 2022
438de66
Merge branch 'master' into koz/bitwise
kozross Aug 30, 2022
dbf6af8
Merge branch 'master' into koz/bitwise
L-as Mar 7, 2023
4134f2c
Style fixes
L-as Mar 7, 2023
d8fede4
Fix issues from the previous merge
L-as Mar 9, 2023
e44b148
Fix `integerToByteString` and its inverse according to spec
L-as Mar 10, 2023
db8d52d
Reduce one copy of the input in `byteStringToInteger`
L-as Mar 10, 2023
d0497d4
Make plutus-tx compile again
L-as Mar 10, 2023
266ac1e
Improve documentation, remove unnececessary pragmata, slightly clean …
L-as Mar 10, 2023
28c359b
Merge commit 'refs/pull/4733/head' of github.com:input-output-hk/plut…
kwxm Jun 30, 2023
6895223
Complete merge
kwxm Jun 30, 2023
371a26d
Fix some more merge problems
kwxm Jun 30, 2023
87d8f73
Restore missing exports
kwxm Jun 30, 2023
3133777
WIP: cost model stubs
kwxm Jun 30, 2023
e98929e
WIP: cost model stubs
kwxm Jun 30, 2023
dc4bdef
WIP: cost model stubs
kwxm Jun 30, 2023
fd60348
Merge branch 'master' into kwxm/mlabs-bitwise
kwxm Jul 7, 2023
b502617
Merge branch 'master' into kwxm/mlabs-bitwise
kwxm Jul 18, 2023
ee0075c
Update builtin tags
kwxm Jul 18, 2023
af4fd3e
Update costing code
kwxm Jul 19, 2023
181488a
_var -> _ver
kwxm Jul 20, 2023
df99b27
Merge branch 'master' into kwxm/mlabs-bitwise
kwxm Jul 25, 2023
3938faf
Fix typo in builtin tags
kwxm Jul 25, 2023
3e011d5
Merge branch 'master' into kwxm/mlabs-bitwise
kwxm Jul 26, 2023
89254ba
Merge branch 'master' into kwxm/mlabs-bitwise
kwxm Jul 26, 2023
ac95847
Remove some duplicated imports
kwxm Aug 1, 2023
1aca9c5
Merge branch 'koz/bitwise' of github.com:mlabs-haskell/plutus into ko…
kozross Aug 8, 2023
221da85
Merge branch 'kwxm/mlabs-bitwise' into koz/bitwise
kozross Aug 8, 2023
7996c8d
Format fix
kozross Aug 8, 2023
00ffb88
Changelogs for bitwise primops
kozross Aug 8, 2023
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
46 changes: 46 additions & 0 deletions plutus-core/plutus-core.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ common lang
library
import: lang
exposed-modules:
Bitwise
Crypto
Data.ByteString.Hash
Data.Either.Extras
Expand Down Expand Up @@ -265,6 +266,7 @@ library
, filepath
, flat <0.5
, free
, ghc-bignum ^>=1.2
, ghc-prim
, hashable >=1.4
, hedgehog >=1.0
Expand Down Expand Up @@ -358,6 +360,7 @@ test-suite untyped-plutus-core-test
DeBruijn.Spec
DeBruijn.UnDeBruijnify
Evaluation.Builtins
Evaluation.Builtins.Bitwise
Evaluation.Builtins.Common
Evaluation.Builtins.Definition
Evaluation.Builtins.MakeRead
Expand Down Expand Up @@ -927,3 +930,46 @@ test-suite index-envs-test
, quickcheck-instances
, tasty
, tasty-quickcheck

benchmark bitwise
import: lang
type: exitcode-stdio-1.0
hs-source-dirs: plutus-core/bench/bitwise
default-language: Haskell2010
main-is: Main.hs
other-modules:
Benches.Binary
Benches.BitRead
Benches.BitWrite
Benches.Complement
Benches.Convert
Benches.CountLeadingZeroes
Benches.Popcount
Benches.Rotate
Benches.Shift
DataGen

include-dirs: plutus-core/bench/bitwise/cbits
c-sources:
plutus-core/bench/bitwise/cbits/binary.c
plutus-core/bench/bitwise/cbits/bit-access.c
plutus-core/bench/bitwise/cbits/clz.c
plutus-core/bench/bitwise/cbits/complement.c
plutus-core/bench/bitwise/cbits/popcount.c
plutus-core/bench/bitwise/cbits/rotate.c
plutus-core/bench/bitwise/cbits/shift.c

cc-options: -O3

if arch(x86_64)
cc-options: -mpopcnt -mabm

build-depends:
, base
, bytestring
, mtl
, random
, tasty
, tasty-bench

ghc-options: -O2 -rtsopts "-with-rtsopts=-A32m --nonmoving-gc -T"
Loading