-
Notifications
You must be signed in to change notification settings - Fork 0
vectorising
-
Accelerate is split into a frontend, consisting of the
AccandExptypes, and various backends that may executeAccterms. -
Accterms are 'Array-valued collective computations'. -
Expterms are 'Scalar expressions for plain array computations'. -
By construction, no
Expterm may use anAccterm, motivated by the desire of a clear cut between parallel operations and sequential operations. -
Thus, all Accelerate programs may be thought of as an outer parallel execution of identical sequential procedures, i.e. flat data parallelism.
-
Arrays are Repa-style; Regular with shapes.
-
Segmented arrays are only supported via explicit, external segment descriptors in some functions of the language.
-
The
Acc/Expdivision gives rise to dublication of functionality, e.g. anifconstruct for bothExpandAcc.
-
Typically, you just import "Data.Array.Nikola.Backend.CUDA" unqualified.
-
Data.Array.Nikola.Language.Syntaxdefines the basic abstract expression syntax,
(For Data.Array.Nikola.Exp:)
-
Data.Array.Nikola.Expwraps the expression syntax, such that it is compatible with-XRebindableSyntax. It is tagged with a phantom type variable representing the dialect. Thus,Exp CUDA ais only nominally different fromExp t a. Maybe the distinction is motivated by the desire to have different primitive constructs available for different backends. -
In various places of Nikola we find obnoxious instances like this:
instance Eq a => Eq (Exp t a) where _ == _ = error " (==) Exp: incomparable" _ /= _ = error " (/=) Exp: incomparable"
So far these have only caused trouble, and seem rather unmotivated.
-
There is a
Lift/Unlifttypeclass pair with an assoctype Lifted t a :: *They seem to serve the purpose of lifting constants intoExp, and unlifting nested expression types (that presumably occurs some places inherently) i.e.Exp t (Exp t a) -> Exp t a, but through the associated type. -
There is an
IsElemtypeclass, detailing what types may occur as scalars in arrays, and their on-device representation type
(For Data.Array.Nikola.Language.Syntax:)
-
Data.Array.Nikola.Language.Syntaxcontains the unwrapped, untyped AST typeExp. -
It also contains data types on variable occurence in
LetE-expressions, presumably to guide the inliner.
(Compiling to cuda code:)
-
In
Data.Array.Nikola.Backend.CUDA.Haskellwe find thecompilefunction, that can makeas intobs, provided instances of(Compilable a b, Reifiable a Exp). -
The given instances of
Compilableare able to compileExp CUDA ato the correspondingRep a(Associated type fromIsElemtypeclass). There is also some machinery to compile various array types. -
The compilation has roughly three major phases: Reification -> C expression rendering -> Nvcc compilation.
(Misc:)
-
mapin Nikola is implemented via the type classMapinData.Array.Nikola.Operators.Mapping, and the default implementation is through Source and Target array classes.
Vectorising Accelerate would involve either tearing down the Acc/Exp wall,
a very central part of the very structure of the language, or providing an
embedAcc :: Acc a -> Exp a, making collective operations fit in where only
scalar operations were previously permitted.
Either way, the language would have be extended to permit nested arrays, either in addition to or instead of shaped arrays, or possibly a hybrid (as shape is just an indexing-abstraction over a flat array).
Breaking down the Acc/Exp wall would quite possibly be much like rewriting
the entire language.
Providing an embedAcc operation would render the distinction between Exp
and Acc apparently redundant, although the distinction might be used to
provide execution hints, i.e. that (unembedded) Exps be preferred to be
executed in sequence. However, depending on how deeply the Acc/Exp
distinction is reflected in assumptions in code generation, providing
embedAcc might require a substantial rewrite of code generation.