Numerical Computing with Rust on CPU

Europe/Paris
Description

This free online training will allow you to acquire or refine the skills needed to write efficient numerical computations for CPU platforms using the Rust programming language. Using a combination of theoretical explations and practical work, it will take place during three afternoons:

  • Monday, November 25th - 1pm: Introduction to Rust for numerical computing, practical work on implementing and optimizing simple numerical computations
  • Tuesday, November 26th - 1pm: End of the work on simple computations, followed by an introduction to the Gray-Scott reaction-diffusion model, which we will use as an example of a more complex computation for the remainder of the course.
  • Wednesday, November 27th - 1pm: Practical work covering more advanced Rust performance optimization techniques, applied to the Gray-Scott simulation introduced on day 2.

Why Rust?

The explosive growth of Python in numerical computing illustrates that scientific software developers are increasingly unwilling to put up with C++'s poor ergonomics, even if it comes at the expense of losing C++'s benefits to large-scale software maintainability and runtime performance. But what if we could have good ergonomics, maintainability and performance at the same time?

This is the value proposition of Rust, an emerging programming language that builds on many of the core design choices of C++ (powerful type system, tight control on program execution...), but has sacrificed some backwards compatibility with C and C++ where it allowed for major improvements in developer ergonomics.

As a result, Rust makes it a lot easier than both C++ and Python to write maintainable programs that are free of type/memory/thread-safety errors, robust in the face of runtime errors, and ultimately produce correct results. All the while enabling the levels of runtime performance that C++ developers are accustomed to, given similar or easier optimization efforts.

Course contents

In this online training, you will learn how to write efficient numerical computations for CPU platforms in Rust, through a combination of theoretical explanations and practical work.

We will first get to know Rust by manually implementing a few simple computations (squaring numbers, dot product...), gradually introducing needed language features as we go. Then we'll see how the underlying hardware can be used more efficiently through a combination of SIMD processing, instruction-level parallelism, and multi-threading.

Armed with this foundational knowledge, we will then scale the problem up to a more sophisticated numerical computation, the Gray-Scott reaction-diffusion model, which will introduce along the way. This will allow us to cover some of the more advanced performance optimization techniques that apply at this scale.

Target audience

No prior knowledge of the Rust programming language or the Gray-Scott model (or computational chemistry in general) is required to follow this course. They will all be introduced during the lectures.

On the other hand, it is recommended to have at least basic knowledge of the following topics:

  • C language concepts and syntax (number types and arithmetic, string literals, stack vs heap)
  • Numerical computing (floating-point numbers, single- and multi-dimensional arrays)
  • Linear algebra (vectors and matrices, dot product and matrix multiplication)
  • Differential equations, numerical resolution via Euler and finite difference methods
    • 13:00 16:30
      Rust for Numerical Computing

      To start the training, we will introduce the use of Rust for numerical computing and available platforms for practical work, then jump into said practical work. At this stage, our focus will be to efficiently implement a few simple computations (squaring each element of an array of floating-point numbers, dot product...). This will ease the learning curve of participants new to Rust, while more experienced Rust practicioners will still enjoy insight into how small-scale numerical performance optimization (SIMD, ILP, multi-threading) is performed in Rust.

    • 13:00 16:30
      From Rust to Gray-Scott

      Following our introduction to Rust numerical computing, we will scale up during the second day to a more complex numerical computing problem, the Gray-Scott reaction-diffusion model (which will be introduced along the way). This will allow us to introduce useful building blocks for real-world Rust numerical problems including command-line interfaces and HDF5 I/O.

      • 13:00
        Rust practice on simple computations, wrap-up 1h 30m
      • 14:30
        Break 20m
      • 14:50
        Introducing the Gray-Scott reaction-diffusion model 1h 30m
    • 13:00 16:30
      Optimizing the Gray-Scott simulation

      As the final day of the training begins, we now have a Rust implementation of the Gray-Scott reaction-diffusion model at hand. But does it perform as well as it should? As we will see, in addition to the small-scale optimization techniques that we have introduced in the first part of the course, the increased sophistication of the Gray-Scott model opens up new opportunities for more sophisticated performance optimization.

      • 13:00
        Gray-Scott optimization practice 1h 30m
      • 14:30
        Break 20m
      • 14:50
        Gray-Scott optimization practice, course wrap-up 1h 30m