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

Compatibility with accelerate 1.4 #3

Merged
merged 1 commit into from
Aug 12, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
17 changes: 10 additions & 7 deletions Data/Array/Accelerate/System/Random/MWC.hs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE ScopedTypeVariables #-}
-- |
-- Module: : Data.Array.Accelerate.System.Random.MWC
-- Copyright : [2014..2015] Trevor L. McDonell
Expand Down Expand Up @@ -80,6 +82,7 @@ import qualified System.Random.MWC as R
import Data.Array.Accelerate as A
import Data.Array.Accelerate.Array.Data as A
import Data.Array.Accelerate.Array.Sugar as Sugar
import qualified Data.Array.Accelerate.Array.Representation as Repr


-- | A PRNG from indices to variates
Expand Down Expand Up @@ -124,27 +127,27 @@ randomArrayWith
randomArrayWith gen f sh
= do
adata <- runRandomArray f sh gen
return $ adata `seq` Array (fromElt sh) adata
return $ adata `seq` Array (Repr.Array (fromElt sh) adata)


-- Create a mutable array and fill it with random values
--
{-# INLINEABLE runRandomArray #-}
runRandomArray
:: (Shape sh, Elt e)
:: forall sh e. (Shape sh, Elt e)
=> sh :~> e
-> sh
-> GenIO
-> IO (MutableArrayData (EltRepr e))
runRandomArray f sh gen
= do
let n = Sugar.size sh
arr <- newArrayData n
arr <- newArrayData (eltType @e) n
--
let write !i
| i P.>= n = return ()
| otherwise = do
unsafeWriteArrayData arr i . fromElt =<< f (Sugar.fromIndex sh i) gen
unsafeWriteArrayData (eltType @e) arr i . fromElt =<< f (Sugar.fromIndex sh i) gen
write (i+1)
--
write 0
Expand Down
4 changes: 2 additions & 2 deletions mwc-random-accelerate.cabal
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: mwc-random-accelerate
version: 0.1.0.0
version: 0.1.0.1
synopsis: Generate Accelerate arrays filled with high quality pseudorandom numbers
description:
Generate /Accelerate/ arrays filled with high-quality pseudorandom numbers.
Expand Down Expand Up @@ -43,7 +43,7 @@ benchmark bench-random

build-depends:
base >= 4.7 && < 5
, accelerate
, accelerate >= 1.4 && < 1.5
, criterion
, mersenne-random
, mwc-random
Expand Down