module Futhark.CodeGen.Backends.SequentialPython
( compileProg,
)
where
import Control.Monad
import Data.Text qualified as T
import Futhark.CodeGen.Backends.GenericPython qualified as GenericPython
import Futhark.CodeGen.Backends.GenericPython.AST
import Futhark.CodeGen.ImpCode.Sequential qualified as Imp
import Futhark.CodeGen.ImpGen.Sequential qualified as ImpGen
import Futhark.IR.SeqMem
import Futhark.MonadFreshNames
compileProg ::
(MonadFreshNames m) =>
GenericPython.CompilerMode ->
String ->
Prog SeqMem ->
m (ImpGen.Warnings, T.Text)
compileProg :: forall (m :: * -> *).
MonadFreshNames m =>
CompilerMode -> String -> Prog SeqMem -> m (Warnings, Text)
compileProg CompilerMode
mode String
class_name =
forall (m :: * -> *).
MonadFreshNames m =>
Prog SeqMem -> m (Warnings, Program)
ImpGen.compileProg
forall (m :: * -> *) a b c.
Monad m =>
(a -> m b) -> (b -> m c) -> a -> m c
>=> forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse
( forall (m :: * -> *) op s.
MonadFreshNames m =>
CompilerMode
-> String
-> Constructor
-> [PyStmt]
-> [PyStmt]
-> Operations op s
-> s
-> [PyStmt]
-> [Option]
-> Definitions op
-> m Text
GenericPython.compileProg
CompilerMode
mode
String
class_name
Constructor
GenericPython.emptyConstructor
[PyStmt]
imports
forall {a}. [a]
defines
Operations Sequential ()
operations
()
[]
[]
)
where
imports :: [PyStmt]
imports =
[ String -> Maybe String -> PyStmt
Import String
"sys" forall a. Maybe a
Nothing,
String -> Maybe String -> PyStmt
Import String
"numpy" forall a b. (a -> b) -> a -> b
$ forall a. a -> Maybe a
Just String
"np",
String -> Maybe String -> PyStmt
Import String
"ctypes" forall a b. (a -> b) -> a -> b
$ forall a. a -> Maybe a
Just String
"ct",
String -> Maybe String -> PyStmt
Import String
"time" forall a. Maybe a
Nothing
]
defines :: [a]
defines = []
operations :: GenericPython.Operations Imp.Sequential ()
operations :: Operations Sequential ()
operations =
forall op s. Operations op s
GenericPython.defaultOperations
{ opsCompiler :: OpCompiler Sequential ()
GenericPython.opsCompiler = forall a b. a -> b -> a
const forall a b. (a -> b) -> a -> b
$ forall (f :: * -> *) a. Applicative f => a -> f a
pure ()
}