Skip to content

Commit

Permalink
More and fixed Haddocks.
Browse files Browse the repository at this point in the history
  • Loading branch information
athas committed Jan 25, 2021
1 parent f863b23 commit 24d0720
Show file tree
Hide file tree
Showing 23 changed files with 49 additions and 13 deletions.
1 change: 1 addition & 0 deletions src/Futhark/Actions.hs
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ kernelImpCodeGenAction =
actionProcedure = liftIO . putStrLn . pretty . snd <=< ImpGenKernels.compileProgOpenCL
}

-- | Convert the program to CPU multicore ImpCode and print it to stdout.
multicoreImpCodeGenAction :: Action MCMem
multicoreImpCodeGenAction =
Action
Expand Down
12 changes: 6 additions & 6 deletions src/Futhark/Analysis/PrimExp.hs
Original file line number Diff line number Diff line change
Expand Up @@ -147,31 +147,31 @@ instance Traversable (TPrimExp t) where
instance FreeIn v => FreeIn (TPrimExp t v) where
freeIn' = freeIn' . untyped

-- | This expression is of type 'Int8'.
-- | This expression is of type t'Int8'.
isInt8 :: PrimExp v -> TPrimExp Int8 v
isInt8 = TPrimExp

-- | This expression is of type 'Int16'.
-- | This expression is of type t'Int16'.
isInt16 :: PrimExp v -> TPrimExp Int16 v
isInt16 = TPrimExp

-- | This expression is of type 'Int32'.
-- | This expression is of type t'Int32'.
isInt32 :: PrimExp v -> TPrimExp Int32 v
isInt32 = TPrimExp

-- | This expression is of type 'Int64'.
-- | This expression is of type t'Int64'.
isInt64 :: PrimExp v -> TPrimExp Int64 v
isInt64 = TPrimExp

-- | This is a boolean expression.
isBool :: PrimExp v -> TPrimExp Bool v
isBool = TPrimExp

-- | This expression is of type 'Float'.
-- | This expression is of type t'Float'.
isF32 :: PrimExp v -> TPrimExp Float v
isF32 = TPrimExp

-- | This expression is of type 'Double'.
-- | This expression is of type t'Double'.
isF64 :: PrimExp v -> TPrimExp Double v
isF64 = TPrimExp

Expand Down
1 change: 1 addition & 0 deletions src/Futhark/CLI/Literate.hs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE OverloadedStrings #-}

-- | @futhark literate@
module Futhark.CLI.Literate (main) where

