As presented on its official Github repository, "rocALUTION is a sparse linear algebra library with focus on exploring fine-grained parallelism [...], targeting modern CPU and GPU platforms". The library is easy to build on Linux systems. However, this process is a little bit more complex on Windows. In this project, I present all the steps required for building rocALUTION on Windows with OpenMP backend.
rocALUTION offers four different backends: host, OpenMP for multicore CPUs, HIP designed for ROCm compatible devices (currently available only on Linux systems) and MPI for multi-node clusters. As detailed in rocALUTION documentation, the library offers multiple iterative solvers, preconditioners and handles different sparse matrix storage formats:
- Fixed-Point iteration schemes - Jacobi, (Symmetric) Gauss-Seidel, SOR, SSOR
- Krylov subspace methods - CR, CG, BiCGStab, BiCGStab(l), GMRES, IDR, QMRCGSTAB, Flexible CG/GMRES
- Mixed-precision defect-correction scheme
- Chebyshev iteration scheme
- Multigrid - geometric and algebraic
- Matrix splitting schemes - Jacobi, (multi-colored) (symmetric) Gauss-Seidel, SOR, SSOR
- Factorization schemes - ILU(0), ILU(p) (based on levels), ILU(p,q) (power(q)-pattern method), multi-elimination ILU (nested/recursive), ILUT (based on threshold), IC(0)
- Approximate Inverses - Chebyshev matrix-valued polynomial, SPAI, FSAI, TNS
- Diagonal-based preconditioner for Saddle-point problems
- Block-type of sub-preconditioners/solvers
- (Restricted) Additive Schwarz
- Variable type of preconditioners
- Compressed Sparse Row (CSR)
- Modified Compressed Sparse Row (MCSR)
- Dense (DENSE)
- Coordinate (COO)
- The Ellpack-Itpack (ELL)
- Diagonal (DIA)
- Hybrid ELL and COO (HYB)
To build rocALUTION on Windows with OpenMP backend, three software tools are required: CMAKE, GIT and a compiling toolchain.
- CMAKE: the release 3.5+ is required. Older releases might not work.
- GIT
- Building toolchain: we will use MSVC included in Microsoft Visual Studio 2019. The MVS 2017 and 2015 will work as well.
Explain what these tests test and why
The first step is to download and install CMAKE, Git and Microsoft Visual Studio 2019.
The rocALUTION code can be downloaded in two ways:
- Use Git commands:
git clone https://github.com/ROCmSoftwarePlatform/rocALUTION.git
- Download the solution as a zipped file:
- Go to rocALUTION repository
- Click on "Clone or download", then click on "Download ZIP"
- Unzip the file to a folder of your choice
After download rocALUTION code, rename the folder "rocALUTION-develop" to "rocalution". Then, change directory to "rocalution"and create a directory "build" in the current folder.
- Open CMAKE
- Copy the rocalution root folder path to the "source code" text field of CMAKE
- Copy the rocalution build folder path to the "build the binaries" text field of CMAKE
- Click the button "Configure" (see Figure 1)
- A window pops up asking for:
- Generator (select Visual Studio 16 2019) if you want to build a library for the latest releases of MSVC tools
- Optionally, you can select the target platform (by default: x64)
- Once the configuration process is done, make sure that the "SUPPORT_OMP" flag is checked
- Press the button "Generate"
Figure 1. Configure project using CMAKE
(a)
(b)
Figure 2. Generate visual studio project using CMAKE: (a) Make sure that the "SUPPORT_OMP" flag is checked before clicking "Generate" (b) Once project generation is done, notice the visual studio solution and projects files added to the folder
Figure 3. Generated visual studio solution
- Open the "build" directory
- Open the Visual Studio solution by double clicking the file "rocalution.sln" (see Figure 3)
- Once the solution is opened in Microsoft Visual Studio IDE, the rocalution projects are listed in the Solution Explorer (see Figure 4)
Figure 4. Rocalution solution projects
- In the solution explorer, right-click on “rocalution” project and click “Build” (Notice that the default build is Debug and default platform is x64).
- You might get the error "C2065 'M_PI': undeclared identifier" (see Figure 5). This refers to the variable M_PI in line 430 of the file host_vector.cpp. This variable appears only once in that file and project. To solve this error, just add this line to the beginning of the function "double M_PI = 3.141592653589793238;" (e.g., line 420), then rebuild the project.
Figure 5. Potential compilation error
Once this error is corrected, the rocalution project can be built as a shared library.
- Select "Release" in the configuration dropdown list.
- Right-click on "rocalution" project and then click on "Properties".
- In the "General" tab, select "Static Library (.lib)" in the "Configuration Type" (see Figure 6).
- In the "Advanced" tab, make sure that the "Target File Extension" is ".lib" (see Figure 7).
- Under "C/C++" and "Optimization" tab, make sure that "Optimization" is set to "Maximum Optimization (Favor Speed) (/O2)" (see Figure 8).
- Under "C/C++" and "Code Generation" tab, make sure that "Runtime Library" is set to "Multi-threaded (/MT)" (see Figure 9).
- Under "C/C++" and "Language" tab, make sure that "Open MP Support" is set to "Yes (/openmp)" (see Figure 10).
- Click "OK". Then, rebuild the project.
Figure 6. Select static library
Figure 7. Set target file extension to ".lib"
Figure 8. Select maximum optimization
Figure 9. Select runtime library type
The output library will be stored under "[PATH]\rocalution\build\src\Release\rocalution.lib" (see Figure 11).
Figure 11. The release version of the library is saved to "build/src/Release"
In addition to the steps taken for "Release" version, add the following:
- Select "RelWithDebInfo" in the configuration dropdown list.
- Under "C/C++" and "General" tab, make sure that "Debug Information Format" is set to "Program Database (/Zi)" (see Figure 12).
Figure 12. Enable program database flag to generate '.pdb' files
The building process generates two files ('.lib' and '.pdb') which are stored under "[PATH]\rocalution\build\src\RelWithDebInfo\rocalution.lib" (see Figure 13).
Figure 13. Output files for the RelWithDebInfo release
- Select "Debug" in the configuration dropdown list.
- Under "C/C++" and "General" tab, make sure that "Debug Information Format" is set to "Program Database (/Zi)" (see Figure 12).
- Under "C/C++" and "Optimization" tab, make sure that "Optimization" is set to "Disabled (/Od)" (see Figure 14).
Figure 14. Disable optimization for the debug release
The building process generates also two files ('.lib' and '.pdb') which are stored under "[PATH]\rocalution\build\src\Debug\rocalution.lib".
This project is licensed under the MIT License - see the LICENSE file for details.