Skip to content

NLeSC-COMPAS/compas-toolkit

Repository files navigation

Compas Toolkit

github Github Build GitHub License GitHub Tag

The Compas Toolkit is a high-performance C++ library offering GPU-accelerated functions for use in quantitative MRI research. The toolkit offers fast simulations of various MRI sequences and k-space trajectories commonly used in qMRI studies. While the core of the toolkit is implemented using CUDA, the functionality is accessible from both C++ and Julia.

Features

  • Flexible API that can be composed in different ways.
  • Highly tuned GPU kernels that provide high performance.
  • Implemented using CUDA, optimized for Nvidia GPUs.
  • Usable from Julia and C++.

Prerequisites

Compilation requires the following software:

  • CMake (version 3.10 or higher)
  • NVIDIA CUDA Compiler (version 11.0 or higher)
  • Julia (version 1.9 or later, only for Julia bindings)

Installation

To install the Compas Toolkit, follow these steps:

Clone the repository

First, clone the GitHub repository:

$ git clone --recurse-submodules https://github.com/NLeSC-COMPAS/compas-toolkit

Compiling the C++ code

Next, configure the CMake project inside a new build directory:

$ mkdir -p build
$ cd build
$ cmake -B. -DCMAKE_BUILD_TYPE=Release -DCMAKE_CUDA_ARCHITECTURES=80 ..

After the configuration, build the toolkit by running:

$ make compas-toolkit

This generates a static library named libcompas-toolkit.a.

Compiling the Julia bindings

To compile the Julia bindings, use the following command. This will install the library into a local lib/ directory:

$ make install

If everything has gone as planned, you'll now have a shared library called libcompas-julia.so in the local lib/ directory. Additionally, a Julia file should have been automatically generated as CompasToolkit.jl/src/CompasToolkit.jl.

Usage

To use the Compas Toolkit in Julia, simply build the Julia bindings using the instructions above and then add the directory CompasToolkit.jl to you Julia project.

$ julia
> using Pkg; Pkg.add(path="<path to compas-toolkit>/CompasToolkit.jl/")

You can then import the library with using CompasToolkit.

For examples of using the toolkit, take a look at the scripts available in the CompasToolkit.jl/tests directory.