API

Modules

Types and constants

Functions and macros

Documentation

HeterogeneousComputing.AbstractComputeUnitType
abstract type AbstractComputeUnit

Supertype for arbitrary compute units (CPU, GPU, etc.).

adapt(cunit::AbstractComputeUnit, x) adapts x for cunit.

get_total_memory(cunit) and get_free_memory(cunit) return the total resp. the free memory on the compute unit.

allocate_array(cunit, dims) can be used to allocate new arrays on cunit.

KernelAbstractions.Backend(cunit) will return default KernelAbstractions backend for the type of the compute unit.

See also GenContext.

source
HeterogeneousComputing.ComputeUnitIndependentType
struct ComputeUnitIndependent

get_compute_unit(x) === ComputeUnitIndependent() indicates that x is not tied to a specific compute unit. This typically means that x is a statically allocated object.

source
HeterogeneousComputing.GenContextType
GenContext{T=AbstractFloat}(
    rng::AbstractRNG = Random.default_rng(),
    cunit::AbstractComputeUnit = CPUnit()
)

Context for generative computations.

  • Base.eltype(ctx::GenContext)will returnT`.
source
HeterogeneousComputing.NoRNGType
struct HeterogeneousComputing.NoRNG{T}

Indicates that no specific random number generator associated with an object of type T could be determined.

See get_rng for details.

source
HeterogeneousComputing.allocate_arrayFunction
allocate_array(cpunit::AbstractComputeUnit, ::Type{T}, dims::Dims)
allocate_array(cpunit::AbstractComputeUnit, ::Type{T}, dims::Integer...)

Allocate a new array with element type T and size dims on compute unit cunit.

The content of the newly allocated array is undefined.

source
HeterogeneousComputing.allocate_arrayMethod
allocate_array(ctx::GenContext, dims::Dims)
allocate_array(ctx::GenContext, dims::Integer...)
allocate_array(ctx::GenContext, ::Type{T}, dims::Dims)
allocate_array(ctx::GenContext, ::Type{T}, dims::Integer...)

Allocate a new array on the compute unit and with the numerical element type specified by ctx.

The default element type can be overriden by specifying T.

source
HeterogeneousComputing.get_compute_unit_implFunction
HeterogeneousComputing.get_compute_unit_impl(::Type{TypeHistory}, x)::AbstractComputeUnit

See get_compute_unit_impl.

Specializations that directly resolve the compute unit based on x can ignore TypeHistory:

HeterogeneousComputing.get_compute_unit_impl(@nospecialize(TypeHistory::Type), x::SomeType) = ...
source
HeterogeneousComputing.ka_backendFunction
HeterogeneousComputing.ka_backend(cunit::AbstractComputeUnit)

Returns the KernelAbstractions backend for cunit.

Requires KernelAbstractions.jl to be loaded, otherwise ka_backend will have no methods.

Do not call directly, use for specialization only.

User code should call KernelAbstractions.Backend(cunit) or convert(KernelAbstractions.Backend, cunit) instead, both of which will use ka_backend internally.

source
HeterogeneousComputing.merge_compute_unitsFunction
merge_compute_units(compute_units...)

Merge compute_units unto a common/combined compute unit.

Do not specialize merge_compute_units directly, specialize compute_unit_mergerule(a, b) instead.

source
HeterogeneousComputing.real_numtypeFunction
real_numtype(T::Type)

Return the underlying numerical type of T that's a subtype of Real.

Uses type promotion among underlying Real type in T.

Non numerical types that are commonly used to express default and missing values or named choices/options are treated as Bool.

In contract to get_precision_fromtype, the function real_numtype may also return subtypes of Integer and will preserve types like ForwardDiff.Dual.

Example:


A = fill(fill(rand(Float32, 5), 10), 5)
real_numtype(typeof(A)) == Float32
source