Copyright | [2009..2020] The Accelerate Team |
---|---|
License | BSD3 |
Maintainer | Trevor L. McDonell <trevor.mcdonell@gmail.com> |
Stability | experimental |
Portability | non-portable (GHC extensions) |
Safe Haskell | None |
Language | Haskell2010 |
Operations which may be unsafe. Use with care.
Since: 1.2.0.0
Unsafe operations
mkCoerce'
Instances
Coerce a a Source # | |
Defined in Data.Array.Accelerate.Smart mkCoerce' :: SmartExp a -> SmartExp a | |
(IsScalar a, IsScalar b, BitSizeEq a b) => Coerce a b Source # | |
Defined in Data.Array.Accelerate.Smart mkCoerce' :: SmartExp a -> SmartExp b | |
Coerce a (a, ()) Source # | |
Defined in Data.Array.Accelerate.Smart mkCoerce' :: SmartExp a -> SmartExp (a, ()) | |
Coerce a ((), a) Source # | |
Defined in Data.Array.Accelerate.Smart mkCoerce' :: SmartExp a -> SmartExp ((), a) | |
Coerce ((), a) a Source # | |
Defined in Data.Array.Accelerate.Smart mkCoerce' :: SmartExp ((), a) -> SmartExp a | |
Coerce (a, ()) a Source # | |
Defined in Data.Array.Accelerate.Smart mkCoerce' :: SmartExp (a, ()) -> SmartExp a | |
(Coerce a1 b1, Coerce a2 b2) => Coerce (a1, a2) (b1, b2) Source # | |
Defined in Data.Array.Accelerate.Smart mkCoerce' :: SmartExp (a1, a2) -> SmartExp (b1, b2) |
coerce :: Coerce (EltR a) (EltR b) => Exp a -> Exp b Source #
The function coerce
allows you to convert a value between any two types
whose underlying representations have the same bit size at each component.
For example:
coerce (x :: Exp Double) :: Exp Word64 coerce (x :: Exp (Int64,Float)) :: Exp (Complex Float, Word32)
Furthermore, as we typically declare newtype wrappers similarly to:
type instance EltR (Sum a) = ((), EltR a)
This can be used instead of the newtype constructor, to go from the newtype's
abstract type to the concrete type by dropping the extra ()
from the
representation, and vice-versa.
The type class PreSmartExp
assures that there is a coercion between the two
types.
Since: 1.2.0.0
undef :: forall e. Elt e => Exp e Source #
undef
can be used anywhere a constant is expected, and indicates that the
consumer of the value can receive an unspecified bit pattern.
This is useful because a store of an undefined value can be assumed to not have any effect; we can assume that the value is overwritten with bits that happen to match what was already there. However, a store to an undefined location could clobber arbitrary memory, therefore, its use in such a context would introduce undefined behaviour.
There are (at least) two cases where you may want to use this:
- The
permute
function requires an array of default values, into which the new values are combined. However, if you are sure the default values are not used, and will (eventually) be completely overwritten, thenfill
ing an array with this value will give you a new uninitialised array. - In the definition of sum data types. See for example Data.Array.Accelerate.Data.Maybe and Data.Array.Accelerate.Data.Either.
Since: 1.2.0.0