Skip to content

./Data/Array/Accelerate/LLVM/PTX/State.hs:50:9: (unhandled): CUDA Exception: invalid argument #375

@alang9

Description

@alang9

I'm getting this weird error:

*** Exception: 
*** Internal error in package accelerate ***
*** Please submit a bug report at https://github.com/AccelerateHS/accelerate/issues
./Data/Array/Accelerate/LLVM/PTX/State.hs:50:9: (unhandled): CUDA Exception: invalid argument
CallStack (from HasCallStack):
  error, called at ./Data/Array/Accelerate/LLVM/PTX/State.hs:50:9 in accelerate-llvm-ptx-1.0.0.0-NmZValj0z98sMHA20PqUN:Data.Array.Accelerate.LLVM.PTX.State

On this code. I'm using accelerate, accelerate-llvm, accelerate-llvm-ptx 1.0.0.0. I'm also using master of linear-accelerate: https://github.com/ekmett/linear-accelerate

Running foo here causes the error:

multiplyMatrix4Vector ::
   forall a f. (A.Elt a, P.Num (Exp a), Functor f, Box f a, Additive f, A.Elt (f a)) =>
   Acc (Matrix (f a)) ->
   Acc (Vector a) ->
   Acc (Vector (f a))
multiplyMatrix4Vector m v =
    A.fold1 (^+^) $
    (A.zipWith (\v' s' -> s' *^ v') m
       (A.replicate (A.lift $ Any :. rows :. All) v) :: Acc (Matrix (f a)))
  where
    Z :. (rows :: Exp Int) :. (_cols :: Exp Int) = unlift (shape m)

foo :: ([Double], [Double], [Double])
foo = 
    (A.toList dCArr, map (view L._x) (A.toList outMat :: [V4 Double]), A.toList outVec)
  where
    n = 1
    xs = [27000]
    (dCArr, outMat :: Matrix (V4 Double), outVec) =
        run1 code ( A.fromList (Z :. P.length xs) xs, singleton n)
    code :: Acc ( A.Vector Double, A.Scalar Int)
         -> Acc ( A.Vector Double, Matrix (V4 Double), A.Vector Double)
    code (unlift -> (xs, (the -> n))) = out
      where
        out :: Acc (A.Vector Double, Matrix (V4 Double), A.Vector Double)
        out = A.lift
            ( dC -- A.fromList (Z :. 0) []
            , phiMat -- A.fromList (Z :. 0 :. 0) []
            , uPut -- A.fromList (Z :. 0) []
            )
        dC = A.map (view _x) $
            multiplyMatrix4Vector phiMat uPut
        phiMat = A.generate (A.index2 (A.length xs) n) $
            \_ -> A.lift (V4 0 0 0 0 :: V4 (Exp Double))
        uPut = A.generate (lift $ Z :. n) $ \_ -> 0
  • replacing dC by A.fromList (Z :. 0) [] makes the error go away
  • replacing phiMat by A.fromList (Z :. 0 :. 0) [] makes the error go away
  • replacing uPut by A.fromList (Z :. 0) [] makes the error go away
  • replacing all the V4s by V3s or V2s makes the error go away

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions