diff --git a/vector/benchmarks/Algo/AwShCC.hs b/vector/benchlib/Bench/Vector/Algo/AwShCC.hs similarity index 96% rename from vector/benchmarks/Algo/AwShCC.hs rename to vector/benchlib/Bench/Vector/Algo/AwShCC.hs index 404e289f..9f61ca74 100644 --- a/vector/benchmarks/Algo/AwShCC.hs +++ b/vector/benchlib/Bench/Vector/Algo/AwShCC.hs @@ -1,5 +1,5 @@ {-# OPTIONS -fno-spec-constr-count #-} -module Algo.AwShCC (awshcc) where +module Bench.Vector.Algo.AwShCC (awshcc) where import Data.Vector.Unboxed as V diff --git a/vector/benchmarks/Algo/FindIndexR.hs b/vector/benchlib/Bench/Vector/Algo/FindIndexR.hs similarity index 90% rename from vector/benchmarks/Algo/FindIndexR.hs rename to vector/benchlib/Bench/Vector/Algo/FindIndexR.hs index c7417a24..b77d31e1 100644 --- a/vector/benchmarks/Algo/FindIndexR.hs +++ b/vector/benchlib/Bench/Vector/Algo/FindIndexR.hs @@ -1,4 +1,4 @@ -module Algo.FindIndexR (findIndexR, findIndexR_naive, findIndexR_manual) +module Bench.Vector.Algo.FindIndexR (findIndexR, findIndexR_naive, findIndexR_manual) where import Data.Vector.Unboxed (Vector) diff --git a/vector/benchmarks/Algo/HybCC.hs b/vector/benchlib/Bench/Vector/Algo/HybCC.hs similarity index 96% rename from vector/benchmarks/Algo/HybCC.hs rename to vector/benchlib/Bench/Vector/Algo/HybCC.hs index 876d08f7..db3345d5 100644 --- a/vector/benchmarks/Algo/HybCC.hs +++ b/vector/benchlib/Bench/Vector/Algo/HybCC.hs @@ -1,4 +1,4 @@ -module Algo.HybCC (hybcc) where +module Bench.Vector.Algo.HybCC (hybcc) where import Data.Vector.Unboxed as V diff --git a/vector/benchmarks/Algo/Leaffix.hs b/vector/benchlib/Bench/Vector/Algo/Leaffix.hs similarity index 91% rename from vector/benchmarks/Algo/Leaffix.hs rename to vector/benchlib/Bench/Vector/Algo/Leaffix.hs index 40ec5175..e341daed 100644 --- a/vector/benchmarks/Algo/Leaffix.hs +++ b/vector/benchlib/Bench/Vector/Algo/Leaffix.hs @@ -1,4 +1,4 @@ -module Algo.Leaffix where +module Bench.Vector.Algo.Leaffix where import Data.Vector.Unboxed as V diff --git a/vector/benchmarks/Algo/ListRank.hs b/vector/benchlib/Bench/Vector/Algo/ListRank.hs similarity index 93% rename from vector/benchmarks/Algo/ListRank.hs rename to vector/benchlib/Bench/Vector/Algo/ListRank.hs index 933bd8eb..7c7377d9 100644 --- a/vector/benchmarks/Algo/ListRank.hs +++ b/vector/benchlib/Bench/Vector/Algo/ListRank.hs @@ -1,4 +1,4 @@ -module Algo.ListRank +module Bench.Vector.Algo.ListRank where import Data.Vector.Unboxed as V diff --git a/vector/benchmarks/Algo/MutableSet.hs b/vector/benchlib/Bench/Vector/Algo/MutableSet.hs similarity index 95% rename from vector/benchmarks/Algo/MutableSet.hs rename to vector/benchlib/Bench/Vector/Algo/MutableSet.hs index 12f5e501..8dd187f0 100644 --- a/vector/benchmarks/Algo/MutableSet.hs +++ b/vector/benchlib/Bench/Vector/Algo/MutableSet.hs @@ -1,6 +1,6 @@ {-# LANGUAGE BangPatterns #-} -module Algo.MutableSet +module Bench.Vector.Algo.MutableSet where import Prelude hiding(length, read) diff --git a/vector/benchmarks/Algo/Quickhull.hs b/vector/benchlib/Bench/Vector/Algo/Quickhull.hs similarity index 94% rename from vector/benchmarks/Algo/Quickhull.hs rename to vector/benchlib/Bench/Vector/Algo/Quickhull.hs index 694bea30..da866e27 100644 --- a/vector/benchmarks/Algo/Quickhull.hs +++ b/vector/benchlib/Bench/Vector/Algo/Quickhull.hs @@ -1,4 +1,4 @@ -module Algo.Quickhull (quickhull) where +module Bench.Vector.Algo.Quickhull (quickhull) where import Data.Vector.Unboxed as V diff --git a/vector/benchmarks/Algo/Rootfix.hs b/vector/benchlib/Bench/Vector/Algo/Rootfix.hs similarity index 91% rename from vector/benchmarks/Algo/Rootfix.hs rename to vector/benchlib/Bench/Vector/Algo/Rootfix.hs index 1b112a80..6de8daba 100644 --- a/vector/benchmarks/Algo/Rootfix.hs +++ b/vector/benchlib/Bench/Vector/Algo/Rootfix.hs @@ -1,4 +1,4 @@ -module Algo.Rootfix where +module Bench.Vector.Algo.Rootfix where import Data.Vector.Unboxed as V diff --git a/vector/benchmarks/Algo/Spectral.hs b/vector/benchlib/Bench/Vector/Algo/Spectral.hs similarity index 88% rename from vector/benchmarks/Algo/Spectral.hs rename to vector/benchlib/Bench/Vector/Algo/Spectral.hs index 811c5826..b8ff62fe 100644 --- a/vector/benchmarks/Algo/Spectral.hs +++ b/vector/benchlib/Bench/Vector/Algo/Spectral.hs @@ -1,4 +1,4 @@ -module Algo.Spectral ( spectral ) where +module Bench.Vector.Algo.Spectral ( spectral ) where import Data.Vector.Unboxed as V diff --git a/vector/benchmarks/Algo/Tridiag.hs b/vector/benchlib/Bench/Vector/Algo/Tridiag.hs similarity index 90% rename from vector/benchmarks/Algo/Tridiag.hs rename to vector/benchlib/Bench/Vector/Algo/Tridiag.hs index 7668deac..f28dad52 100644 --- a/vector/benchmarks/Algo/Tridiag.hs +++ b/vector/benchlib/Bench/Vector/Algo/Tridiag.hs @@ -1,4 +1,4 @@ -module Algo.Tridiag ( tridiag ) where +module Bench.Vector.Algo.Tridiag ( tridiag ) where import Data.Vector.Unboxed as V diff --git a/vector/benchlib/Bench/Vector/Tasty.hs b/vector/benchlib/Bench/Vector/Tasty.hs new file mode 100644 index 00000000..0af8cf6f --- /dev/null +++ b/vector/benchlib/Bench/Vector/Tasty.hs @@ -0,0 +1,27 @@ +-- | +-- Tasty integration for vector benchmarks. +module Bench.Vector.Tasty + ( VectorSize(..) + , RandomSeed(..) + ) where + +import Test.Tasty.Options + + +-- | Size of vector used in benchmarks +newtype VectorSize = VectorSize Int + +instance IsOption VectorSize where + defaultValue = VectorSize 2000000 + parseValue = fmap VectorSize . safeRead + optionName = pure "size" + optionHelp = pure "Size of vectors used in benchmarks" + +-- | Random seed used for generation of the test data +newtype RandomSeed = RandomSeed Int + +instance IsOption RandomSeed where + defaultValue = RandomSeed 42 + parseValue = fmap RandomSeed . safeRead + optionName = pure "seed" + optionHelp = pure "Random seed used for generation of the test data" diff --git a/vector/benchmarks/TestData/Graph.hs b/vector/benchlib/Bench/Vector/TestData/Graph.hs similarity index 96% rename from vector/benchmarks/TestData/Graph.hs rename to vector/benchlib/Bench/Vector/TestData/Graph.hs index 81c1ac2f..0643578d 100644 --- a/vector/benchmarks/TestData/Graph.hs +++ b/vector/benchlib/Bench/Vector/TestData/Graph.hs @@ -1,4 +1,4 @@ -module TestData.Graph +module Bench.Vector.TestData.Graph ( randomGraph ) where diff --git a/vector/benchmarks/TestData/ParenTree.hs b/vector/benchlib/Bench/Vector/TestData/ParenTree.hs similarity index 93% rename from vector/benchmarks/TestData/ParenTree.hs rename to vector/benchlib/Bench/Vector/TestData/ParenTree.hs index 4aeb7509..cb9f50a5 100644 --- a/vector/benchmarks/TestData/ParenTree.hs +++ b/vector/benchlib/Bench/Vector/TestData/ParenTree.hs @@ -1,4 +1,4 @@ -module TestData.ParenTree where +module Bench.Vector.TestData.ParenTree where import qualified Data.Vector.Unboxed as V diff --git a/vector/benchmarks/README.md b/vector/benchlib/README.md similarity index 100% rename from vector/benchmarks/README.md rename to vector/benchlib/README.md diff --git a/vector/benchmarks/Main.hs b/vector/benchmarks/Main.hs index d6ae78f0..26645cf0 100644 --- a/vector/benchmarks/Main.hs +++ b/vector/benchmarks/Main.hs @@ -1,18 +1,20 @@ +{-# LANGUAGE BangPatterns #-} module Main where -import Algo.MutableSet (mutableSet) -import Algo.ListRank (listRank) -import Algo.Rootfix (rootfix) -import Algo.Leaffix (leaffix) -import Algo.AwShCC (awshcc) -import Algo.HybCC (hybcc) -import Algo.Quickhull (quickhull) -import Algo.Spectral (spectral) -import Algo.Tridiag (tridiag) -import Algo.FindIndexR (findIndexR, findIndexR_naive, findIndexR_manual) +import Bench.Vector.Algo.MutableSet (mutableSet) +import Bench.Vector.Algo.ListRank (listRank) +import Bench.Vector.Algo.Rootfix (rootfix) +import Bench.Vector.Algo.Leaffix (leaffix) +import Bench.Vector.Algo.AwShCC (awshcc) +import Bench.Vector.Algo.HybCC (hybcc) +import Bench.Vector.Algo.Quickhull (quickhull) +import Bench.Vector.Algo.Spectral (spectral) +import Bench.Vector.Algo.Tridiag (tridiag) +import Bench.Vector.Algo.FindIndexR (findIndexR, findIndexR_naive, findIndexR_manual) -import TestData.ParenTree (parenTree) -import TestData.Graph (randomGraph) +import Bench.Vector.TestData.ParenTree (parenTree) +import Bench.Vector.TestData.Graph (randomGraph) +import Bench.Vector.Tasty import Data.Proxy import qualified Data.Vector.Mutable as MV @@ -24,21 +26,6 @@ import Test.Tasty.Bench import Test.Tasty.Options import Test.Tasty.Runners -newtype VectorSize = VectorSize Int - -instance IsOption VectorSize where - defaultValue = VectorSize 2000000 - parseValue = fmap VectorSize . safeRead - optionName = pure "size" - optionHelp = pure "Size of vectors used in benchmarks" - -newtype RandomSeed = RandomSeed Int - -instance IsOption RandomSeed where - defaultValue = RandomSeed 42 - parseValue = fmap RandomSeed . safeRead - optionName = pure "seed" - optionHelp = pure "Random seed used in benchmarks" indexFindThreshold :: Double indexFindThreshold = 2e-5 @@ -53,18 +40,15 @@ main = do gen <- newIOGenM (mkStdGen useSeed) - let (lparens, rparens) = parenTree useSize - (nodes, edges1, edges2) <- randomGraph gen useSize - lparens `seq` rparens `seq` nodes `seq` edges1 `seq` edges2 `seq` return () + let (!lparens, !rparens) = parenTree useSize + (!nodes, !edges1, !edges2) <- randomGraph gen useSize let randomVector l = U.replicateM l (uniformDoublePositive01M gen) - as <- randomVector useSize - bs <- randomVector useSize - cs <- randomVector useSize - ds <- randomVector useSize - sp <- randomVector (floor $ sqrt $ fromIntegral useSize) - as `seq` bs `seq` cs `seq` ds `seq` sp `seq` return () - + !as <- randomVector useSize + !bs <- randomVector useSize + !cs <- randomVector useSize + !ds <- randomVector useSize + !sp <- randomVector (floor $ sqrt $ fromIntegral useSize) vi <- MV.new useSize defaultMainWithIngredients ingredients $ bgroup "All" diff --git a/vector/vector.cabal b/vector/vector.cabal index be175ef1..79ca5bbc 100644 --- a/vector/vector.cabal +++ b/vector/vector.cabal @@ -1,7 +1,9 @@ +Cabal-Version: 3.0 +Build-Type: Simple Name: vector Version: 0.13.1.0 -- don't forget to update the changelog file! -License: BSD3 +License: BSD-3-Clause License-File: LICENSE Author: Roman Leshchinskiy Maintainer: Haskell Libraries Team @@ -42,31 +44,33 @@ Description: * Tested-With: - GHC == 8.0.2, - GHC == 8.2.2, - GHC == 8.4.4, - GHC == 8.6.5, - GHC == 8.8.4, - GHC == 8.10.7, - GHC == 9.0.2, - GHC == 9.2.8, - GHC == 9.4.6, + GHC == 8.0.2 + GHC == 8.2.2 + GHC == 8.4.4 + GHC == 8.6.5 + GHC == 8.8.4 + GHC == 8.10.7 + GHC == 9.0.2 + GHC == 9.2.8 + GHC == 9.4.6 GHC == 9.6.2 GHC == 9.8.1 - -Cabal-Version: >= 1.10 -Build-Type: Simple -Extra-Source-Files: +Extra-doc-files: changelog.md README.md tests/LICENSE +Extra-Source-Files: tests/Setup.hs - tests/Main.hs internal/GenUnboxTuple.hs internal/unbox-tuple-instances +source-repository head + type: git + location: https://github.com/haskell/vector.git + subdir: vector + Flag BoundsChecks Description: Enable bounds checking Default: True @@ -89,8 +93,17 @@ Flag Wall Default: False Manual: True +-- This common sets warning flags passed to GHC as controlled by Wall cabal flag +common flag-Wall + Ghc-Options: -Wall + if !flag(Wall) + Ghc-Options: -fno-warn-orphans + if impl(ghc >= 8.0) && impl(ghc < 8.1) + Ghc-Options: -Wno-redundant-constraints + Library + import: flag-Wall Default-Language: Haskell2010 Other-Extensions: BangPatterns @@ -151,13 +164,7 @@ Library , deepseq >= 1.1 && < 1.6 , vector-stream >= 0.1 && < 0.2 - Ghc-Options: -O2 -Wall - - if !flag(Wall) - Ghc-Options: -fno-warn-orphans - - if impl(ghc >= 8.0) && impl(ghc < 8.1) - Ghc-Options: -Wno-redundant-constraints + Ghc-Options: -O2 if flag(BoundsChecks) cpp-options: -DVECTOR_BOUNDS_CHECKS @@ -168,35 +175,37 @@ Library if flag(InternalChecks) cpp-options: -DVECTOR_INTERNAL_CHECKS -source-repository head - type: git - location: https://github.com/haskell/vector.git - subdir: vector - -test-suite vector-tests-O0 +-- We want to build test suite in two variants. One built with -O0 +-- and another with -O2 in order to catch bugs caused by invalid +-- rewrite rules +common tests-common Default-Language: Haskell2010 - type: exitcode-stdio-1.0 - Main-Is: Main.hs - - other-modules: Boilerplater - Tests.Bundle - Tests.Move - Tests.Vector - Tests.Vector.Property - Tests.Vector.Boxed - Tests.Vector.Storable - Tests.Vector.Primitive - Tests.Vector.Unboxed - Tests.Vector.UnitTests - Utilities - - hs-source-dirs: tests - Build-Depends: base >= 4.5 && < 5, template-haskell, base-orphans >= 0.6, vector, - primitive, random, - QuickCheck >= 2.9 && < 2.15, HUnit, tasty, - tasty-hunit, tasty-quickcheck, - transformers >= 0.2.0.0 + Ghc-Options: -fno-warn-missing-signatures + hs-source-dirs: tests + Build-Depends: base >= 4.5 && < 5 + , template-haskell + , base-orphans >= 0.6 + , vector + , primitive + , random + , QuickCheck >= 2.9 && < 2.15 + , tasty + , tasty-hunit + , tasty-quickcheck + , transformers >= 0.2.0.0 + Other-Modules: + Boilerplater + Tests.Bundle + Tests.Move + Tests.Vector + Tests.Vector.Property + Tests.Vector.Boxed + Tests.Vector.Storable + Tests.Vector.Primitive + Tests.Vector.Unboxed + Tests.Vector.UnitTests + Utilities default-extensions: CPP, ScopedTypeVariables, @@ -208,55 +217,17 @@ test-suite vector-tests-O0 TypeFamilies, TemplateHaskell - Ghc-Options: -O0 -threaded - Ghc-Options: -Wall - - if !flag(Wall) - Ghc-Options: -fno-warn-orphans -fno-warn-missing-signatures - if impl(ghc >= 8.0) && impl(ghc < 8.1) - Ghc-Options: -Wno-redundant-constraints - +test-suite vector-tests-O0 + import: flag-Wall, tests-common + type: exitcode-stdio-1.0 + Main-Is: Main.hs + Ghc-Options: -O0 -threaded test-suite vector-tests-O2 - Default-Language: Haskell2010 - type: exitcode-stdio-1.0 - Main-Is: Main.hs - - other-modules: Boilerplater - Tests.Bundle - Tests.Move - Tests.Vector - Tests.Vector.Property - Tests.Vector.Boxed - Tests.Vector.Storable - Tests.Vector.Primitive - Tests.Vector.Unboxed - Tests.Vector.UnitTests - Utilities - - hs-source-dirs: tests - Build-Depends: base >= 4.5 && < 5, template-haskell, base-orphans >= 0.6, vector, - primitive, random, - QuickCheck >= 2.9 && < 2.15, HUnit, tasty, - tasty-hunit, tasty-quickcheck, - transformers >= 0.2.0.0 - - default-extensions: CPP, - ScopedTypeVariables, - PatternGuards, - MultiParamTypeClasses, - FlexibleContexts, - RankNTypes, - TypeSynonymInstances, - TypeFamilies, - TemplateHaskell - - Ghc-Options: -Wall - Ghc-Options: -O2 -threaded - if !flag(Wall) - Ghc-Options: -fno-warn-orphans -fno-warn-missing-signatures - if impl(ghc >= 8.0) && impl(ghc < 8.1) - Ghc-Options: -Wno-redundant-constraints + import: flag-Wall, tests-common + type: exitcode-stdio-1.0 + Main-Is: Main.hs + Ghc-Options: -O2 -threaded test-suite vector-doctest type: exitcode-stdio-1.0 @@ -277,9 +248,9 @@ test-suite vector-doctest , vector -any test-suite vector-inspection + import: flag-Wall type: exitcode-stdio-1.0 hs-source-dirs: tests-inspect - Ghc-Options: -Wall main-is: main.hs default-language: Haskell2010 Other-modules: Inspect @@ -293,6 +264,31 @@ test-suite vector-inspection , tasty , tasty-inspection-testing >= 0.1 +library benchmarks-O2 + visibility: public + ghc-options: -O2 + hs-source-dirs: benchlib + Default-Language: Haskell2010 + build-depends: + base + , random >= 1.2 + , tasty + , vector + exposed-modules: + Bench.Vector.Algo.MutableSet + Bench.Vector.Algo.ListRank + Bench.Vector.Algo.Rootfix + Bench.Vector.Algo.Leaffix + Bench.Vector.Algo.AwShCC + Bench.Vector.Algo.HybCC + Bench.Vector.Algo.Quickhull + Bench.Vector.Algo.Spectral + Bench.Vector.Algo.Tridiag + Bench.Vector.Algo.FindIndexR + Bench.Vector.TestData.ParenTree + Bench.Vector.TestData.Graph + Bench.Vector.Tasty + benchmark algorithms type: exitcode-stdio-1.0 main-is: Main.hs @@ -305,19 +301,6 @@ benchmark algorithms , tasty , tasty-bench >= 0.2.1 , vector + , vector:benchmarks-O2 ghc-options: -O2 - - other-modules: - Algo.MutableSet - Algo.ListRank - Algo.Rootfix - Algo.Leaffix - Algo.AwShCC - Algo.HybCC - Algo.Quickhull - Algo.Spectral - Algo.Tridiag - Algo.FindIndexR - TestData.ParenTree - TestData.Graph