Install Nvidia HPC C, C++, Fortran compilers
The free-to-use
Nvidia HPC SDK
offers possible speed improvements over GNU GCC / GFortran.
Intel oneAPI binaries can be significantly faster than Nvidia-compiled binaries for CPU-only workloads on Intel CPUs.
A typical reason for using Nvidia HPC SDK is the Cuda GPU features.
Nvidia HPC compilers support C11, C++20, and partial Fortran 2018 including submodule
and error stop
.
Download and install Nvidia HPC SDK. Create a script nvidia.sh:
To use NVIDIA HPC SDK, source the script:
source ~/nvidia.sh
Note: to use newer languages standard features, ensure the underlying GCC toolchain is set to a new-enough compiler
export CXXFLAGS=--gcc-toolchain=/opt/rh/gcc-toolset-14/root/usr/
which can be determined like:
scl enable gcc-toolset-14 "which g++"
For CMake use, set NVIDIA HPC compiler-specific options in CMakeLists.txt
like:
if(CMAKE_Fortran_COMPILER_ID STREQUAL "NVHPC")
add_compile_options($<$<COMPILE_LANGUAGE:Fortran>:-Mdclchk;-Munixlogical>)
endif()