futhark-0.25.32: An optimising compiler for a functional, array-oriented language.

Safe Haskell | None
Language | GHC2021

Futhark.Test

Description

Facilities for reading Futhark test programs. A Futhark test program is an ordinary Futhark program where an initial comment block specifies input- and output-sets.

Synopsis

- module Futhark.Test.Spec
- valuesFromByteString :: String -> ByteString -> Either String [Value]
- newtype FutharkExe = FutharkExe FilePath
- getValues :: (MonadFail m, MonadIO m) => FutharkExe -> FilePath -> Values -> m [Value]
- getValuesBS :: (MonadFail m, MonadIO m) => FutharkExe -> FilePath -> Values -> m ByteString
- valuesAsVars :: (MonadError Text m, MonadIO m) => Server -> [(VarName, TypeName)] -> FutharkExe -> FilePath -> Values -> m ()
- compareValues :: Tolerance -> Value -> Value -> [Mismatch]
- checkResult :: (MonadError Text m, MonadIO m) => FilePath -> [Value] -> [Value] -> m ()
- testRunReferenceOutput :: FilePath -> Text -> TestRun -> FilePath
- getExpectedResult :: (MonadFail m, MonadIO m) => FutharkExe -> FilePath -> Text -> TestRun -> m (ExpectedResult [Value])
- compileProgram :: (MonadIO m, MonadError Text m) => [String] -> FutharkExe -> String -> FilePath -> m (ByteString, ByteString)
- readResults :: (MonadIO m, MonadError Text m) => Server -> [VarName] -> m [Value]
- ensureReferenceOutput :: (MonadIO m, MonadError Text m) => Maybe Int -> FutharkExe -> String -> FilePath -> [InputOutputs] -> m ()
- determineTuning :: MonadIO m => Maybe FilePath -> FilePath -> m ([String], String)
- determineCache :: Maybe FilePath -> FilePath -> [String]
- binaryName :: FilePath -> FilePath
- futharkServerCfg :: FilePath -> [String] -> ServerCfg
- data Mismatch
- data Value
- valueText :: Value -> Text

# Documentation

module Futhark.Test.Spec

valuesFromByteString :: String -> ByteString -> Either String [Value] Source #

Try to parse a several values from a byte string. The `String` parameter is used for error messages.

newtype FutharkExe Source #

The `futhark` executable we are using. This is merely a wrapper around the underlying file path, because we will be using a lot of different file paths here, and it is easy to mix them up.

Constructors

FutharkExe FilePath |

#### Instances

Instances details

Show FutharkExe Source # |
Instance details Defined in Futhark.Test Methods showsPrec :: Int -> FutharkExe -> ShowS Source # show :: FutharkExe -> String Source # showList :: [FutharkExe] -> ShowS Source #
Eq FutharkExe Source # |
Instance details Defined in Futhark.Test Methods (==) :: FutharkExe -> FutharkExe -> Bool Source # (/=) :: FutharkExe -> FutharkExe -> Bool Source #
Ord FutharkExe Source # |

Instance details

Defined in Futhark.Test

Methods

compare :: FutharkExe -> FutharkExe -> Ordering Source #

(<) :: FutharkExe -> FutharkExe -> Bool Source #

(<=) :: FutharkExe -> FutharkExe -> Bool Source #

(>) :: FutharkExe -> FutharkExe -> Bool Source #

(>=) :: FutharkExe -> FutharkExe -> Bool Source #

max :: FutharkExe -> FutharkExe -> FutharkExe Source #

min :: FutharkExe -> FutharkExe -> FutharkExe Source #

getValues :: (MonadFail m, MonadIO m) => FutharkExe -> FilePath -> Values -> m [Value] Source #

Get the actual core Futhark values corresponding to a `Values` specification. The first `FilePath` is the path of the `futhark` executable, and the second is the directory which file paths are read relative to.

getValuesBS :: (MonadFail m, MonadIO m) => FutharkExe -> FilePath -> Values -> m ByteString Source #

Extract a text representation of some `Values`. In the IO monad because this might involve reading from a file. There is no guarantee that the resulting byte string yields a readable value.

