Architectures API
Use array_adapter(arch) for backend adaptation and KernelAbstractions.get_backend(array) for kernel execution. A grid stores its execution architecture in grid.arch.
host_array keeps an Array and copies other storage, including CPU views. similar_arrays allocates nested tuple storage in order and accepts an explicit allocator for world-age boundaries. zeros_like, fill_zero! and scale_arrays! preserve one fill or broadcast per array. These helpers do not change the batched launch policy of copy_arrays!.
The declared shared _neumaier_sum(f, ks, T) helper returns (sum, compensation); add the pair to obtain the total. It evaluates terms in the order of ks in precision T. Convection and non-core Analysis import it explicitly; src/README.md declares sharing without adding an export.
AtmosTransport.Architectures Module
ArchitecturesExecution architectures and their optional runtime integration.
An architecture is part of a grid's type-level model contract: CPU() selects host execution, while GPU(:cuda), GPU(:rocm), and GPU(:metal) select a concrete GPU runtime. The same object controls array adaptation, device synchronization, and runtime validation, so grid metadata cannot diverge from model storage.
AtmosTransport.Architectures.AbstractArchitectureRequest Type
abstract type AbstractArchitectureRequestA parsed request for an execution architecture. Configuration strings become one of the concrete request types at the configuration boundary; runtime selection then dispatches on the request instead of retaining a string or Symbol selector.
AtmosTransport.Architectures.AbstractPointOp Type
AbstractPointOpA unit of work applied independently at every index of its index space. A concrete operation is a small isbits struct of integers and flags; the arrays it reads and writes travel in a shared context ctx (usually a NamedTuple). It defines two methods:
index_space(op, ctx) -> NTuple{N, Int}
apply_point!(op, ctx, I::Vararg{Int, N}) # @inline; one index, no return valuelaunch!(op, ctx, backend) runs it as one kernel on a device and as a loop over the same body on the host, where bound_context(op, ctx) may first resolve loop-invariant lookups (an operation with much work per index can run the kernel on the host instead, see host_parallel). Operations compose by type:
Fused(ops...): independent operations in one launch. A trailing slot index selects the operation; indices outside an operation's own space are skipped. The operations run concurrently on a device and one after the other on the host, so they must write pairwise-disjoint cells, and no operation may read a cell that another one writes.Sequence(ops...): dependent operations, launched in order (stream order on a device) with one synchronization at the end.
Fusing changes only the launch structure. For operations that satisfy the Fused contract, every index runs the same arithmetic on the same inputs, so results equal those of separate launches bit for bit.
AtmosTransport.Architectures.AutoGPURequest Type
Request automatic detection of a supported GPU runtime.
sourceAtmosTransport.Architectures.CPU Type
struct CPU <: AtmosTransport.Architectures.AbstractArchitectureHost CPU execution architecture.
sourceAtmosTransport.Architectures.DiscreteHostMemory Type
Device memory reached from the host only through copies (CUDA, ROCm).
sourceAtmosTransport.Architectures.Fused Type
Fused(ops::AbstractPointOp...)
Fused(ops::Tuple)Independent point operations of equal index rank in one launch, over the elementwise-largest index space plus a trailing slot index. At least one operation is required.
On a device the operations run concurrently; on the host they run one after the other. The operations must therefore write pairwise-disjoint cells, and no operation may read a cell that another fused operation writes. Under this contract both paths give the results of separate launches bit for bit.
sourceAtmosTransport.Architectures.FusionPolicy Type
FusionPolicyHow a backend launches a Fused set of point operations, chosen by fusion_policy(backend): FuseLaunches() (the default) runs them as one kernel; SeparateLaunches() launches each operation over its own index space on its bound_context (operations that define one, such as the halo fills, then see their arrays directly), one after another, with one synchronization at the end. Results are the same either way (fused operations write disjoint cells and read none that another writes); which is faster depends on the backend.
AtmosTransport.Architectures.GPU Type
struct GPU{B} <: AtmosTransport.Architectures.AbstractArchitectureGPU execution architecture for backend B.
Construct with GPU(:cuda), GPU(:rocm), or GPU(:metal). The explicit backend keeps methods unambiguous when multiple optional packages are loaded.
AtmosTransport.Architectures.HostMemoryModel Type
HostMemoryModelWhether host code can read and write a backend's device buffers directly, chosen by host_memory_model: DiscreteHostMemory() (the default: device memory is reached only through copies, as on CUDA and ROCm) or UnifiedHostMemory() (one memory that host and device share, as Metal's shared-storage buffers on Apple silicon; see host_mapped_vector).
AtmosTransport.Architectures.LinearCopy Type
LinearCopy <: AbstractPointOpAt linear index i, ctx.dest[k][i] = ctx.src[k][i] for every array pair k of the tuples ctx.dest and ctx.src that has an element i: a set of copies as one launch over the longest array. The host runs the pairs as copyto!s. See copy_arrays!.
AtmosTransport.Architectures.Sequence Type
Sequence(ops::AbstractPointOp...)Point operations where later ones read what earlier ones wrote: launched in order, with one synchronization after the last.
sourceAtmosTransport.Architectures.UnifiedHostMemory Type
One memory shared by host and device (Metal on Apple silicon).
sourceAtmosTransport.Architectures.apply_point! Function
apply_point!(op, ctx, I...)The work of op at one index; methods should be @inline.
AtmosTransport.Architectures.architecture_from_config Method
architecture_from_config(config) -> AbstractArchitectureResolve an [architecture] configuration table to one concrete execution architecture. An omitted backend selects CPU() unless use_gpu = true, in which case a usable GPU runtime is detected.
AtmosTransport.Architectures.assert_residency! Method
assert_residency!(storage, architecture; label="storage")Verify that an array or tuple of arrays is resident on architecture. CPU storage is returned directly; a GPU mismatch aborts rather than falling back silently to host execution.
AtmosTransport.Architectures.autodetect_gpu_architecture Method
autodetect_gpu_architecture() -> GPUReturn the first functional supported GPU architecture on this host.
sourceAtmosTransport.Architectures.compensated_total Method
compensated_total(values) -> Float64Compensated Float64 total of a host or device array, or of a tuple of arrays (cubed-sphere panels). CPU and CUDA arrays are summed in place.
sourceAtmosTransport.Architectures.copy_arrays! Method
copy_arrays!(dest::Tuple, src::Tuple) -> destcopyto!(dest[k], src[k]) for every pair of equally sized arrays. When every array of dest and src lives on one backend (single_launch_copy), all pairs are copied by one LinearCopy launch, queued on the current task's device queue without a host synchronization; the host backend copies each pair with copyto!. A batch that mixes backends (a host window uploaded to the device, or arrays on different devices) keeps one copyto! per pair.
The single launch applies to every device backend (CUDA, ROCm and Metal), not only to Metal: it replaces a batch of copies by one launch, and copies values unchanged, so the result equals that of the copyto!s bit for bit. On CUDA and ROCm a device-to-device copyto! is already queued asynchronously, so the gain there is fewer launches. On Metal it also removes host synchronizations: Metal.jl synchronizes the queue before every device-to-device copyto! and waits for its blit, so the 18 panel copies of a cubed-sphere flux refresh cost about 2.5 ms per step on an M5 Pro.
AtmosTransport.Architectures.fill_zero! Method
Fill arrays with element-type zero, in tuple order; accept nothing for absent storage.
AtmosTransport.Architectures.fusion_policy Method
fusion_policy(backend) -> FusionPolicyFuseLaunches() unless a backend extension says otherwise (Metal launches separately: measured on an M5 Pro, a C90 packed-tracer halo exchange takes 1.1–1.3 ms with separate launches of bound arrays and 1.7–2.0 ms fused, while on CUDA the fused launch is 3–9× faster).
AtmosTransport.Architectures.host_array Method
Return an Array unchanged; copy other array storage (including CPU views) to an Array.
sourceAtmosTransport.Architectures.host_mapped_vector Method
host_mapped_vector(T, n, reference_array) -> (host::Vector{T}, device)A device vector of n elements of type T on the backend of reference_array whose memory host code reads and writes through host, an Array aliasing the same bytes (no copies in either direction). Defined for backends with UnifiedHostMemory only. Host writes are seen by device work queued afterwards; device writes by the host after a synchronization (synchronize_storage!), which must also separate device reads from later host writes. host does not keep device alive: hold on to device as long as host is used.
AtmosTransport.Architectures.host_memory_model Method
host_memory_model(reference_array) -> HostMemoryModelThe HostMemoryModel of the backend that holds reference_array (or the first panel of a tuple): UnifiedHostMemory() where a backend extension declares it (Metal), DiscreteHostMemory() otherwise. Callers dispatch on it to stage host data without a copy where the memory is shared.
AtmosTransport.Architectures.host_parallel Method
host_parallel(op) -> BoolHow launch! runs op on the host (KernelAbstractions' CPU backend): false (the default) runs plain loops in one thread, the fastest choice for light operations such as halo fills; an operation with much work per index (a column walk) returns true to run the device kernel, which the CPU backend spreads over the Julia threads. A Fused set runs as one kernel if any of its operations does; under the Fused contract both paths give the same results.
AtmosTransport.Architectures.index_space Function
index_space(op, ctx) -> NTuple{N, Int}Extent of the indices at which apply_point!(op, ctx, I...) runs.
AtmosTransport.Architectures.launch! Method
launch!(op::AbstractPointOp, ctx, backend; workgroup = 256, sync = true)Run op at every index of index_space(op, ctx): one kernel launch on a device backend (then synchronize unless sync = false), and a loop calling the same apply_point! on the host backend.
AtmosTransport.Architectures.launch! Method
launch!(kernel, backend, workgroup, ndrange, args...; sync = true)Run the KernelAbstractions kernel (a @kernel function) on backend with workgroup over ndrange, then synchronize(backend) unless sync = false (several launches on one backend can share one synchronization). Kernel launches are being moved onto this helper module by module, so that workgroup choices and synchronization are explicit at each call site; the cubed-sphere advection sweeps keep their own profiled launch, which skips the host synchronization on GPU.
AtmosTransport.Architectures.reclaim_backend_pool! Method
reclaim_backend_pool!(reference_array)Release device allocator caches associated with reference_array after startup transients become unreachable. CPU arrays are a no-op.
AtmosTransport.Architectures.scale_arrays! Method
Scale each array in order, retaining one broadcast per array.
sourceAtmosTransport.Architectures.similar_arrays Method
similar_arrays(reference; allocator=similar)Allocate arrays like reference, visiting nested tuples in order. Pass allocator = a -> Base.invokelatest(similar, a) at world-age boundaries.
AtmosTransport.Architectures.zeros_like Method
Allocate zeroed storage like an array or nested tuple, in the same order; optional arguments go to similar.