Skip to content

Commit

Permalink
doc for GPU compilation on laptop
Browse files Browse the repository at this point in the history
  • Loading branch information
Frederic Perez committed Mar 25, 2024
1 parent 4539750 commit f9da9fb
Show file tree
Hide file tree
Showing 10 changed files with 83 additions and 33 deletions.
74 changes: 74 additions & 0 deletions doc/Sphinx/Use/install_linux_GPU.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@

Install on Linux for GPU
-----------------------------

First, make sure you have a recent version of CMAKE, and the other libraries
to compile Smilei on CPU as usual. In particular, for this example, you
need GCC <= 12.

Make a directory to store all the nvidia tools. We call it $NVDIR:

.. code:: bash
cd $NVDIR
The first step is download ``nvhpc`` and install it:

.. code:: bash
wget https://developer.download.nvidia.com/hpc-sdk/23.11/nvhpc_2023_2311_Linux_x86_64_cuda_12.3.tar.gz
tar xpzf nvhpc_2023_2311_Linux_x86_64_cuda_12.3.tar.gz
nvhpc_2023_2311_Linux_x86_64_cuda_12.3/install # install in $NVDIR when asked
rm nvhpc_2023_2311_Linux_x86_64_cuda_12.3.tar.gz
Then compile ``hdf5``:

.. code:: bash
export PATH=$NVDIR/Linux_x86_64/23.11/compilers/bin:$PATH
export PATH=$NVDIR/Linux_x86_64/23.11/comm_libs/mpi/bin:$PATH
wget https://github.com/HDFGroup/hdf5/releases/download/hdf5-1_14_2/hdf5-1_14_2.tar.gz
tar xpzf hdf5-1_14_2.tar.gz
cd hdfsrc/
mkdir build
cd build
cmake -DCMAKE_C_COMPILER=`which mpicc` -DCMAKE_INSTALL_PREFIX=$NVDIR/hdfsrc/install -DHDF5_ENABLE_PARALLEL=ON ..
make
make install
Create a file ``nvidia_env.sh`` containing the following commands:

.. code:: bash
export BUILD_DIR=build_nvidia
export PATH=$NVDIR/Linux_x86_64/23.11/compilers/bin:$PATH
export PATH=$NVDIR/Linux_x86_64/23.11/comm_libs/mpi/bin:$PATH
export HDF5_ROOT_DIR=$NVDIR/hdfsrc/install/
export LD_LIBRARY_PATH=$HDF5_ROOT_DIR/lib
export LDFLAGS="-acc=gpu -gpu=ccnative -cudalib=curand "
export CXXFLAGS="-acc=gpu -gpu=ccnative,fastmath -std=c++14 -lcurand -Minfo=accel -w -D__GCC_ATOMIC_TEST_AND_SET_TRUEVAL=1 -I$NVDIR/Linux_x86_64/23.11/math_libs/include/"
export GPU_COMPILER_FLAGS="-O3 --std c++14 -arch=sm_86 --expt-relaxed-constexpr --compiler-bindir $NVDIR -I$NVDIR/Linux_x86_64/23.11/comm_libs/12.3/openmpi4/openmpi-4.1.5/include/ -I$NVDIR/hdfsrc/install/include/"
export SMILEICXX_DEPS=g++
export SLURM_LOCALID=0
To compile Smilei:

.. code:: bash
source nvidia_env.sh
make config="gpu_nvidia"
To run:

.. code:: bash
source nvidia_env.sh
smilei namelist.py
3 changes: 3 additions & 0 deletions doc/Sphinx/Use/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,9 @@ Typically ``CXXFLAGS += -ta=tesla:cc80`` for ``nvhpc`` <23.4 and
* The hdf5 module should be compiled with the nvidia/cray compiler;
openmpi as well, but depending on the nvhpc module it might not be needed as it can be included in the nvhpc module.

For testing purposes, Smilei can be run on a linux PC with a good
GPU. As a guidance, read these :doc:`instructions for GPU on linux<install_linux_GPU>`.

----

.. _vectorization_flags:
Expand Down
1 change: 1 addition & 0 deletions doc/Sphinx/site.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ Unreferenced pages
/Use/install_linux
/Use/install_macos
/Use/install_supercomputer
/Use/install_linux_GPU
/Use/laser_offset
/Use/maxwell-juttner
/Use/particle_initialization
Expand Down
2 changes: 1 addition & 1 deletion makefile
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ ifneq ($(strip $(my_config)),)
$(error "Unused parameters in config : $(my_config)")
endif

SMILEICXX.DEPS ?= $(SMILEICXX)
SMILEICXX_DEPS ?= $(SMILEICXX)

#-----------------------------------------------------
# Rules for building the excutable smilei
Expand Down
2 changes: 1 addition & 1 deletion scripts/compile_tools/machine/adastra
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
################################################################################

SMILEICXX := CC
SMILEICXX.DEPS := $(SMILEICXX)
SMILEICXX_DEPS := $(SMILEICXX)
# GPU_COMPILER := hipcc
GPU_COMPILER := $(SMILEICXX)

Expand Down
20 changes: 0 additions & 20 deletions scripts/compile_tools/machine/cp_laptop

This file was deleted.

2 changes: 1 addition & 1 deletion scripts/compile_tools/machine/jean_zay_gpu_A100
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# http://www.idris.fr/jean-zay
#

SMILEICXX.DEPS = g++
SMILEICXX_DEPS = g++
#GPU_COMPILER = nvcc

CXXFLAGS += -w
Expand Down
2 changes: 1 addition & 1 deletion scripts/compile_tools/machine/jean_zay_gpu_V100
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# http://www.idris.fr/jean-zay
#

SMILEICXX.DEPS = g++
SMILEICXX_DEPS = g++
#GPU_COMPILER = nvcc

CXXFLAGS += -w
Expand Down
8 changes: 0 additions & 8 deletions scripts/compile_tools/machine/juanjo_cpu

This file was deleted.

2 changes: 1 addition & 1 deletion scripts/compile_tools/machine/ruche_gpu2
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

# Compile command: make -j 40 machine="ruche_gpu2" config="gpu_nvidia noopenmp detailed_timers verbose"

SMILEICXX.DEPS = g++ #nvcc -I/gpfs/softs/spack_0.17/opt/spack/linux-centos7-haswell/nvhpc-23.7/openmpi-4.1.5-ckfuippq6gf6qsilwitd7d2zyd5bng32/include/ -I/gpfs/softs/spack_0.17/opt/spack/linux-centos7-haswell/nvhpc-23.7/hdf5-1.12.0-3em63nl4p5tmv37offfmuvz2uswvgwzv/include/
SMILEICXX_DEPS = g++ #nvcc -I/gpfs/softs/spack_0.17/opt/spack/linux-centos7-haswell/nvhpc-23.7/openmpi-4.1.5-ckfuippq6gf6qsilwitd7d2zyd5bng32/include/ -I/gpfs/softs/spack_0.17/opt/spack/linux-centos7-haswell/nvhpc-23.7/hdf5-1.12.0-3em63nl4p5tmv37offfmuvz2uswvgwzv/include/

GPU_COMPILER = nvcc -I/gpfs/softs/spack_0.17/opt/spack/linux-centos7-haswell/nvhpc-23.7/openmpi-4.1.5-ckfuippq6gf6qsilwitd7d2zyd5bng32/include/ -I/gpfs/softs/spack_0.17/opt/spack/linux-centos7-haswell/nvhpc-23.7/hdf5-1.12.0-3em63nl4p5tmv37offfmuvz2uswvgwzv/include/

Expand Down

0 comments on commit f9da9fb

Please sign in to comment.