valuesAsVars :: (MonadError Text m, MonadIO m) => Server -> [(VarName, TypeName)] -> FutharkExe -> FilePath -> Values -> m () Source #

Make the provided `Values` available as server-side variables. This may involve arbitrary server-side computation. Error detection... dubious.

compareValues :: Tolerance -> Value -> Value -> [Mismatch] Source #

Compare two Futhark values for equality.

checkResult :: (MonadError Text m, MonadIO m) => FilePath -> [Value] -> [Value] -> m () Source #

Check that the result is as expected, and write files and throw an error if not.

testRunReferenceOutput :: FilePath -> Text -> TestRun -> FilePath Source #

When/if generating a reference output file for this run, what should it be called? Includes the "data/" folder.

getExpectedResult :: (MonadFail m, MonadIO m) => FutharkExe -> FilePath -> Text -> TestRun -> m (ExpectedResult [Value]) Source #

Get the values corresponding to an expected result, if any.

compileProgram :: (MonadIO m, MonadError Text m) => [String] -> FutharkExe -> String -> FilePath -> m (ByteString, ByteString) Source #

`compileProgram extra_options futhark backend program` compiles `program` with the command `futhark backend extra-options...`, and returns stdout and stderr of the compiler. Throws an IO exception containing stderr if compilation fails.

readResults :: (MonadIO m, MonadError Text m) => Server -> [VarName] -> m [Value] Source #

Read the given variables from a running server.

ensureReferenceOutput :: (MonadIO m, MonadError Text m) => Maybe Int -> FutharkExe -> String -> FilePath -> [InputOutputs] -> m () Source #

Ensure that any reference output files exist, or create them (by compiling the program with the reference compiler and running it on the input) if necessary.

determineTuning :: MonadIO m => Maybe FilePath -> FilePath -> m ([String], String) Source #

Determine the `--tuning` options to pass to the program. The first argument is the extension of the tuning file, or `Nothing` if none should be used.

determineCache :: Maybe FilePath -> FilePath -> [String] Source #

Determine the `--cache-file` options to pass to the program. The first argument is the extension of the cache file, or `Nothing` if none should be used.

binaryName :: FilePath -> FilePath Source #

The name we use for compiled programs.

futharkServerCfg :: FilePath -> [String] -> ServerCfg Source #

Create a Futhark server configuration suitable for use when testing/benchmarking Futhark programs.

data Mismatch Source #

Two values differ in some way. The `Show` instance produces a human-readable explanation.

#### Instances

Instances details

Show Mismatch |
Instance details Defined in Futhark.Data.Compare Methods showsPrec :: Int -> Mismatch -> ShowS Source # show :: Mismatch -> String Source # showList :: [Mismatch] -> ShowS Source #

data Value Source #

An efficiently represented Futhark value, represented as a shape vector and a value vector, which contains elements in row-major order. The size of the value vector must be equal to the product of the shape vector. This is not enforced by the representation, but consuming functions may give unexpected results if this invariant is broken. Scalars are represented with an empty shape vector.

Use `valueText` to get a human-readable representation, and `put` to obtain binary a representation.

The `Eq` instance is the naive one, meaning that no values containing NaNs will be considered equal. Use the functions from Futhark.Data.Compare if this is not what you want.

#### Instances

Instances details

Binary Value |
Instance details Defined in Futhark.Data Methods put :: Value -> Put Source # get :: Get Value Source # putList :: [Value] -> Put Source #
Show Value |
Instance details Defined in Futhark.Data Methods showsPrec :: Int -> Value -> ShowS Source # show :: Value -> String Source # showList :: [Value] -> ShowS Source #
Eq Value |
Instance details Defined in Futhark.Data Methods (==) :: Value -> Value -> Bool Source # (/=) :: Value -> Value -> Bool Source #
Pretty Value Source # |
Instance details Defined in Futhark.Test.Values Methods pretty :: Value -> Doc ann Source # prettyList :: [Value] -> Doc ann Source #
PutValue [Value] |
Instance details Defined in Futhark.Data Methods putValue :: [Value] -> Maybe Value Source #

valueText :: Value -> Text Source #

Construct a textual representation of the value as a strict text.