..

Kokkos-rs

my attempt at porting an existing C++ programming model to Rust


GitHub RepositoryReport


This research project focuses on a specific High Performance Computing (HPC) programming challenge: the issue of code portability across diverse hardware architectures.

We’ve been seeing a steady growth of the importance of GPUs in HPC clusters for quite some time now. Unfortunately, the software side of things didn’t improve as much, or at least not on every aspect. Portable GPGPU is still an issue, and multiple projects are trying to come up with a solution. Among those, we find Kokkos, a C++ Performance Portability Programming Model.

Kokkos is both a programming model and its implementation. It provides tools to write portable kernels, supporting both CPU and GPU by introducing the notions of memory space and execution space.

The goal of this project was to evaluate the viability of the model in the Rust programming language. The original Kokkos project implements its model in C++ only, making heavy use of templates. By re-implementing simple features of the model in Rust, we aimed to (a) check if the language was permissive enough to support the model, and (b) see how Rust’s built-in features would complement the model.


Overall, the model works very well in Rust. Ownership naturally complements the view system as lifetimes can be used to automatically manage shallow copies; well defined move and copy semantics also contribute to a “natural” API whereas the original implementation has to define arbitrary functions for each case.

The report covers that, and more. The original model is quickly introduced to then move on to benchmarks showcasing its usefulness. It also works as a gentle, practical introduction to cache dynamics and optimization.