1a8c70ff5SJunchao Zhang#!/usr/bin/python3 2a8c70ff5SJunchao Zhang 3a8c70ff5SJunchao Zhang# Use GNU compilers 4a8c70ff5SJunchao Zhang# module load PrgEnv-gnu 5a8c70ff5SJunchao Zhang# module load cray-mpich 666a39b35SJunchao Zhang# module load craype-accel-amd-gfx90a 766a39b35SJunchao Zhang# module load rocm 8a8c70ff5SJunchao Zhang# 9a8c70ff5SJunchao Zhang# To enable GPU-aware MPI, one has to also set this runtime environment variable 10a8c70ff5SJunchao Zhang# 11a8c70ff5SJunchao Zhang# export MPICH_GPU_SUPPORT_ENABLED=1 12a8c70ff5SJunchao Zhang# 13ec0e25d5SJunchao Zhang# To use hipcc with GPU-aware Cray MPICH, use the following environment variables to setup the needed header files and libraries. 14ec0e25d5SJunchao Zhang# 15ec0e25d5SJunchao Zhang# -I${MPICH_DIR}/include 16ec0e25d5SJunchao Zhang# -L${MPICH_DIR}/lib -lmpi ${PE_MPICH_GTL_DIR_amd_gfx90a} ${PE_MPICH_GTL_LIBS_amd_gfx90a} 17ec0e25d5SJunchao Zhang# 18ec0e25d5SJunchao Zhang# See also https://docs.olcf.ornl.gov/systems/frontier_user_guide.html#gpu-aware-mpi 19ec0e25d5SJunchao Zhang# 20a8c70ff5SJunchao Zhangif __name__ == '__main__': 21a8c70ff5SJunchao Zhang import sys 22a8c70ff5SJunchao Zhang import os 23a8c70ff5SJunchao Zhang sys.path.insert(0, os.path.abspath('config')) 24a8c70ff5SJunchao Zhang import configure 25a8c70ff5SJunchao Zhang configure_options = [ 26a8c70ff5SJunchao Zhang '--with-debugging=0', 27a8c70ff5SJunchao Zhang '--with-cc=cc', 28a8c70ff5SJunchao Zhang '--with-cxx=CC', 29a8c70ff5SJunchao Zhang '--with-fc=ftn', 30a8c70ff5SJunchao Zhang '--with-mpiexec=srun -p batch -N 1 -A csc314 -t 00:10:00', 31ec0e25d5SJunchao Zhang '--with-batch', 32a8c70ff5SJunchao Zhang '--with-hip', 33a8c70ff5SJunchao Zhang '--with-hipc=hipcc', 34ec0e25d5SJunchao Zhang 'LIBS={GTLDIR} {GTLLIBS}'.format(GTLDIR=os.environ['PE_MPICH_GTL_DIR_amd_gfx90a'], GTLLIBS=os.environ['PE_MPICH_GTL_LIBS_amd_gfx90a']), 35719633f8SJunchao Zhang '--download-metis', 36719633f8SJunchao Zhang '--download-parmetis', 37a8c70ff5SJunchao Zhang '--download-kokkos', 38a8c70ff5SJunchao Zhang '--download-kokkos-kernels', 39719633f8SJunchao Zhang '--download-superlu_dist', 40*04ba64a0SVictor A. P. Magri '--download-umpire', 41*04ba64a0SVictor A. P. Magri '--download-hypre' 42a8c70ff5SJunchao Zhang ] 43a8c70ff5SJunchao Zhang configure.petsc_configure(configure_options) 44a8c70ff5SJunchao Zhang 45a8c70ff5SJunchao Zhang# Use Cray compilers 46a8c70ff5SJunchao Zhang# module load PrgEnv-cray 47a8c70ff5SJunchao Zhang# module load cray-mpich 48a8c70ff5SJunchao Zhang# module load amd-mixed/5.4.0 49a8c70ff5SJunchao Zhang 50a8c70ff5SJunchao Zhang# To enable GPU-aware MPI, one has to also set this runtime environment variable 51a8c70ff5SJunchao Zhang# 52a8c70ff5SJunchao Zhang# export MPICH_GPU_SUPPORT_ENABLED=1 53a8c70ff5SJunchao Zhang# 54a8c70ff5SJunchao Zhang# Additional note: "craype-accel-amd-gfx90a" module is recommended for 55a8c70ff5SJunchao Zhang# "OpenMP offload" or "GPU enabled MPI". It requires "--with-openmp" option. 56a8c70ff5SJunchao Zhang# [otherwise building c examples gives link errors (when fortran bindings are enabled)] 57a8c70ff5SJunchao Zhang# Alternative is to use "-lmpi_gtl_hsa" as shown below. 58a8c70ff5SJunchao Zhang# 59a8c70ff5SJunchao Zhang# ld.lld: error: lib/libpetsc.so: undefined reference to .omp_offloading.img_start.cray_amdgcn-amd-amdhsa [--no-allow-shlib-undefined] 60a8c70ff5SJunchao Zhang# 61a8c70ff5SJunchao Zhang# Also, please ignore warnings like this. If you don't use Fortran, use '--with-fc=0' to get rid of them. 62a8c70ff5SJunchao Zhang# 636dd63270SBarry Smith# ftn-878 ftn: WARNING PETSC, File = ../../../autofs/nccs-svm1_home1/jczhang/petsc/src/tao/ftn-mod/petsctaomod.F90, Line = 37, Column = 13 64a8c70ff5SJunchao Zhang# A module named "PETSCVECDEFDUMMY" has already been directly or indirectly use associated into this scope. 65a8c70ff5SJunchao Zhang 66a8c70ff5SJunchao Zhang# if __name__ == '__main__': 67a8c70ff5SJunchao Zhang# import sys 68a8c70ff5SJunchao Zhang# import os 69a8c70ff5SJunchao Zhang# sys.path.insert(0, os.path.abspath('config')) 70a8c70ff5SJunchao Zhang# import configure 71a8c70ff5SJunchao Zhang# configure_options = [ 72a8c70ff5SJunchao Zhang# '--with-debugging=0', 73a8c70ff5SJunchao Zhang# '--with-cc=cc', 74a8c70ff5SJunchao Zhang# '--with-cxx=CC', 75a8c70ff5SJunchao Zhang# '--with-fc=ftn', 76a8c70ff5SJunchao Zhang# # -std=c2x is a workaround for this hipsparse problem 77a8c70ff5SJunchao Zhang# # /opt/rocm-5.4.0/include/hipsparse/hipsparse.h:8741:28: error: expected '= constant-expression' or end of enumerator definition 78a8c70ff5SJunchao Zhang# # HIPSPARSE_ORDER_COLUMN [[deprecated("Please use HIPSPARSE_ORDER_COL instead")]] = 1, 79f0b74427SPierre Jolivet# # -Wno-constant-logical-operand is a workaround to suppress excessive warnings caused by -std=c2x in PETSc source which we don't want to address, see MR !6287 80a8c70ff5SJunchao Zhang# '--CFLAGS=-std=c2x -Wno-constant-logical-operand', 81a8c70ff5SJunchao Zhang# 'LIBS={GTLDIR} {GTLLIBS}'.format(GTLDIR=os.environ['PE_MPICH_GTL_DIR_amd_gfx90a'], GTLLIBS=os.environ['PE_MPICH_GTL_LIBS_amd_gfx90a']), 82a8c70ff5SJunchao Zhang# #'--with-openmp=1', # enable if using "craype-accel-amd-gfx90a" module 83a8c70ff5SJunchao Zhang# '--with-mpiexec=srun -p batch -N 1 -A csc314 -t 00:10:00', 84ec0e25d5SJunchao Zhang# '--with-batch', 85a8c70ff5SJunchao Zhang# '--with-hip', 86a8c70ff5SJunchao Zhang# '--with-hipc=hipcc', 87a8c70ff5SJunchao Zhang# '--download-kokkos', 88a8c70ff5SJunchao Zhang# '--download-kokkos-kernels', 89a8c70ff5SJunchao Zhang# ] 90a8c70ff5SJunchao Zhang# configure.petsc_configure(configure_options) 91