Ticket #21 (closed defect: fixed)

Opened 4 years ago

Last modified 4 years ago

Texture binding for IndexScalar does not work properly with the projection on tuple arrays.

Reported by: seanl Owned by: seanl
Priority: major Milestone:
Component: CUDA backend Version: 0.7.1.0
Keywords: Cc:

Description

The execution of the code fragment

bar3 :: Vector (Word32, Int, Word32) -> Acc (Vector (Word32, Int, Word32))
bar3 xs
  = let
      xs' = use xs
      ys' = use (fromList 10 $ Prelude.zip3 [100..] [1000..] [10000..]) :: Acc (Vector (Word32, Int, Word32))
    in flip map xs' $ \x -> let (a  :: Exp Word32, b  :: Exp Int, c  :: Exp Word32) = untuple x
                                (a' :: Exp Word32, b' :: Exp Int, c' :: Exp Word32) = untuple (ys' Acc.! (b - 1))
                            in  tuple (a * a', b * b', c * c')

main :: IO ()
main = do
  let input3  = fromList 10 (Prelude.zip3 [0..9] [1..10] [2..11]) :: Vector (Word32, Int, Word32)
  r <- CUDA.run $ bar3 input3
  putStrLn $ show r

must produce

Array 10 [(0,1000,20000),(101,2002,30003),(204,3006,40008),(309,4012,50015),(416,5020,60024),(525,6030,70035),(636,7042,80048),(749,8056,90063),(864,9072,100080),(981,10090,110099)]

as the result.

As the liftExp (Prj _ e) in Data/Array/Accelerate/CUDA/Execute.hs simply returns an empty list and bind in the same module computes the texture number incorrectly, the CUDA backend failed to produce the correct result:

Array 10 [(0,0,0),(0,0,0),(0,0,0),(0,0,0),(0,0,0),(0,0,0),(0,0,0),(0,0,0),(0,0,0),(0,0,0)]

Change History

Changed 4 years ago by seanl

  • status changed from new to assigned

Fixed it by adding

liftExp (Prj _ e)         aenv = liftExp e aenv

to liftExp in Data/Array/Accelerate/CUDA/Execute.hs, and

by replacing

bind :: CUDA.Module -> [FVar] -> CIO [CUDA.FunParam]
bind mdl var =
  let tex n (FArr (Array sh ad)) = textureRefs ad mdl (size sh) n
  in  concat <$> zipWithM tex [0..] var

with

bind :: CUDA.Module -> [FVar] -> CIO [CUDA.FunParam]
bind mdl var =
  let tex n (FArr (Array sh ad)) = textureRefs ad mdl (size sh) n
  in  foldM (\texs farr -> (texs ++) <$> tex (length texs) farr) [] var

in Data/Array/Accelerate/CUDA/Execute.hs

I am going to push this patch tonight (9 Aug 2010).

Changed 4 years ago by tmcdonell

  • status changed from assigned to closed
  • resolution set to fixed
Mon Aug  9 16:41:09 EST 2010  seanl@cse.unsw.edu.au
  * fix texture binding for IndexScalar on tuple arrays
Note: See TracTickets for help on using tickets.