Logo

Parallel algorithm building blocks for the Julia ecosystem, targeting multithreaded CPUs, and GPUs via Nvidia CUDA, AMD ROCm, Intel oneAPI, Apple Metal and OpenCL (and any future backends added to the JuliaGPU organisation), from one KernelAbstractions.jl codebase.

AcceleratedKernels.jl is a library of parallel primitives in the style of CUB: sorting, reductions, prefix scans, stream compaction (findall), binary searches, any/all, map, reverse and general loops. The functions take Base's names and arguments but follow a contract of their own, modelled on CUB's (see Differences from Base). The sorts, reductions, scans, findall and any/all take an explicit algorithm with its settings, and a reusable workspace for their scratch memory. AcceleratedKernels does not try to reproduce Base: packages such as GPUArrays.jl build Base's functions on top of it, and code that needs control over the algorithm or its memory calls it directly.


What's Different?

As far as I am aware, this is the first cross-architecture parallel standard library from a unified codebase - that is, the code is written as KernelAbstractions.jl backend-agnostic kernels, which are then transpiled to a GPU backend; that means we benefit from all the optimisations available on the native platform and official compiler stacks. For example, unlike open standards like OpenCL that require GPU vendors to implement that API for their hardware, we target the existing official compilers. And while performance-portability libraries like Kokkos and RAJA are powerful for large C++ codebases, they require US National Lab-level development and maintenance efforts to effectively forward calls from a single API to other OpenMP, CUDA Thrust, ROCm rocThrust, oneAPI DPC++ libraries developed separately.

As a simple example, this is how a normal Julia for-loop can be converted to an accelerated kernel - for both multithreaded CPUs and Nvidia / AMD / Intel / Apple GPUs, with native performance - by changing a single line:

<table> <tr> <td> CPU Code </td> <td> Multithreaded / GPU code </td> <tr>

<tr> <td>

# Copy kernel testing throughputfunction cpu_copy&#33;&#40;dst, src&#41;    for i in eachindex&#40;src&#41;        dst&#91;i&#93; &#61; src&#91;i&#93;    endend

</td> <td>

import AcceleratedKernels as AKfunction ak_copy&#33;&#40;dst, src&#41;    AK.foreachindex&#40;src&#41; do i        dst&#91;i&#93; &#61; src&#91;i&#93;    endend

</td> </tr> </table>

Again, this is only possible because of the unique Julia compilation model, the JuliaGPU organisation work for reusable GPU backend infrastructure, and especially the KernelAbstractions.jl backend-agnostic kernel language. Thank you.


Status

The AcceleratedKernels.jl GPU sort and accumulate implementations were adopted as the official AMDGPU algorithms! The API is starting to stabilise; it follows the Julia standard library's names and arguments fairly closely, with a contract of its own where GPU libraries need one (see Differences from Base), and reusable workspaces for scratch memory. For any new ideas / requests, please join the conversation on Julia Discourse or post an issue.

We have an extensive randomised test suite that we run on the CPU (single- and multi-threaded) backend on Windows, Ubuntu and MacOS for Julia LTS, Stable, and Pre-Release, plus OpenCL on PoCL, and the CUDA, AMDGPU, oneAPI and Metal backends on the JuliaGPU buildkite - the exact same tests are run on all architectures to ensure uniform interfaces.

AcceleratedKernels.jl is also a fundamental building block of applications developed at EvoPhase, so it will see continuous heavy use with industry backing. Long-term stability, performance improvements and support are priorities for us.


License

AcceleratedKernels.jl is MIT-licensed. Enjoy.