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

Safe Haskell | Safe-Inferred
Language | GHC2021

Futhark.Analysis.Metrics

Contents

- Extensibility

Description

Abstract Syntax Tree metrics. This is used in the `futhark test` program, for the `structure` stanzas.

Synopsis

- newtype AstMetrics = AstMetrics (Map Text Int)
- progMetrics :: OpMetrics (Op rep) => Prog rep -> AstMetrics
- class OpMetrics op where
  - opMetrics :: op -> MetricsM ()
- seen :: Text -> MetricsM ()
- inside :: Text -> MetricsM () -> MetricsM ()
- data MetricsM a
- stmMetrics :: OpMetrics (Op rep) => Stm rep -> MetricsM ()
- lambdaMetrics :: OpMetrics (Op rep) => Lambda rep -> MetricsM ()
- bodyMetrics :: OpMetrics (Op rep) => Body rep -> MetricsM ()

# Documentation

newtype AstMetrics Source #

AST metrics are simply a collection from identifiable node names to the number of times that node appears.

Constructors

AstMetrics (Map Text Int) |

#### Instances

Instances details

Read AstMetrics Source # |
Instance details Defined in Futhark.Analysis.Metrics.Type Methods readsPrec :: Int -> ReadS AstMetrics Source # readList :: ReadS [AstMetrics] Source # readPrec :: ReadPrec AstMetrics Source # readListPrec :: ReadPrec [AstMetrics] Source #
Show AstMetrics Source # |
Instance details Defined in Futhark.Analysis.Metrics.Type Methods showsPrec :: Int -> AstMetrics -> ShowS Source # show :: AstMetrics -> String Source # showList :: [AstMetrics] -> ShowS Source #

progMetrics :: OpMetrics (Op rep) => Prog rep -> AstMetrics Source #

Compute the metrics for a program.

# Extensibility

class OpMetrics op where Source #

Compute the metrics for some operation.

Methods

opMetrics :: op -> MetricsM () Source #

#### Instances

Instances details

OpMetrics SizeOp Source # |
Instance details Defined in Futhark.IR.GPU.Op Methods opMetrics :: SizeOp -> MetricsM () Source #
OpMetrics (Op rep) => OpMetrics (SOAC rep) Source # |
Instance details Defined in Futhark.IR.SOACS.SOAC Methods opMetrics :: SOAC rep -> MetricsM () Source #
OpMetrics a => OpMetrics (Maybe a) Source # |
Instance details Defined in Futhark.Analysis.Metrics Methods opMetrics :: Maybe a -> MetricsM () Source #
(OpMetrics (Op rep), OpMetrics (op rep)) => OpMetrics (HostOp op rep) Source # |
Instance details Defined in Futhark.IR.GPU.Op Methods opMetrics :: HostOp op rep -> MetricsM () Source #
(OpMetrics (Op rep), OpMetrics (op rep)) => OpMetrics (MCOp op rep) Source # |
Instance details Defined in Futhark.IR.MC.Op Methods opMetrics :: MCOp op rep -> MetricsM () Source #
OpMetrics (inner rep) => OpMetrics (MemOp inner rep) Source # |
Instance details Defined in Futhark.IR.Mem Methods opMetrics :: MemOp inner rep -> MetricsM () Source #
OpMetrics (NoOp rep) Source # |
Instance details Defined in Futhark.Analysis.Metrics Methods opMetrics :: NoOp rep -> MetricsM () Source #
OpMetrics (Op rep) => OpMetrics (SegOp lvl rep) Source # |
Instance details Defined in Futhark.IR.SegOp Methods opMetrics :: SegOp lvl rep -> MetricsM () Source #

seen :: Text -> MetricsM () Source #

Add this node to the current tally.

inside :: Text -> MetricsM () -> MetricsM () Source #

Enclose a metrics counting operation. Most importantly, this prefixes the name of the context to all the metrics computed in the enclosed operation.

data MetricsM a Source #

This monad is used for computing metrics. It internally keeps track of what we've seen so far. Use `seen` to add more stuff.

#### Instances

Instances details

Applicative MetricsM Source # |
Instance details Defined in Futhark.Analysis.Metrics Methods pure :: a -> MetricsM a Source # (<*>) :: MetricsM (a -> b) -> MetricsM a -> MetricsM b Source # liftA2 :: (a -> b -> c) -> MetricsM a -> MetricsM b -> MetricsM c Source # (*>) :: MetricsM a -> MetricsM b -> MetricsM b Source # (<*) :: MetricsM a -> MetricsM b -> MetricsM a Source #
Functor MetricsM Source # |
Instance details Defined in Futhark.Analysis.Metrics Methods fmap :: (a -> b) -> MetricsM a -> MetricsM b Source # (<$) :: a -> MetricsM b -> MetricsM a Source #
Monad MetricsM Source # |
Instance details Defined in Futhark.Analysis.Metrics Methods (>>=) :: MetricsM a -> (a -> MetricsM b) -> MetricsM b Source # (>>) :: MetricsM a -> MetricsM b -> MetricsM b Source # return :: a -> MetricsM a Source #

stmMetrics :: OpMetrics (Op rep) => Stm rep -> MetricsM () Source #

Compute metrics for this statement.

lambdaMetrics :: OpMetrics (Op rep) => Lambda rep -> MetricsM () Source #

Compute metrics for this lambda.

bodyMetrics :: OpMetrics (Op rep) => Body rep -> MetricsM () Source #

Compute metrics for this body.