Introduction
Expectations and conventions
This course assumes that the reader has basic familiarity with C (especially number types, arithmetic operations, string literals and stack vs heap). It will thus not explain concepts which are rigorously identical between Rust and C for the sake of concision. If this is not your case, feel free to ask the teacher about any surprising construct in the course’s material.
We will also compare Rust with C++ where they differ, so that readers familiar with C++ can get a good picture of Rust specificities. But previous knowledge of C++ should not be necessary to get a good understanding of Rust via this course.
Finally, we will make heavy use of “C/++” abbreviation as a shorter alternative to “C and C++” when discussing common properties of C and C++, and how they compare to Rust.
Intended workflow
Welcome to this practical about writing high performance computing in Rust!
You should have been granted access to a browser-based version of Visual Studio Code, where everything needed for the practical is installed. The intended workflow is for you to have this document opened in one browser tab, and the code editor opened in another tab (or even two browser windows side by side if your computer’s screen allows for it).
After performing basic Visual Studio Code configuration, I advise opening a
terminal, which you can do by showing the bottom pane of the code editor using
the Ctrl+J
keyboard shortcut.
You would then go to the exercises directory if you’re not already there…
cd ~/exercises
And, when you’re ready to do the exercises, start running cargo run
with the
options specified by the corresponding course material.
The exercises are based on code examples that are purposely incorrect.
Therefore, any code example within the provided exercises
Rust project, except
for 00-hello.rs
, will either fail to compile or fail to run to completion. A
TODO code comment or … symbol will indicate where failures are expected, and
your goal in the exercises will be to modify the code in such a way that the
associated example will compile and run. For runtime failures, you should not
need to change the failing assertion, instead you will need to change other code
such that the assertion passes.
If you encounter any failure which does not seem expected, or if you otherwise get stuck, please call the teacher for guidance!
Now, let’s get started with actual Rust code. You can move to the next page, or any other page within the course for that matter, through the following means:
- Left and right keyboard arrow keys will switch to the previous/next page. Equivalently, arrow buttons will be displayed at the end of each page, doing the same thing.
- There is a menu on the left (not shown by default on small screen, use the top-left button to show it) that allows you to quickly jump to any page of the course. Note, however, that the course material is designed to be read in order.
- With the magnifying glass icon in the top-left corner, or the “S” keyboard shortcut, you can open a search bar that lets you look up content by keywords.
Running the course environment locally
After the school, if you want to get back to this course, you will be able to
run the same development environment on your machine by installing podman
or
docker
and running the following command:
# Replace "podman" with "docker" if you prefer to use docker
podman run -p 8080:8080 --rm -it gitlab-registry.in2p3.fr/grasland/grayscott-with-rust/rust_code_server
You will then be able to connect to the environement by opening the
http://127.0.0.1:8080 URL in your web browser, and typing in the password that
is displayed at the beginning of the console output of podman run
.
Please refrain from doing so during the school, however:
- These container images are designed to please HPC sysadmins who are unhappy with internet downloads from compute nodes. Therefore they bundle everything that may be possibly needed during the course, and are quite heavyweight as a result. If everyone attempts to download them at once at the beginning of the course, it may saturate the building’s or CCIN2P3’s internet connection and therefore disrupt the classes.
- Making your local GPUs work inside of the course’s container can require a fair amount of work, especially if you use NVidia GPUs, whose driver is architected in a manner that is fundamentally hostile to Linux containers. Your local organizers will have done their best to make it work for you during the school, saving you a lot of time. Without such support, a CPU emulation will be used, so the GPU examples will still work but run very slowly.
As for Apptainer/Singularity, although it is reasonably compatible with Docker/Podman container images, it actually does many things very differently from other container engines as far as running containers is concerned. Therefore, it must be run in a very exotic configuration for the course environment to work as expected. Please check out the course repository’s README for details.