14 views

Skip to first unread message

Oct 7, 2015, 10:12:31 AM10/7/15

to Haskell Repa

When compiled with `-threaded` and run with `+RTS -N2`, the following code produces the nested parallelism error.

```
import Control.Monad.Identity (runIdentity, liftM)
import Data.Array.Repa as R
import Data.Array.Repa.Repr.Unboxed
import Data.Vector.Unboxed
import Test.Framework
import Test.Framework.Providers.QuickCheck2
import Test.QuickCheck hiding (generate,output)
main :: IO ()
main = defaultMainWithArgs [prop,prop] ["--maximum-generated-tests=1"]
prop = testProperty "Test" $ property prop_fmap
prop_fmap :: Arr Int -> Bool
prop_fmap x = fmapT id x == x
newtype Arr r = Arr (Array U DIM1 r) deriving (Eq, Show)
instance (Arbitrary r, Unbox r) => Arbitrary (Arr r) where
arbitrary = replM arbitrary
shrink = shrinkNothing
replM :: (Unbox r, Monad mon) => mon r -> mon (Arr r)
replM = let n = 6
in liftM (Arr . fromUnboxed (Z:.n)) . replicateM n
fmapT :: (Unbox a, Unbox b) => (a -> b) -> Arr a -> Arr b
fmapT f (Arr v) = Arr $ force' $ R.map f $ v
force' :: (Shape sh, Unbox r) => Array D sh r -> Array U sh r
force' = runIdentity . computeP
```

This appears to be due to test-framework evaluating all of the tests in a group (such as the list passed to `defaultMainWithArgs`) in parallel. Is there something that repa/me/test-framework can do differently to prevent this? Why is there nested parallelism at all? It appears that these are two independent instances of computeP whose results do not depend on each other.

Reply all

Reply to author

Forward

0 new messages

Search

Clear search

Close search

Google apps

Main menu