abla/kernel
Generated from source.
Import with import "abla/kernel".
Source: abla/kernel/entry.ab
KernelF32Buffer (class)
@__abla_trusted_only("error: take one from CudaKernelMemory.floats(), or build it in a trusted function that owns the memory and keeps it alive")
class KernelF32Buffer(val address: int, val count: int)
A buffer of count f32 values at address (host memory on the CPU, device memory on a GPU), as a kernel sees it.
KernelU32Buffer (class)
@__abla_trusted_only("error: take one from CudaKernelMemory.words(), or build it in a trusted function that owns the memory and keeps it alive")
class KernelU32Buffer(val address: int, val count: int)
A buffer of count u32 values at address, as a kernel sees it; its elements read as ints from 0 to 2^32 - 1.
KernelF32Buffer.size (extension fun)
fun KernelF32Buffer.size(): int
The number of elements of the buffer (0 for an empty one, which a kernel can take for "none").
KernelU32Buffer.size (extension fun)
fun KernelU32Buffer.size(): int
The number of elements of the buffer.
KernelF32Buffer.load (extension fun)
trusted fun KernelF32Buffer.load(index: int): f32
Element index of the buffer, or 0 when index is outside it.
KernelF32Buffer.store (extension fun)
trusted fun KernelF32Buffer.store(index: int, value: f32): void
Stores value as element index; does nothing when index is outside the buffer.
KernelU32Buffer.load (extension fun)
trusted fun KernelU32Buffer.load(index: int): int
Element index of the buffer (0 to 2^32 - 1), or 0 when index is outside it.
KernelU32Buffer.store (extension fun)
trusted fun KernelU32Buffer.store(index: int, value: int): void
Stores the low 32 bits of value as element index; does nothing when index is outside the buffer.
KernelU16Buffer (class)
@__abla_trusted_only("error: take one from CudaKernelMemory.halves(), or build it in a trusted function that owns the memory and keeps it alive")
class KernelU16Buffer(val address: int, val count: int)
A buffer of count u16 values at address, as a kernel sees it (GGML Q8_0 blocks are 17 of them: an f16 scale and 32 bytes); its elements read as ints from 0 to 65535.
KernelU16Buffer.size (extension fun)
fun KernelU16Buffer.size(): int
The number of elements of the buffer.
KernelU16Buffer.load (extension fun)
trusted fun KernelU16Buffer.load(index: int): int
Element index of the buffer (0 to 65535), or 0 when index is outside it.
KernelU16Buffer.store (extension fun)
trusted fun KernelU16Buffer.store(index: int, value: int): void
Stores the low 16 bits of value as element index; does nothing when index is outside the buffer.
KernelU8Buffer (class)
@__abla_trusted_only("error: take one from CudaKernelMemory.raw(), or build it in a trusted function that owns the memory and keeps it alive")
class KernelU8Buffer(val address: int, val count: int)
A buffer of count bytes at address, as a kernel sees it: packed data at any alignment (GGML blocks of 34 or 36 bytes), read a byte, two or four at a time.
KernelU8Buffer.size (extension fun)
fun KernelU8Buffer.size(): int
The number of bytes of the buffer.
KernelU8Buffer.load (extension fun)
trusted fun KernelU8Buffer.load(index: int): int
Byte index (0 to 255), or 0 when index is outside the buffer.
KernelU8Buffer.store (extension fun)
trusted fun KernelU8Buffer.store(index: int, value: int): void
Stores the low 8 bits of value as byte index; does nothing when index is outside the buffer.
KernelU8Buffer.loadU16 (extension fun)
fun KernelU8Buffer.loadU16(index: int): int
The little-endian u16 at bytes index and index + 1, at any alignment (bytes outside the buffer count 0). On a GPU an even address is one 16-bit load.
KernelU8Buffer.loadU32 (extension fun)
fun KernelU8Buffer.loadU32(index: int): int
The little-endian u32 at bytes index to index + 3, at any alignment (bytes outside the buffer count 0). On a GPU a 4-byte-aligned address is one 32-bit load and an even one two 16-bit loads.
KernelF32Buffer.load4 (extension fun)
fun KernelF32Buffer.load4(index: int): f32x4
Elements index to index + 3 as one vector, each 0 when outside the buffer. On a GPU, four elements inside the buffer at a 16-byte-aligned address are one 16-byte load (CUDA's float4); anywhere else, four loads.
KernelF32Buffer.isAligned (extension fun)
fun KernelF32Buffer.isAligned(index: int, bytes: int): bool
Whether element index's address is a multiple of bytes (a power of two), so a kernel can pick its aligned fast path once (a buffer may start anywhere: an offset into device memory). Reads no memory.
KernelU32Buffer.isAligned (extension fun)
fun KernelU32Buffer.isAligned(index: int, bytes: int): bool
Whether element index's address is a multiple of bytes (see KernelF32Buffer.isAligned).
KernelU16Buffer.isAligned (extension fun)
fun KernelU16Buffer.isAligned(index: int, bytes: int): bool
Whether element index's address is a multiple of bytes (see KernelF32Buffer.isAligned).
KernelU8Buffer.isAligned (extension fun)
fun KernelU8Buffer.isAligned(index: int, bytes: int): bool
Whether byte index's address is a multiple of bytes (see KernelF32Buffer.isAligned).
KernelF32Buffer.loadUnchecked (extension fun)
@__abla_trusted_only("error: use load(index), which checks the index; loadUnchecked is for trusted kernels that show it is inside")
trusted fun KernelF32Buffer.loadUnchecked(index: int): f32
Element index, which the caller guarantees is inside the buffer (see the unchecked fast path above).
KernelU32Buffer.loadUnchecked (extension fun)
@__abla_trusted_only("error: use load(index), which checks the index; loadUnchecked is for trusted kernels that show it is inside")
trusted fun KernelU32Buffer.loadUnchecked(index: int): int
Element index (0 to 2^32 - 1), which the caller guarantees is inside the buffer (see the unchecked fast path).
KernelU16Buffer.loadUnchecked (extension fun)
@__abla_trusted_only("error: use load(index), which checks the index; loadUnchecked is for trusted kernels that show it is inside")
trusted fun KernelU16Buffer.loadUnchecked(index: int): int
Element index (0 to 65535), which the caller guarantees is inside the buffer (see the unchecked fast path).
KernelU8Buffer.loadUnchecked (extension fun)
@__abla_trusted_only("error: use load(index), which checks the index; loadUnchecked is for trusted kernels that show it is inside")
trusted fun KernelU8Buffer.loadUnchecked(index: int): int
Byte index (0 to 255), which the caller guarantees is inside the buffer (see the unchecked fast path).
KernelF32Buffer.load4Aligned (extension fun)
@__abla_trusted_only("error: use load4(index), which checks the index and the alignment; load4Aligned is for trusted kernels that show both")
trusted fun KernelF32Buffer.load4Aligned(index: int): f32x4
Elements index to index + 3 as one 16-byte load, which the caller guarantees are inside the buffer at a 16-byte- aligned address (see the unchecked fast path; a misaligned address faults the launch on a GPU).
KernelU8Buffer.loadU16Aligned (extension fun)
@__abla_trusted_only("error: use loadU16(index), which checks the index and the alignment; loadU16Aligned is for trusted kernels that show both")
trusted fun KernelU8Buffer.loadU16Aligned(index: int): int
The little-endian u16 at byte index, one 2-byte load: the caller guarantees both bytes are inside the buffer at an even address (see the unchecked fast path).
KernelU8Buffer.loadU32Aligned (extension fun)
@__abla_trusted_only("error: use loadU32(index), which checks the index and the alignment; loadU32Aligned is for trusted kernels that show both")
trusted fun KernelU8Buffer.loadU32Aligned(index: int): int
The little-endian u32 at byte index, one 4-byte load: the caller guarantees the four bytes are inside the buffer at a 4-byte-aligned address (see the unchecked fast path).
kernelGlobalId (fun)
fun kernelGlobalId(): int
The thread's index in the whole launch: group * group size + local index.
kernelLocalId (fun)
fun kernelLocalId(): int
The thread's index in its group (workgroup, CUDA block).
kernelGroupId (fun)
fun kernelGroupId(): int
The group's index in the launch (along x, the dimension the other ids count in).
kernelGroupIdY (fun)
fun kernelGroupIdY(): int
The group's index along y in a two-dimensional launch (kernelRunCpuGrid; CUDA's blockIdx.y); 0 in a one-dimensional one.
kernelGroupSize (fun)
fun kernelGroupSize(): int
The number of threads in a group.
kernelSubgroupLane (fun)
fun kernelSubgroupLane(): int
The thread's lane in its subgroup (CUDA warp). On the CPU a subgroup is one thread: 0.
kernelSubgroupSize (fun)
fun kernelSubgroupSize(): int
The number of threads in a subgroup: 32 on CUDA, 1 on the CPU. A kernel written for any size runs on every backend.
kernelSubgroupSum (fun)
fun kernelSubgroupSum(value: f32): f32
The sum of value over the thread's subgroup, in every lane. Every lane of the subgroup must call it together. On the CPU, value itself.
kernelSharedF32 (fun)
trusted fun kernelSharedF32(count: int): KernelF32Buffer
The workgroup's shared memory for count f32 values: every thread of a group gets the same memory, which a GPU keeps on the chip (CUDA __shared__). Each call in a kernel is its own array, and count must be a compile-time constant (a literal, or a value the compiler folds to one). Its contents start undefined; share them across threads with kernelBarrier.
kernelSharedU32 (fun)
trusted fun kernelSharedU32(count: int): KernelU32Buffer
The workgroup's shared memory for count u32 values (see kernelSharedF32).
KERNEL_SHARED_MAX_ELEMENTS (val)
val KERNEL_SHARED_MAX_ELEMENTS
The most elements a kernelShared call takes on the CPU backend (4 MiB of 4-byte elements, far above a GPU's 48 KiB per group).
KernelU32Buffer.atomicAdd (extension fun)
fun KernelU32Buffer.atomicAdd(index: int, value: int): int
Adds the low 32 bits of value to element index as one indivisible step, so threads of every group may add to the same element, and gives the element as it was before (0, adding nothing, when index is outside the buffer). It orders no other memory access: to hand results between groups, write them, kernelFence(), then add (CUDA's atomicAdd and __threadfence). The CPU backend runs one thread at a time, so there it is a plain read and write.
kernelSubgroupShuffleXor (fun)
fun kernelSubgroupShuffleXor(value: f32, distance: int): f32
value from the lane whose index is this lane's xor distance (CUDA's __shfl_xor_sync over the whole subgroup), or this lane's own value when that lane is outside the subgroup; every lane must call it together. A butterfly of these (distances 16, 8, ..., 1) combines a value across the subgroup in any way a kernel needs, a (score, index) maximum with ties, say. On the CPU, where a subgroup is one thread, value.
kernelSubgroupShuffleXorInt (fun)
fun kernelSubgroupShuffleXorInt(value: int, distance: int): int
kernelSubgroupShuffleXor for an int (all 64 bits move).
kernelFence (fun)
fun kernelFence(): void
Makes this thread's device-memory writes before it visible to every group before any of its writes after it (CUDA __threadfence). Nothing on the CPU backend, which runs one thread at a time.
kernelBarrier (fun)
fun kernelBarrier(): void
Waits until every thread of the group has reached it, and makes their writes to shared and device memory visible to each other (CUDA __syncthreads). Every thread of the group must reach the same barriers. The CPU backend runs a group's threads one after another, so there a barrier holds only for groups of one thread: it does nothing then, and stops the program in a larger group. A kernel that strides by kernelGroupSize() runs on both.
kernelSubgroupMax (fun)
fun kernelSubgroupMax(value: f32): f32
The largest value over the thread's subgroup, in every lane (every lane must call it together). On the CPU, value.
kernelSqrt (fun)
fun kernelSqrt(value: f32): f32
The square root of value (correctly rounded on every backend: through f64 on the CPU).
kernelRsqrt (fun)
fun kernelRsqrt(value: f32): f32
An approximation of 1 / sqrt(value): on CUDA the GPU's rsqrt.approx.f32 (CUDA C's rsqrtf, within 2 ulp), on the CPU the correctly rounded 1 / sqrt through f64. Use kernelSqrt where every backend must give the same bits.
kernelExp (fun)
fun kernelExp(value: f32): f32
e to the power value: on CUDA exactly what CUDA C's expf computes without fast-math (libdevice's __nv_expf, within 2 ulp: 0 below about -104, infinity above about 88.7), on the CPU abla/math's f64 exp rounded to f32.
kernelF16ToF32 (fun)
fun kernelF16ToF32(bits: int): f32
The f32 value of the IEEE binary16 bits in the low 16 bits of bits (exact: every f16 is an f32).
kernelFma (fun)
fun kernelFma(x: f32, y: f32, z: f32): f32
x * y + z: one rounding on a GPU; on the CPU the product is exact in f64 and the sum is rounded twice (to f64, then f32).
kernelRunCpu (fun)
fun kernelRunCpu(groups: int, groupSize: int, body: () -> void): void
Runs body once per thread of groups groups of groupSize threads, in order, on this thread: the CPU backend. The kernel's ids answer the thread being run.
kernelRunCpuGrid (fun)
fun kernelRunCpuGrid(groups: int, groupsY: int, groupSize: int, body: () -> void): void
Runs body once per thread of a grid of groups x groupsY groups of groupSize threads, in order, on this thread.
kernelPtx (extern)
noescape extern:"intrinsic" fun kernelPtx(): string
The PTX of every @kernel function of the program, one entry per kernel under its name, for the CUDA driver (cuModuleLoadData): made by the compiler at build time; "" when the program has no kernel.
Built from Abla v0.2.79 source ba5d6b7d. Examples and generated signatures follow that source revision.