Skip to content

Instantly share code, notes, and snippets.

@tmcdonell
Created February 27, 2014 16:47
Show Gist options
  • Save tmcdonell/9254023 to your computer and use it in GitHub Desktop.
Save tmcdonell/9254023 to your computer and use it in GitHub Desktop.
import Prelude as P
import Data.Array.Accelerate as A
import Data.Array.Accelerate.CUDA as C
import Data.Array.Accelerate.Interpreter as I
import Data.Array.Accelerate.Array.Sugar
input :: Acc (Vector Int32)
input = use $ fromList (Z :. 59) [3214586,-22955798,24117958,-20242782,-18004116,3985569,1024273,-32729186,-30502029,-5017248,3166066,4277396,4405509,19375005,24465845,21106830,-16052075,13200861,-27493632,17784659,4138004,16501551,25998396,2146684,13413209,-25369899,-25241634,-14754912,-28861012,-10508167,21070625,-29990464,16694578,-24171913,-2266914,-18248338,-24717578,18032912,-11713204,-3853636,25922588,-26181472,4306350,14492894,22005937,1681278,-27479141,29397304,19498557,-16341281,-26789977,-30407265,-7861545,10902053,31949840,27671411,30285084,3983719,11323650]
expected :: (Vector Int32, Scalar Int32)
expected = ( fromList (Z :. 59) [0,3214586,-19741212,4376746,-15866036,-33870152,-29884583,-28860310,-61589496,-92091525,-97108773,-93942707,-89665311,-85259802,-65884797,-41418952,-20312122,-36364197,-23163336,-50656968,-32872309,-28734305,-12232754,13765642,15912326,29325535,3955636,-21285998,-36040910,-64901922,-75410089,-54339464,-84329928,-67635350,-91807263,-94074177,-112322515,-137040093,-119007181,-130720385,-134574021,-108651433,-134832905,-130526555,-116033661,-94027724,-92346446,-119825587,-90428283,-70929726,-87271007,-114060984,-144468249,-152329794,-141427741,-109477901,-81806490,-51521406,-47537687]
, fromList Z [-36214037])
runtest :: Bool
runtest =
let (c1,c2) = C.run . A.lift $ A.scanl' (+) 0 input
(i1,i2) = I.run . A.lift $ A.scanl' (+) 0 input
in
shapeToList (arrayShape c1) == shapeToList (arrayShape i1) &&
shapeToList (arrayShape c2) == shapeToList (arrayShape i2) &&
toList c1 == toList i1 &&
toList c2 == toList i2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment