Ticket #22 (closed defect: fixed)

Opened 4 years ago

Last modified 4 years ago

IndexScalar does not produce the correct value when it is used in the default value expression of scan and fold

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

Description (last modified by seanl) (diff)

IndexScalar does not produce the correct value when it is used in the default value expressions of scan and fold.

For example,

foo :: Vector Word32 -> Acc (Vector Word32)
foo xs
  = let
      xs' = use xs
    in
    Prelude.fst $ Acc.scanl const (xs' Acc.! constant 4) xs'

main :: IO ()
main = do
  let input = fromList 10 [0..] :: Vector (Word32)
  r <- CUDA.run $ foo input2
  putStrLn $ show r

is meant to produce

Array 10 [4,4,4,4,4,4,4,4,4,4]

but it produces

Array 10 [0,0,0,0,0,0,0,0,0,0]

Change History

Changed 4 years ago by seanl

  • description modified (diff)
  • summary changed from IndexScalar does not produce the correct value when it is used in the default value expression of scan and fold to IndexScalar does not produce the correct value when it is used in the default value expression of scan

Changed 4 years ago by seanl

  • description modified (diff)
  • summary changed from IndexScalar does not produce the correct value when it is used in the default value expression of scan to IndexScalar does not produce the correct value when it is used in the default value expression of scan and fold

Changed 4 years ago by seanl

  • owner changed from tmcdonell to seanl

Changed 4 years ago by seanl

  • description modified (diff)

Changed 4 years ago by seanl

  • status changed from new to assigned

Changed 4 years ago by seanl

  • description modified (diff)

Fixed it by replacing

f_arr <- liftFun f env

in the dispatch function for scan and fold

with

f_arr <- (++) <$> liftExp x env <*> liftFun f env

to lift the free array variables from both the default value expression and the scalar function.

Also, I added

release f_arr

at the end of dispatchScan to make sure that the device memory allocated for the free array variable.

Changed 4 years ago by seanl

Also, I added

release f_arr

at the end of dispatchScan to make sure that the device memory allocated for the free array variables is freed.

Changed 4 years ago by tmcdonell

  • status changed from assigned to closed
  • resolution set to fixed
Mon Aug  9 22:56:43 EST 2010  seanl@cse.unsw.edu.au
  * fix for the problem that IndexScalar does not produce the correct value when it is used in the default value expression of scan and fold.
Note: See TracTickets for help on using tickets.