Compile
Docker Images
For Linux users, if there is no access to sudo but can build containers with Docker, it is possible to compile the
project with
Docker. Check the provided Dockerfiles for more information.
Once the container is built, the .tar.gz will be placed under /. Simply copy them out and install/unpack the
archive. The .deb or .rpm packages are installed in the images, so they can be used directly.
The following is a general guide that covers three main operating systems.
Prerequisites
- To configure the source code, CMake shall be available. Please download and install it before configuring the source code package.
- The linear algebra driver used is OpenBLAS. You may want to compile it with the optimal configuration based on the specific machine. Otherwise, precompiled binaries (dynamic platform) are available in this repository.
- It is strongly recommended installing Intel MKL for potentially better performance.
- Please be aware that MKL is throttled on AMD platforms. Performance comparisons can be seen for example here. If you have AMD CPUs please collect more knowledge to determine which linear algebra library is more suitable.
Toolsets
A number of new features from new standards are utilized. To compile the binary, a compiler that supports C++20 is required.
GCC 11, Clang 13, MSVC 14.3, Intel compilers and later version of those compilers are tested with the source code.
On Windows, Visual Studio 2022 with Intel oneAPI toolkit is recommended. Alternatively, WinLibs can be used if GCC compilers are preferred.
On other platforms (Linux and macOS), simply use GCC (at least version 10) which comes with a valid Fortran compiler. Clang can also be used for C/CPP code, but since Clang and GCC have different supports for C++20, successful compilation is not guaranteed with Clang.
Obtain Source Code
Download the source code archive from GitHub Releases or the latest code.
Configure and Compile
The manual compilation is not difficult in general. The CI/CD configuration files can be referred to if you wish. Please check this page. Here some general guidelines are given.
Visual Studio
A solution file is provided under MSVC/suanPan folder. There are two configurations:
Debug: Assume no available Fortran compiler, all Fortran related libraries are provided as precompiled DLLs. Use OpenBLAS for linear algebra. Multithreading disabled. Visualisation disabled. HDF5 support disabled.Release: Fortran libraries are configured with Intel compilers. Use MKL for linear algebra. Multithreading enabled. Visualisation enabled with VTK version 9.2. HDF5 support enabled. CUDA enabled.
This repository contains some precompiled libraries used.
If Intel oneAPI Toolkit and CUDA are not installed, only the Debug configuration can be successfully compiled. Simply
open the solution and switch to Debug configuration, ignore all potential warnings and build the solution.
To compile Release version, please
-
Make sure oneAPI both base and HPC toolkits, as well as VS integration, are installed. Be aware of this issue if you are using VS 2022: Microsoft Visual Studio 2022 Version 17.2 and Newer Fails to Integrate with the Intel Fortran Compiler. The MKL is enabled via integrated option
<UseInteloneMKL>Parallel</UseInteloneMKL>. -
Make sure CUDA is installed. The environment variable
$(CUDA_PATH)is used to locate headers. -
Make sure VTK is available. Then define a system environment variable
$(VTK_DIR), which points to the root folder of VTK library. On my machine, it is
| PowerShell | |
|---|---|
For versions other than 9.2, names of the linked libraries shall be manually changed as they contain version numbers. Thus, it is not a good idea to switch to a different version. Precompiled VTK library is also available in this repository.
- Make sure MAGMA is available. Then define a system environment variable
$(MAGMA_DIR), which points to the root folder of MAGMA library. On my machine, it is
| PowerShell | |
|---|---|
You probably need to compile MAGMA yourself. You can manually remove all magma related settings in the solution file if you don't want to use it.
Alternatively, CMake can be used to generate solution files if some external packages are not available.
Ubuntu
The following instructions are based on Ubuntu 20.04. CMake is used to manage builds. It is recommended to use CMake GUI if appropriate.
- Install necessary tools.
| Bash | |
|---|---|
- Clone the project.
| Bash | |
|---|---|
- Create build folder and configure via CMake. The default configuration disables parallelism
-DBUILD_MULTITHREAD=OFFand enables HDF5 via bundled library-DUSE_HDF5=ON. Please checkOption.cmakefile or use GUI for available options.
- Invoke
make.
| Bash | |
|---|---|
Check the following recording.
Install VTK
Ubuntu official repository does not (Fedora does!) contain the latest VTK library. It's better to compile it manually.
- Install OpenGL first, as well as compilers if necessary.
| Bash | |
|---|---|
- Obtain VTK source code and unpack.
- Create folder for building VTK.
| Bash | |
|---|---|
- Configure and compile VTK library. If necessary, installation destination can be modified. Here static libraries are built.
| Bash | |
|---|---|
- Now obtain
suanPansource code and unpack it. To configure it with VTK support, users may use the following flag-DUSE_VTK=ON. IfFindVTKis presented andVTKis installed to default location, there is no need to provide the variableVTK_DIR, otherwise point it to thelib/cmake/vtk-9.1folder.
Install MKL
The provided CMake configuration covers both oneMKL and Intel MKL 2020. Please note MKL is included in oneAPI
toolkit starting from 2021, which has a different folder structure compared to Intel Parallel Studio.
The following guide is a manual installation is based on Ubuntu terminal using the official repository. See this page for details.
- Add repository. To summarise,
| Bash | |
|---|---|
- Install the package.
| Bash | |
|---|---|
- Now compile
suanPanby enabling MKL via option-DUSE_MKL=ON. The correspondingMKLROOTshall be assigned, for example-DMKLROOT=/opt/intel/oneapi/mkl/latest/, depending on the installation location. The configuration used for snap is the following one.
| Bash | |
|---|---|
Fedora
VTK
Fedora offers the latest VTK library, simply install it.
| Bash | |
|---|---|
MKL
Intel also provides a repository to install MKL via dnf.
See this page
for details.
First, create the repo file.
| Bash | |
|---|---|
Move it to the proper location.
| Bash | |
|---|---|
Install MKL. You may perform a search sudo dnf search intel-oneapi-mkl-devel to find which package name is available
and install the specific version if necessary.
| Bash | |
|---|---|
The source can be compiled with VTK and MKL enabled.
macOS
The following guide is based on macOS Big Sur (11).
Install tools. gfortran, llvm and libomp are used for compiling the main program, glfw and glew are required
for compiling VTK. VTK does not compile with GCC. Here, we use Clang.
| Bash | |
|---|---|
Similar to Ubuntu, compile VTK if wanted.
| Bash | |
|---|---|
MKL can be installed if necessary. See
this page
.
Obtain the source code and configure.
Build Options
If CMake GUI is used to configure the project, the following options are available.
BUILD_DLL_EXAMPLE: If enabled, example element/material/section implemented as external libraries will be built.BUILD_MULTITHREAD: If enabled,TBBwill be used for multithreading so that element update, global matrix assembly, etc., can be parallelized.OpenMPis not controlled by this option given thatOpenMPsupport is available in major platforms. It will be used for low level parallelization such as linear algebra operations (which is controlled byArmadillo), matrix solving (which is controlled by various solvers).BUILD_SHARED: If enabled, all libraries will be built as shared libraries.USE_SUPERLUMT: If enabled,SuperLU-MTwill be used, otherwiseSuperLUwill be used.USE_HDF5: If enabled,HDF5will be used to provide support forhdf5recorder.USE_VTK: If enabled,VTKwill be used to provide support for visualization. It will be useful to generate.vtkfiles that can be used inParaviewfor post-processing. If enabled,VTK_DIRneeds to be set to the path ofVTKinstallation. For example,VTK_DIR=/usr/local/opt/vtk/lib/cmake/vtk-9.1.USE_CUDA:CUDAneeds to be installed manually by the user. If enabled,CUDAbased solvers will be available. However, for dense matrix storage, only full matrix storage scheme is supported byCUDA. Note full matrix storage scheme is not favorable for FEM. It can, however, be used for sparse matrix solving and mixed precision solving.USE_AVX: If enabled, compiler flags-mavxor/arch:AVXwill be used. (~2011)USE_AVX2: If enabled, compiler flags-mavx2or/arch:AVX2will be used. (~2013)USE_AVX512: If enabled, compiler flags-mavx512for/arch:AVX512will be used. (~2016)USE_MKL:MKLneeds to be installed manually by the user. If enabled, the parallel version ofMKLwill be used for linear algebra operations. It is possible to manually modify the configuration to use cluster version (MPI). However, For the moment, the global matrix is still centralized in such a way that element updating will happen on a single node. The linear algebra operations may be offloaded to other nodes. IfUSE_MKLis enabled, the following additional options are available.LINK_DYNAMIC_MKL: If enabled, dynamically linkedMKLlibraries will be used. Otherwise, statically linkedMKLlibraries will be used, leading to larger binary size but faster execution and fewer dependencies.MKLROOT: Set this path to the root directory ofMKLinstallation. For example,C:/Program Files (x86)/Intel/oneAPI/mkl/latestor/opt/intel/oneapi/mkl/latest.USE_INTEL_OPENMP: If enabled, Intel OpenMP library will be used. Otherwise, Default ones (such as GNU OpenMP library) will be used.
Example Configuration
The following command is used to compile the program to be distributed via snap. See this file.