API
Modules
Types and constants
HeterogeneousComputing.AbstractComputeAcceleratorHeterogeneousComputing.AbstractComputeUnitHeterogeneousComputing.AbstractGPUnitHeterogeneousComputing.CPUnitHeterogeneousComputing.ComputeUnitIndependentHeterogeneousComputing.GenContextHeterogeneousComputing.MixedComputeSystemHeterogeneousComputing.NoGenContextHeterogeneousComputing.NoPrecisionHeterogeneousComputing.NoRNGHeterogeneousComputing.UnknownComputeUnitOf
Functions and macros
HeterogeneousComputing.allocate_arrayHeterogeneousComputing.allocate_arrayHeterogeneousComputing.get_compute_unitHeterogeneousComputing.get_compute_unit_implHeterogeneousComputing.get_free_memoryHeterogeneousComputing.get_gencontextHeterogeneousComputing.get_precisionHeterogeneousComputing.get_precision_fromtypeHeterogeneousComputing.get_rngHeterogeneousComputing.get_total_memoryHeterogeneousComputing.ka_backendHeterogeneousComputing.merge_compute_unitsHeterogeneousComputing.real_numtype
Documentation
HeterogeneousComputing.HeterogeneousComputing — ModuleHeterogeneousComputingTools for heterogeneous computing in Julia.
HeterogeneousComputing.AbstractComputeAccelerator — Typeabstract type AbstractComputeAccelerator <: AbstractComputeUnitSupertype for GPU compute units.
HeterogeneousComputing.AbstractComputeUnit — Typeabstract type AbstractComputeUnitSupertype 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.
HeterogeneousComputing.AbstractGPUnit — Typeabstract type AbstractGPUnit <: AbstractComputeAcceleratorSupertype for GPU comute units.
HeterogeneousComputing.CPUnit — Typestruct CPUnit <: AbstractComputeUnitCPUnit() is the default central processing unit (CPU).
HeterogeneousComputing.ComputeUnitIndependent — Typestruct ComputeUnitIndependentget_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.
HeterogeneousComputing.GenContext — TypeGenContext{T=AbstractFloat}(
rng::AbstractRNG = Random.default_rng(),
cunit::AbstractComputeUnit = CPUnit()
)Context for generative computations.
Base.eltype(ctx::GenContext)will returnT`.
HeterogeneousComputing.MixedComputeSystem — Typestruct MixedComputeSystem <: AbstractComputeUnitA (possibly heterogenous) system of multiple compute units.
HeterogeneousComputing.NoGenContext — Typestruct HeterogeneousComputing.NoGenContext{T}Indicates that no generative context could be derived from an object of type T.
See get_gencontext for details.
HeterogeneousComputing.NoPrecision — Typestruct HeterogeneousComputing.NoPrecision{T}Indicates that no specific numerical precision associated with an object of type T could be determined.
HeterogeneousComputing.NoRNG — Typestruct 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.
HeterogeneousComputing.UnknownComputeUnitOf — TypeUnknownComputeUnitOf(x)get_compute_unit(x) === ComputeUnitIndependent() indicates that the compute unit for x cannot be determined.
HeterogeneousComputing.allocate_array — Functionallocate_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.
HeterogeneousComputing.allocate_array — Methodallocate_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.
HeterogeneousComputing.get_compute_unit — Functionget_compute_unit(x)::Union{
AbstractComputeUnit,
ComputeUnitIndependent,
UnknownComputeUnitOf
}Get the compute unit backing object x.
Don't specialize get_compute_unit, specialize HeterogeneousComputing.get_compute_unit_impl instead.
HeterogeneousComputing.get_compute_unit_impl — FunctionHeterogeneousComputing.get_compute_unit_impl(::Type{TypeHistory}, x)::AbstractComputeUnitSpecializations that directly resolve the compute unit based on x can ignore TypeHistory:
HeterogeneousComputing.get_compute_unit_impl(@nospecialize(TypeHistory::Type), x::SomeType) = ...HeterogeneousComputing.get_free_memory — Functiongetfreememory(cunit::AbstractComputeUnit)
Get the amount of free memory available on cunit.
HeterogeneousComputing.get_gencontext — Functionget_gencontext(x::T)Get the generative context associated with x or NoGenContext{T} if no context can be determined for x.
HeterogeneousComputing.get_precision — Functionget_precision(x::T)::Union{
Type{<:AbstractFloat},
Type{<:HeterogeneousComputing.NoPrecision}
}Returns the numerical precision of used by x or NoPrecision{T} if no numerical precision can be determined for x.
In general, do not specialize get_precision, specialize get_precision_fromtype instead.
HeterogeneousComputing.get_precision_fromtype — Functionget_precision_fromtype(::Type{T})Returns the numberical precision accociate with type T or NoPrecision{T} if no numerical precision can be determined for type T.
HeterogeneousComputing.get_rng — Functionget_rng(x::T)Tries to determine the random number generator used by x.
Returns NoRNG{T}() if x doesn't seem to be associated with a specific random number generator.
HeterogeneousComputing.get_total_memory — Functionget_total_memory(cunit::AbstractComputeUnit)Get the total amount of memory available on cunit.
HeterogeneousComputing.ka_backend — FunctionHeterogeneousComputing.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.
HeterogeneousComputing.merge_compute_units — Functionmerge_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.
HeterogeneousComputing.real_numtype — Functionreal_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