{-# LANGUAGE CPP #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeApplications #-}
module Data.Array.Accelerate.Numeric.Sum.LLVM.PTX (
fadd, fsub, fmul,
) where
import Data.Array.Accelerate as A
import Data.Array.Accelerate.Type
import Data.Array.Accelerate.Sugar.Elt
#ifdef ACCELERATE_LLVM_PTX_BACKEND
import Data.Array.Accelerate.LLVM.CodeGen.Sugar
import Data.Array.Accelerate.LLVM.PTX.Foreign as A
import qualified Data.Array.Accelerate.Numeric.Sum.LLVM.Prim as Prim
#endif
#ifdef ACCELERATE_LLVM_PTX_BACKEND
wrap2 :: (Elt a, Elt b, Elt c)
=> String
-> IRFun1 PTX () (EltR (a, b) -> EltR c)
-> (Exp a -> Exp b -> Exp c)
-> Exp a
-> Exp b
-> Exp c
wrap2 :: String
-> IRFun1 PTX () (EltR (a, b) -> EltR c)
-> (Exp a -> Exp b -> Exp c)
-> Exp a
-> Exp b
-> Exp c
wrap2 String
str IRFun1 PTX () (EltR (a, b) -> EltR c)
f Exp a -> Exp b -> Exp c
g = (Exp (Plain (Exp a), Plain (Exp b)) -> Exp c)
-> Exp a -> Exp b -> Exp c
forall (f :: * -> *) a b c.
Lift f (f a, f b) =>
(f (Plain (f a), Plain (f b)) -> f c) -> f a -> f b -> f c
A.curry (ForeignExp (EltR (a, b) -> EltR c)
-> (Exp (a, b) -> Exp c) -> Exp (a, b) -> Exp c
forall x y (asm :: * -> *).
(Elt x, Elt y, Foreign asm) =>
asm (EltR x -> EltR y) -> (Exp x -> Exp y) -> Exp x -> Exp y
foreignExp (String
-> IRFun1 PTX () ((((), EltR a), EltR b) -> EltR c)
-> ForeignExp ((((), EltR a), EltR b) -> EltR c)
forall x y. String -> IRFun1 PTX () (x -> y) -> ForeignExp (x -> y)
ForeignExp String
str IRFun1 PTX () ((((), EltR a), EltR b) -> EltR c)
IRFun1 PTX () (EltR (a, b) -> EltR c)
f) ((Exp a -> Exp b -> Exp c)
-> Exp (Plain (Exp a), Plain (Exp b)) -> Exp c
forall (f :: * -> *) a b c.
Unlift f (f a, f b) =>
(f a -> f b -> f c) -> f (Plain (f a), Plain (f b)) -> f c
A.uncurry Exp a -> Exp b -> Exp c
g))
#endif
fadd :: forall a. (Elt a, IsFloating a) => (Exp a -> Exp a -> Exp a) -> Exp a -> Exp a -> Exp a
#ifdef ACCELERATE_LLVM_PTX_BACKEND
fadd :: (Exp a -> Exp a -> Exp a) -> Exp a -> Exp a -> Exp a
fadd = String
-> IRFun1 PTX () (EltR (a, a) -> EltR a)
-> (Exp a -> Exp a -> Exp a)
-> Exp a
-> Exp a
-> Exp a
forall a b c.
(Elt a, Elt b, Elt c) =>
String
-> IRFun1 PTX () (EltR (a, b) -> EltR c)
-> (Exp a -> Exp b -> Exp c)
-> Exp a
-> Exp b
-> Exp c
wrap2 String
"fadd" (FloatingType a
-> IROpenFun1 PTX () () ((((), EltR a), EltR a) -> EltR a)
forall a arch env aenv.
FloatingType a
-> IROpenFun1 arch env aenv ((((), EltR a), EltR a) -> EltR a)
Prim.fadd (IsFloating a => FloatingType a
forall a. IsFloating a => FloatingType a
floatingType @a))
#else
fadd = id
#endif
fsub :: forall a. (Elt a, IsFloating a) => (Exp a -> Exp a -> Exp a) -> Exp a -> Exp a -> Exp a
#ifdef ACCELERATE_LLVM_PTX_BACKEND
fsub :: (Exp a -> Exp a -> Exp a) -> Exp a -> Exp a -> Exp a
fsub = String
-> IRFun1 PTX () (EltR (a, a) -> EltR a)
-> (Exp a -> Exp a -> Exp a)
-> Exp a
-> Exp a
-> Exp a
forall a b c.
(Elt a, Elt b, Elt c) =>
String
-> IRFun1 PTX () (EltR (a, b) -> EltR c)
-> (Exp a -> Exp b -> Exp c)
-> Exp a
-> Exp b
-> Exp c
wrap2 String
"fsub" (FloatingType a
-> IROpenFun1 PTX () () ((((), EltR a), EltR a) -> EltR a)
forall a arch env aenv.
FloatingType a
-> IROpenFun1 arch env aenv ((((), EltR a), EltR a) -> EltR a)
Prim.fsub (IsFloating a => FloatingType a
forall a. IsFloating a => FloatingType a
floatingType @a))
#else
fsub = id
#endif
fmul :: forall a. (Elt a, IsFloating a) => (Exp a -> Exp a -> Exp a) -> Exp a -> Exp a -> Exp a
#ifdef ACCELERATE_LLVM_PTX_BACKEND
fmul :: (Exp a -> Exp a -> Exp a) -> Exp a -> Exp a -> Exp a
fmul = String
-> IRFun1 PTX () (EltR (a, a) -> EltR a)
-> (Exp a -> Exp a -> Exp a)
-> Exp a
-> Exp a
-> Exp a
forall a b c.
(Elt a, Elt b, Elt c) =>
String
-> IRFun1 PTX () (EltR (a, b) -> EltR c)
-> (Exp a -> Exp b -> Exp c)
-> Exp a
-> Exp b
-> Exp c
wrap2 String
"fmul" (FloatingType a
-> IROpenFun1 PTX () () ((((), EltR a), EltR a) -> EltR a)
forall a arch env aenv.
FloatingType a
-> IROpenFun1 arch env aenv ((((), EltR a), EltR a) -> EltR a)
Prim.fmul (IsFloating a => FloatingType a
forall a. IsFloating a => FloatingType a
floatingType @a))
#else
fmul = id
#endif