haskell / vector

An efficient implementation of Int-indexed arrays (both mutable and immutable), with a powerful loop optimisation framework .
Other
366 stars 139 forks source link

Expose tests and benchmarks as public sublibrary #481

Closed Shimuuar closed 10 months ago

Shimuuar commented 10 months ago

This was discussed in #426 and #459 as a way for other packages to access tests and benchmarks from vector. I tested that it's possible to build PAPI-based benchmarks as separate package, but this change is big enough that it deserves its own PR

There're two tests sublibraries: one built with with -O2 (vector:tests-O2) and another with -O0 (vector:tests-O0). In the same way benchmarks library is called vector:benchmarks-O2. I want to leave name for benchmarks built with -O1 since testing both -O1 and -O2 could be quite valuable.

Most notable change: building vector requires cabal 3.0 since it's earliest version supporting public sublibraries.

There's also question of naming of modules in both sublibraries. I left them as they were but it was assumed that they are not available outside of test-suite/benchmarks which is not the case anymore.

Shimuuar commented 10 months ago

There's also problem with cabal check. It complains:

Warning: These warnings may cause trouble when distributing the package:
Warning: 'ghc-options: -O0' is not needed. Use the --disable-optimization
configure flag.
Warning: 'ghc-options: -O0' is not needed. Use the --disable-optimization
configure flag.

and fails CI. It seems there's no good way around this. We do need to build tests with different optimization levels

lehins commented 10 months ago

It also complains about bounds:

Warning: These packages miss upper bounds:
- base-orphans
- random
- tasty
- tasty-hunit
- tasty-quickcheck
- template-haskell
- transformers

I think we can just disable cabal check, since those warnings are useless.

Shimuuar commented 10 months ago

Cabal check has warnings and warning-but-actually-errors. Former are printed but cabal check returns 0, latter causes non-zero exit code. AFIAR hackage runs cabal check on upload and will reject packages failing it, warnings are accepted.

Maybe there's way around this by structuring tests different;y. But I think it would be better to keep tests private in this PR

Shimuuar commented 10 months ago

Yes I think sublibrary for tests turned out to be trickier than I thought. It would be better to keep tests as they are. And extract common functionality piece by piece later.

With benchmarks situation with optimization flags is more tricky. They export monomorphic function and optimization level is decided when function is built. Application cannot change it.

Shimuuar commented 10 months ago

So I left tests mostly alone and only factored shared parts into common stanza. Also:

For benchmarks sublibrary I moved all modules into Bench.Vector hierarcy and moved RandomSeed & VectorSize options to library as well. They will be used by PAPI benchmark as well