Introduction
The latest version of OMPi enables offloading to Vulkan-supported GPUs through the vulkan module. OMPi analyzes the OpenMP target directives appearing in a user application and generates kernel source files, written in shader language (GLSL).
The vulkan module can:
- Compile the shader files to SPIR-V binaries,
- Optimize the generated binaries in terms of size and performance,
- Initialize and finalize a Vulkan device,
- Transfer data between the CPU and a Vulkan device,
- Offload compute shaders to the requested Vulkan device.
Requirements
The current requirements of the vulkan module are the following:
- Vulkan Loader
sudo apt-get install libvulkan-devOR
dnf install vulkan-loader-devel
- Vulkan Validation layers and SPIR-V tools
sudo apt install vulkan-validationlayers spirv-tools glslang-tools
ORsudo dnf install mesa-vulkan-drivers vulkan-validation-layers-devel glslang
- Vulkan Utilities
sudo apt-get install vulkan-toolsOR
dnf install vulkan-tools
On Arch Linux,ou can run sudo pacman -S vulkan-devel to install all the required tools.
Before proceeding with the installation, verify the Vulkan installation and SPIR-V utilities by executing:
$ vulkaninfo
$ glslangValidator -v
The commands should display information about the Vulkan devices and Glslang version, respectively.
Installing OMPi
The first step is to deploy OMPi on your system. Initially, you need to build OMPi as usual:
meson setup build --prefix=<install-dir> cd build/ meson compile meson install
During the installation process, if your system satisfies the minimum requirements and has at least one Vulkan-enabled GPU installed, OMPi will automatically build the vulkan module. The correct installation of the module can be verified by running:
ompiconf --devvinfo
which lists all the identified modules/devices, along with their numeric device IDs. If the above command fails to show a Vulkan GPU, please revisit the minimum requirements and ensure you have installed OMPi correctly.
Quick start
Compiling your OpenMP application with Vulkan GPU offloading requires a simple --devs=all argument:
ompicc --devs=all app.c
The compiler will produce the main application executable (a.out) and several SPIR-V kernel binaries, one for each OpenMP target construct in the application.
Limitations
Currently, the vulkan module has a number of limitations:
- Structs are allowed, but the above restriction also applies to struct fields,
- Only static loop scheduling is supported in
target teams distribute parallel fordirectives, - Pointers and conditional jumps are not allowed in the offloaded kernels.
Notes
The OMPi vulkan module has been tested with the following GPUs:
- NVIDIA Ampere A2
- NVIDIA Tesla P40
- AMD RX 550
- Intel UHD 770
- VideoCore VII (Raspberry Pi 5)
- VideoCore VI (Raspberry Pi 4)