import Control.Monad.Except
Expand Down
2 changes: 2 additions & 0 deletions src/Futhark/CLI/Multicore.hs
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
{-# LANGUAGE FlexibleContexts #-}

-- | @futhark multicore@
module Futhark.CLI.Multicore (main) where

import Futhark.Actions (compileMulticoreAction)
import Futhark.Compiler.CLI
import Futhark.Passes (multicorePipeline)

-- | Run @futhark multicore@.
main :: String -> [String] -> IO ()
main = compilerMain
()
Expand Down
3 changes: 3 additions & 0 deletions src/Futhark/CodeGen/Backends/GenericC/CLI.hs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
{-# LANGUAGE Trustworthy #-}
{-# LANGUAGE TupleSections #-}

-- | Code generation for standalone executables.
module Futhark.CodeGen.Backends.GenericC.CLI
( cliDefs,
)
Expand Down Expand Up @@ -362,6 +363,8 @@ cliEntryPoint fname (Function _ _ _ _ results args) =
)

{-# NOINLINE cliDefs #-}

-- | Generate Futhark standalone executable code.
cliDefs :: [Option] -> Functions a -> [C.Definition]
cliDefs options (Functions funs) =
let values_h = $(embedStringFile "rts/c/values.h")
Expand Down
3 changes: 3 additions & 0 deletions src/Futhark/CodeGen/Backends/GenericC/Server.hs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
{-# LANGUAGE Trustworthy #-}
{-# LANGUAGE TupleSections #-}

-- | Code generation for server executables.
module Futhark.CodeGen.Backends.GenericC.Server
( serverDefs,
)
Expand Down Expand Up @@ -205,6 +206,8 @@ mkBoilerplate funs =
in (type_defs ++ entry_defs, type_inits, entry_inits)

{-# NOINLINE serverDefs #-}

-- | Generate Futhark server executable code.
serverDefs :: [Option] -> Functions a -> [C.Definition]
serverDefs options funs =
let server_h = $(embedStringFile "rts/c/server.h")
Expand Down
1 change: 1 addition & 0 deletions src/Futhark/CodeGen/Backends/MulticoreC.hs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import Futhark.MonadFreshNames
import qualified Language.C.Quote.OpenCL as C
import qualified Language.C.Syntax as C

-- | Compile the program to ImpCode with multicore operations.
compileProg ::
MonadFreshNames m =>
Prog MCMem ->
Expand Down
3 changes: 2 additions & 1 deletion src/Futhark/CodeGen/Backends/PyOpenCL.hs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE TupleSections #-}

-- | Code generation for Python with OpenCL.
module Futhark.CodeGen.Backends.PyOpenCL
( compileProg,
)
Expand All @@ -18,7 +19,7 @@ import Futhark.IR.KernelsMem (KernelsMem, Prog)
import Futhark.MonadFreshNames
import Futhark.Util (zEncodeString)

--maybe pass the config file rather than multiple arguments
-- | Compile the program to Python with calls to OpenCL.
compileProg ::
MonadFreshNames m =>
Py.CompilerMode ->
Expand Down
2 changes: 2 additions & 0 deletions src/Futhark/CodeGen/Backends/SequentialPython.hs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
-- | Code generation for sequential Python.
module Futhark.CodeGen.Backends.SequentialPython
( compileProg,
)
Expand All @@ -11,6 +12,7 @@ import qualified Futhark.CodeGen.ImpGen.Sequential as ImpGen
import Futhark.IR.SeqMem
import Futhark.MonadFreshNames

-- | Compile the program to Python.
compileProg ::
MonadFreshNames m =>
GenericPython.CompilerMode ->
Expand Down
2 changes: 2 additions & 0 deletions src/Futhark/CodeGen/ImpCode.hs
Original file line number Diff line number Diff line change
Expand Up @@ -599,6 +599,8 @@ instance Traversable Code where
traverse _ (DebugPrint s v) =
pure $ DebugPrint s v

-- | The names declared with 'DeclareMem', 'DeclareScalar', and
-- 'DeclareArray' in the given code.
declaredIn :: Code a -> Names
declaredIn (DeclareMem name _) = oneName name
declaredIn (DeclareScalar name _ _) = oneName name
Expand Down
2 changes: 1 addition & 1 deletion src/Futhark/CodeGen/ImpGen.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1567,7 +1567,7 @@ compileAlloc pat _ _ =
error $ "compileAlloc: Invalid pattern: " ++ pretty pat

-- | The number of bytes needed to represent the array in a
-- straightforward contiguous format, as an 'Int64' expression.
-- straightforward contiguous format, as an t'Int64' expression.
typeSize :: Type -> Count Bytes (Imp.TExp Int64)
typeSize t =
Imp.bytes $
Expand Down
2 changes: 2 additions & 0 deletions src/Futhark/CodeGen/ImpGen/CUDA.hs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
-- | Code generation for ImpCode with CUDA kernels.
module Futhark.CodeGen.ImpGen.CUDA
( compileProg,
Warnings,
Expand All @@ -11,5 +12,6 @@ import Futhark.CodeGen.ImpGen.Kernels.ToOpenCL
import Futhark.IR.KernelsMem
import Futhark.MonadFreshNames

-- | Compile the program to ImpCode with CUDA kernels.
compileProg :: MonadFreshNames m => Prog KernelsMem -> m (Warnings, Program)
compileProg prog = second kernelsToCUDA <$> compileProgCUDA prog
2 changes: 1 addition & 1 deletion src/Futhark/CodeGen/ImpGen/Kernels/SegRed.hs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ maxNumOps = 10
-- | Code generation for the body of the SegRed, taking a continuation
-- for saving the results of the body. The results should be
-- represented as a pairing of a t'SubExp' along with a list of
-- indexes into that 'SubExp' for reading the result.
-- indexes into that t'SubExp' for reading the result.
type DoSegBody = ([(SubExp, [Imp.TExp Int64])] -> InKernelGen ()) -> InKernelGen ()

-- | Compile 'SegRed' instance to host-level code with calls to
Expand Down
3 changes: 3 additions & 0 deletions src/Futhark/CodeGen/ImpGen/Kernels/SegScan.hs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
-- | Code generation for 'SegScan'. Dispatches to either a
-- single-pass or two-pass implementation, depending on the nature of
-- the scan and the chosen abckend.
module Futhark.CodeGen.ImpGen.Kernels.SegScan (compileSegScan) where

import qualified Futhark.CodeGen.ImpCode.Kernels as Imp
Expand Down
1 change: 1 addition & 0 deletions src/Futhark/CodeGen/ImpGen/Multicore.hs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE TypeFamilies #-}

-- | Code generation for ImpCode with multicore operations.
module Futhark.CodeGen.ImpGen.Multicore
( Futhark.CodeGen.ImpGen.Multicore.compileProg,
Warnings,
Expand Down
4 changes: 2 additions & 2 deletions src/Futhark/CodeGen/ImpGen/Multicore/Base.hs
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,8 @@ decideScheduling code =
else Imp.Dynamic

-- | Try to extract invariant allocations. If we assume that the
-- given 'Code' is the body of a 'SegOp', then it is always safe to
-- move the immediate allocations to the prebody.
-- given 'Imp.Code' is the body of a 'SegOp', then it is always safe
-- to move the immediate allocations to the prebody.
extractAllocations :: Imp.Code -> (Imp.Code, Imp.Code)
extractAllocations segop_code = f segop_code
where
Expand Down
1 change: 1 addition & 0 deletions src/Futhark/CodeGen/ImpGen/Multicore/SegMap.hs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
-- | Multicore code generation for 'SegMap'.
module Futhark.CodeGen.ImpGen.Multicore.SegMap
( compileSegMap,
)
Expand Down
2 changes: 2 additions & 0 deletions src/Futhark/CodeGen/ImpGen/OpenCL.hs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
-- | Code generation for ImpCode with OpenCL kernels.
module Futhark.CodeGen.ImpGen.OpenCL
( compileProg,
Warnings,
Expand All @@ -11,5 +12,6 @@ import Futhark.CodeGen.ImpGen.Kernels.ToOpenCL
import Futhark.IR.KernelsMem
import Futhark.MonadFreshNames

-- | Compile the program to ImpCode with OpenCL kernels.
compileProg :: MonadFreshNames m => Prog KernelsMem -> m (Warnings, OpenCL.Program)
compileProg prog = second kernelsToOpenCL <$> compileProgOpenCL prog
2 changes: 1 addition & 1 deletion src/Futhark/IR/Prop/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ shapeContext =
ext (Free _) = Nothing

-- | If all dimensions of the given 'ExtShape' are statically known,
-- change to the corresponding 'Shape'.
-- change to the corresponding t'Shape'.
hasStaticShape :: TypeBase ExtShape u -> Maybe (TypeBase Shape u)
hasStaticShape (Prim bt) = Just $ Prim bt
hasStaticShape (Mem space) = Just $ Mem space
Expand Down
2 changes: 2 additions & 0 deletions src/Futhark/Internalise/LiftLambdas.hs
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,8 @@ transformValBind vb = do
addValBind $ vb {valBindBody = e}

{-# NOINLINE transformProg #-}

-- | Perform the transformation.
transformProg :: MonadFreshNames m => [ValBind] -> m [ValBind]
transformProg vbinds =
modifyNameSource $ \namesrc ->
Expand Down
8 changes: 7 additions & 1 deletion src/Futhark/Script.hs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

-- | FutharkScript is a (tiny) subset of Futhark used to write small
-- expressions that are evaluated by server executables. The @futhark
-- script@ command is the main user.
-- literate@ command is the main user.
module Futhark.Script
( -- * Server
ScriptServer,
Expand Down Expand Up @@ -65,6 +65,10 @@ withScriptServer prog options f = withServer prog options $ \server -> do
counter <- newIORef 0
f $ ScriptServer server counter

-- | A FutharkScript expression. This is a simple AST that might not
-- correspond exactly to what the user wrote (e.g. no parentheses or
-- source locations). This is fine for small expressions, which is
-- all this is meant for.
data Exp
= Call EntryName [Exp]
| Const PrimValue
Expand Down Expand Up @@ -162,6 +166,7 @@ inParens sep = between (lexeme sep "(") (lexeme sep ")")
inBraces :: Parser () -> Parser a -> Parser a
inBraces sep = between (lexeme sep "{") (lexeme sep "}")

-- | Parse a FutharkScript expression.
parseExp :: Parser () -> Parser Exp
parseExp sep =
choice
Expand Down Expand Up @@ -270,6 +275,7 @@ valueToExp (V.ValueRecord fs) =
valueToExp (V.ValueTuple fs) =
Tuple $ map valueToExp fs

-- | Evaluate a FutharkScript expression relative to some running server.
evalExp :: (MonadError T.Text m, MonadIO m) => ScriptServer -> Exp -> m ExpValue
evalExp (ScriptServer server counter) top_level_e = do
vars <- liftIO $ newIORef []
Expand Down
1 change: 1 addition & 0 deletions src/Futhark/Test.hs
Original file line number Diff line number Diff line change
Expand Up @@ -787,6 +787,7 @@ runProgram futhark runner extra_options prog entry input = do
input' <- getValuesBS futhark dir input
liftIO $ readProcessWithExitCode to_run to_run_args $ BS.toStrict input'

-- | Read the given variables from a running server.
readResults ::
(MonadIO m, MonadError T.Text m) =>
Server ->
Expand Down
2 changes: 2 additions & 0 deletions src/Language/Futhark/TypeChecker/Match.hs
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,8 @@ findUnmatched [] _ = [[]]
findUnmatched _ _ = []

{-# NOINLINE unmatched #-}

-- | Find the unmatched cases.
unmatched :: [Pattern] -> [Match]
unmatched orig_ps =
-- The algorithm may find duplicate example, which we filter away
Expand Down

0 comments on commit 24d0720

Please sign in to comment.