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

type mismatch #35

Closed
tmcdonell opened this issue Mar 13, 2012 · 2 comments
Closed

type mismatch #35

tmcdonell opened this issue Mar 13, 2012 · 2 comments
Labels
frontend sharing recovery, fusion, optimisation

Comments

@tmcdonell
Copy link
Member

via @arj

import Data.Array.Accelerate as Acc

type AccVector a = Acc (Vector a)
type AccSparseVector a = ((AccVector Int), (AccVector a))

getEntry :: (Elt a) => Exp Int -> a -> AccSparseVector a -> Exp a
getEntry i d (idx,val) = Acc.snd $ the $ Acc.foldAll f def xs
  where
    xs  = Acc.zip idx val
    def = constant (0 :: Int,d)
    f ack v = (i ==* Acc.fst v) ? (v, ack)
--    f ack v = (i ==* i) ? (v, ack) -- This fails!
--    f ack v = ack -- This works!
--    f ack v = v   -- This works!

vectorFromSparseVector :: (Elt a) => AccSparseVector a -> Int -> a -> AccVector a
vectorFromSparseVector sv@(idx,val) size d = Acc.map m def
  where
    def = use $ fromList (Z :. size) $ take size $ ([1,2..] :: [Int]) :: AccVector Int
    m i = getEntry i d sv 

------------

nobug = getEntry 1 (0.0 :: Float) (idx, val) 
  where
    idx = use $ fromList (Z :. (1 :: Int)) ([1] :: [Int])
    val = use $ fromList (Z :. (1 :: Int)) ([1] :: [Float])

-------------------------

bug = vectorFromSparseVector (idx, val) 1 $ (0.0 :: Float)
  where
    idx = use $ fromList (Z :. (1 :: Int)) ([1] :: [Int])
    val = use $ fromList (Z :. (1 :: Int)) ([1] :: [Float])

and the ghci session:

ghci> bug
let a0 =*** Exception: 
*** Internal error in package accelerate ***
*** Please submit a bug report at https://github.com/mchakravarty/accelerate/issues
./Data/Array/Accelerate/Smart.hs:114 (prjIdx): type mismatch
couldn't match expected type `((),Int)' with actual type `(((),Int),Float)'

@mchakravarty
Copy link
Member

This is also nested parallelism: the maped function contains a foldAll.

@mchakravarty
Copy link
Member

BTW, I added "probable cause" suggestion to the error message.

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
frontend sharing recovery, fusion, optimisation
Projects
None yet
Development

No branches or pull requests

2 participants