accelerate-1.3.0.0: An embedded language for accelerated array processing
Copyright[2009..2020] The Accelerate Team
LicenseBSD3
MaintainerTrevor L. McDonell <trevor.mcdonell@gmail.com>
Stabilityexperimental
Portabilitynon-portable (GHC extensions)
Safe HaskellNone
LanguageHaskell2010

Data.Array.Accelerate.Unsafe

Description

Operations which may be unsafe. Use with care.

Since: 1.2.0.0

Synopsis

Unsafe operations

class Coerce a b Source #

Minimal complete definition

mkCoerce'

Instances

Instances details
Coerce a a Source # 
Instance details

Defined in Data.Array.Accelerate.Smart

Methods

mkCoerce' :: SmartExp a -> SmartExp a

(IsScalar a, IsScalar b, BitSizeEq a b) => Coerce a b Source # 
Instance details

Defined in Data.Array.Accelerate.Smart

Methods

mkCoerce' :: SmartExp a -> SmartExp b

Coerce a (a, ()) Source # 
Instance details

Defined in Data.Array.Accelerate.Smart

Methods

mkCoerce' :: SmartExp a -> SmartExp (a, ())

Coerce a ((), a) Source # 
Instance details

Defined in Data.Array.Accelerate.Smart

Methods

mkCoerce' :: SmartExp a -> SmartExp ((), a)

Coerce ((), a) a Source # 
Instance details

Defined in Data.Array.Accelerate.Smart

Methods

mkCoerce' :: SmartExp ((), a) -> SmartExp a

Coerce (a, ()) a Source # 
Instance details

Defined in Data.Array.Accelerate.Smart

Methods

mkCoerce' :: SmartExp (a, ()) -> SmartExp a

(Coerce a1 b1, Coerce a2 b2) => Coerce (a1, a2) (b1, b2) Source # 
Instance details

Defined in Data.Array.Accelerate.Smart

Methods

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 Coerce 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:

  1. 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, then filling an array with this value will give you a new uninitialised array.
  2. 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