{-# LINE 1 "src/Foreign/CUDA/Driver/Graph/Base.chs" #-}
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE CPP #-}
{-# LANGUAGE EmptyDataDecls #-}
{-# LANGUAGE ForeignFunctionInterface #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE EmptyCase #-}
module Foreign.CUDA.Driver.Graph.Base
where
import qualified Foreign.Ptr as C2HSImp
{-# LINE 26 "src/Foreign/CUDA/Driver/Graph/Base.chs" #-}
import Foreign.Storable
import Foreign.Ptr
newtype Graph = Graph { Graph -> Ptr ()
useGraph :: ((C2HSImp.Ptr ()))}
deriving (Graph -> Graph -> Bool
(Graph -> Graph -> Bool) -> (Graph -> Graph -> Bool) -> Eq Graph
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Graph -> Graph -> Bool
== :: Graph -> Graph -> Bool
$c/= :: Graph -> Graph -> Bool
/= :: Graph -> Graph -> Bool
Eq, Int -> Graph -> ShowS
[Graph] -> ShowS
Graph -> String
(Int -> Graph -> ShowS)
-> (Graph -> String) -> ([Graph] -> ShowS) -> Show Graph
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Graph -> ShowS
showsPrec :: Int -> Graph -> ShowS
$cshow :: Graph -> String
show :: Graph -> String
$cshowList :: [Graph] -> ShowS
showList :: [Graph] -> ShowS
Show)
data GraphFlag
instance Enum GraphFlag where
toEnum :: Int -> GraphFlag
toEnum Int
x = String -> GraphFlag
forall a. HasCallStack => String -> a
error (String
"GraphFlag.toEnum: Cannot match " String -> ShowS
forall a. [a] -> [a] -> [a]
++ Int -> String
forall a. Show a => a -> String
show Int
x)
fromEnum :: GraphFlag -> Int
fromEnum GraphFlag
x = case GraphFlag
x of {}
newtype Node = Node { Node -> Ptr ()
useNode :: ((C2HSImp.Ptr ()))}
deriving (Node -> Node -> Bool
(Node -> Node -> Bool) -> (Node -> Node -> Bool) -> Eq Node
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Node -> Node -> Bool
== :: Node -> Node -> Bool
$c/= :: Node -> Node -> Bool
/= :: Node -> Node -> Bool
Eq, Int -> Node -> ShowS
[Node] -> ShowS
Node -> String
(Int -> Node -> ShowS)
-> (Node -> String) -> ([Node] -> ShowS) -> Show Node
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Node -> ShowS
showsPrec :: Int -> Node -> ShowS
$cshow :: Node -> String
show :: Node -> String
$cshowList :: [Node] -> ShowS
showList :: [Node] -> ShowS
Show, Ptr Node -> IO Node
Ptr Node -> Int -> IO Node
Ptr Node -> Int -> Node -> IO ()
Ptr Node -> Node -> IO ()
Node -> Int
(Node -> Int)
-> (Node -> Int)
-> (Ptr Node -> Int -> IO Node)
-> (Ptr Node -> Int -> Node -> IO ())
-> (forall b. Ptr b -> Int -> IO Node)
-> (forall b. Ptr b -> Int -> Node -> IO ())
-> (Ptr Node -> IO Node)
-> (Ptr Node -> Node -> IO ())
-> Storable Node
forall b. Ptr b -> Int -> IO Node
forall b. Ptr b -> Int -> Node -> IO ()
forall a.
(a -> Int)
-> (a -> Int)
-> (Ptr a -> Int -> IO a)
-> (Ptr a -> Int -> a -> IO ())
-> (forall b. Ptr b -> Int -> IO a)
-> (forall b. Ptr b -> Int -> a -> IO ())
-> (Ptr a -> IO a)
-> (Ptr a -> a -> IO ())
-> Storable a
$csizeOf :: Node -> Int
sizeOf :: Node -> Int
$calignment :: Node -> Int
alignment :: Node -> Int
$cpeekElemOff :: Ptr Node -> Int -> IO Node
peekElemOff :: Ptr Node -> Int -> IO Node
$cpokeElemOff :: Ptr Node -> Int -> Node -> IO ()
pokeElemOff :: Ptr Node -> Int -> Node -> IO ()
$cpeekByteOff :: forall b. Ptr b -> Int -> IO Node
peekByteOff :: forall b. Ptr b -> Int -> IO Node
$cpokeByteOff :: forall b. Ptr b -> Int -> Node -> IO ()
pokeByteOff :: forall b. Ptr b -> Int -> Node -> IO ()
$cpeek :: Ptr Node -> IO Node
peek :: Ptr Node -> IO Node
$cpoke :: Ptr Node -> Node -> IO ()
poke :: Ptr Node -> Node -> IO ()
Storable)
data NodeType = Kernel
| Memcpy
| Memset
| Host
| Subgraph
| Empty
| WaitEvent
| EventRecord
| ExtSemasSignal
| ExtSemasWait
| MemAlloc
| MemFree
| BatchMemOp
deriving (NodeType -> NodeType -> Bool
(NodeType -> NodeType -> Bool)
-> (NodeType -> NodeType -> Bool) -> Eq NodeType
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: NodeType -> NodeType -> Bool
== :: NodeType -> NodeType -> Bool
$c/= :: NodeType -> NodeType -> Bool
/= :: NodeType -> NodeType -> Bool
Eq,Int -> NodeType -> ShowS
[NodeType] -> ShowS
NodeType -> String
(Int -> NodeType -> ShowS)
-> (NodeType -> String) -> ([NodeType] -> ShowS) -> Show NodeType
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> NodeType -> ShowS
showsPrec :: Int -> NodeType -> ShowS
$cshow :: NodeType -> String
show :: NodeType -> String
$cshowList :: [NodeType] -> ShowS
showList :: [NodeType] -> ShowS
Show,NodeType
NodeType -> NodeType -> Bounded NodeType
forall a. a -> a -> Bounded a
$cminBound :: NodeType
minBound :: NodeType
$cmaxBound :: NodeType
maxBound :: NodeType
Bounded)
instance Enum NodeType where
succ :: NodeType -> NodeType
succ NodeType
Kernel = NodeType
Memcpy
succ NodeType
Memcpy = NodeType
Memset
succ NodeType
Memset = NodeType
Host
succ NodeType
Host = NodeType
Subgraph
succ NodeType
Subgraph = NodeType
Empty
succ NodeType
Empty = NodeType
WaitEvent
succ NodeType
WaitEvent = NodeType
EventRecord
succ NodeType
EventRecord = NodeType
ExtSemasSignal
succ NodeType
ExtSemasSignal = NodeType
ExtSemasWait
succ ExtSemasWait = MemAlloc
succ MemAlloc = MemFree
succ NodeType
MemFree = NodeType
BatchMemOp
succ NodeType
BatchMemOp = String -> NodeType
forall a. HasCallStack => String -> a
error String
"NodeType.succ: BatchMemOp has no successor"
pred :: NodeType -> NodeType
pred NodeType
Memcpy = NodeType
Kernel
pred NodeType
Memset = NodeType
Memcpy
pred NodeType
Host = NodeType
Memset
pred NodeType
Subgraph = NodeType
Host
pred NodeType
Empty = NodeType
Subgraph
pred NodeType
WaitEvent = NodeType
Empty
pred NodeType
EventRecord = NodeType
WaitEvent
pred NodeType
ExtSemasSignal = NodeType
EventRecord
pred NodeType
ExtSemasWait = NodeType
ExtSemasSignal
pred NodeType
MemAlloc = NodeType
ExtSemasWait
pred NodeType
MemFree = NodeType
MemAlloc
pred NodeType
BatchMemOp = NodeType
MemFree
pred NodeType
Kernel = String -> NodeType
forall a. HasCallStack => String -> a
error String
"NodeType.pred: Kernel has no predecessor"
enumFromTo :: NodeType -> NodeType -> [NodeType]
enumFromTo NodeType
from NodeType
to = NodeType -> [NodeType]
forall {t}. Enum t => t -> [t]
go NodeType
from
where
end :: Int
end = NodeType -> Int
forall a. Enum a => a -> Int
fromEnum NodeType
to
go :: t -> [t]
go t
v = case Int -> Int -> Ordering
forall a. Ord a => a -> a -> Ordering
compare (t -> Int
forall a. Enum a => a -> Int
fromEnum t
v) Int
end of
Ordering
LT -> t
v t -> [t] -> [t]
forall a. a -> [a] -> [a]
: t -> [t]
go (t -> t
forall a. Enum a => a -> a
succ t
v)
Ordering
EQ -> [t
v]
Ordering
GT -> []
enumFrom :: NodeType -> [NodeType]
enumFrom NodeType
from = NodeType -> NodeType -> [NodeType]
forall a. Enum a => a -> a -> [a]
enumFromTo NodeType
from NodeType
BatchMemOp
fromEnum :: NodeType -> Int
fromEnum NodeType
Kernel = Int
0
fromEnum NodeType
Memcpy = Int
1
fromEnum NodeType
Memset = Int
2
fromEnum NodeType
Host = Int
3
fromEnum NodeType
Subgraph = Int
4
fromEnum NodeType
Empty = Int
5
fromEnum NodeType
WaitEvent = Int
6
fromEnum NodeType
EventRecord = Int
7
fromEnum NodeType
ExtSemasSignal = Int
8
fromEnum NodeType
ExtSemasWait = Int
9
fromEnum NodeType
MemAlloc = Int
10
fromEnum NodeType
MemFree = Int
11
fromEnum NodeType
BatchMemOp = Int
12
toEnum :: Int -> NodeType
toEnum Int
0 = NodeType
Kernel
toEnum Int
1 = NodeType
Memcpy
toEnum Int
2 = NodeType
Memset
toEnum Int
3 = NodeType
Host
toEnum Int
4 = NodeType
Subgraph
toEnum Int
5 = NodeType
Empty
toEnum Int
6 = NodeType
WaitEvent
toEnum Int
7 = NodeType
EventRecord
toEnum Int
8 = NodeType
ExtSemasSignal
toEnum Int
9 = NodeType
ExtSemasWait
toEnum Int
10 = NodeType
MemAlloc
toEnum Int
11 = NodeType
MemFree
toEnum Int
12 = NodeType
BatchMemOp
toEnum Int
unmatched = String -> NodeType
forall a. HasCallStack => String -> a
error (String
"NodeType.toEnum: Cannot match " String -> ShowS
forall a. [a] -> [a] -> [a]
++ Int -> String
forall a. Show a => a -> String
show Int
unmatched)
{-# LINE 68 "src/Foreign/CUDA/Driver/Graph/Base.chs" #-}
newtype Executable = Executable { useExecutable :: ((C2HSImp.Ptr ()))}
deriving (Eq, Show)