[ANN] Ark.jl v0.4.0 - Archetype-based ECS, now with support for simulations on the GPU

Ark.jl v0.4 focuses on bringing parallelization and customization to the core of the system. This major release introduces three powerful new features: seamless integration with all major GPU backends for component storage, the ability to use custom user-defined storages, and support for parallel queries.

Release highlights

GPU Storage

Here, it is possible to appreciate how in the new nbody demo the performance on a NVIDIA GeForce GTX 1650 is almost 20 times better than using all the 6 cores of my AMD Ryzen 5 5600H CPU:

CPU N-Body GPU N-Body

This is made possible by the new GPUVector and GPUStructArray component storages. These utilize unified memory to allow for efficient mixed CPU/GPU operations, and are fully compatible with many major backends like CUDA.jl, Metal.jl, oneAPI.jl, and OpenCL.jl.

Custom Storages

Ark.jl now allows to easily plug any data structures into the ECS which implements the storage interface. As long as the new storage is a one-indexed subtype of AbstractVector and implements the interface, it can be used. For example, this flexibility allowed us to easily integrate UniqueVectors.jl to support components optimized for O(1) searches.

Parallel Queries

Queries in archetype‑based ECS are already highly efficient, but this release introduces the necessary tooling to support parallel queries for even greater performance. With this, one can run multiple queries simultaneously thanks to a thread-safe locking mechanism.

Benchmarks with Agents.jl

We also compared Ark.jl with Agents.jl by faithfully reimplementing the benchmarks at GitHub - JuliaDynamics/ABMFrameworksComparison: Benchmarks and comparisons of leading ABM frameworks. The results show that Ark.jl is 2-7x faster than Agents.jl on those! A result which surprised me a bit, since the way those benchmarks are structured don’t really allow for an ECS to shine too much. We lose instead pretty much in the LOCS category since currently no spatial facility is implemented for Ark.jl which was then needed to be recreated inline to run these benchmarks.

More

For a full list of all changes, see the CHANGELOG.

As always, your feedback contributions are highly appreciated!

7 Likes

Would be great to have some animated demos in the docs. Difficult to understand what’s going on from a single picture.

1 Like

Totally! Put on my TODO list for the package

I made a simple boids render in 3d with the new RayMakie backend:

Somehow I lost the code for it though, so it didnt make it into the blogpost/announcement/RayDemo :smiley:
Would be cool to make a 100% stay on the GPU demo with the new version and example!

1 Like