1a8c70ff5SJunchao Zhang#!/usr/bin/python3 2a8c70ff5SJunchao Zhang 3a8c70ff5SJunchao Zhang# Use GNU compilers 4a8c70ff5SJunchao Zhang# module load PrgEnv-gnu 5a8c70ff5SJunchao Zhang# module load cray-mpich 6*66a39b35SJunchao Zhang# module load craype-accel-amd-gfx90a 7*66a39b35SJunchao 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', 40a8c70ff5SJunchao Zhang ] 41a8c70ff5SJunchao Zhang configure.petsc_configure(configure_options) 42a8c70ff5SJunchao Zhang 43a8c70ff5SJunchao Zhang# Use Cray compilers 44a8c70ff5SJunchao Zhang# module load PrgEnv-cray 45a8c70ff5SJunchao Zhang# module load cray-mpich 46a8c70ff5SJunchao Zhang# module load amd-mixed/5.4.0 47a8c70ff5SJunchao Zhang 48a8c70ff5SJunchao Zhang# To enable GPU-aware MPI, one has to also set this runtime environment variable 49a8c70ff5SJunchao Zhang# 50a8c70ff5SJunchao Zhang# export MPICH_GPU_SUPPORT_ENABLED=1 51a8c70ff5SJunchao Zhang# 52a8c70ff5SJunchao Zhang# Additional note: "craype-accel-amd-gfx90a" module is recommended for 53a8c70ff5SJunchao Zhang# "OpenMP offload" or "GPU enabled MPI". It requires "--with-openmp" option. 54a8c70ff5SJunchao Zhang# [otherwise building c examples gives link errors (when fortran bindings are enabled)] 55a8c70ff5SJunchao Zhang# Alternative is to use "-lmpi_gtl_hsa" as shown below. 56a8c70ff5SJunchao Zhang# 57a8c70ff5SJunchao Zhang# ld.lld: error: lib/libpetsc.so: undefined reference to .omp_offloading.img_start.cray_amdgcn-amd-amdhsa [--no-allow-shlib-undefined] 58a8c70ff5SJunchao Zhang# 59a8c70ff5SJunchao Zhang# Also, please ignore warnings like this. If you don't use Fortran, use '--with-fc=0' to get rid of them. 60a8c70ff5SJunchao Zhang# 61a8c70ff5SJunchao Zhang# ftn-878 ftn: WARNING PETSC, File = ../../../autofs/nccs-svm1_home1/jczhang/petsc/src/tao/f90-mod/petsctaomod.F90, Line = 37, Column = 13 62a8c70ff5SJunchao Zhang# A module named "PETSCVECDEFDUMMY" has already been directly or indirectly use associated into this scope. 63a8c70ff5SJunchao Zhang 64a8c70ff5SJunchao Zhang 65a8c70ff5SJunchao Zhang# if __name__ == '__main__': 66a8c70ff5SJunchao Zhang# import sys 67a8c70ff5SJunchao Zhang# import os 68a8c70ff5SJunchao Zhang# sys.path.insert(0, os.path.abspath('config')) 69a8c70ff5SJunchao Zhang# import configure 70a8c70ff5SJunchao Zhang# configure_options = [ 71a8c70ff5SJunchao Zhang# '--with-debugging=0', 72a8c70ff5SJunchao Zhang# '--with-cc=cc', 73a8c70ff5SJunchao Zhang# '--with-cxx=CC', 74a8c70ff5SJunchao Zhang# '--with-fc=ftn', 75a8c70ff5SJunchao Zhang# # -std=c2x is a workaround for this hipsparse problem 76a8c70ff5SJunchao Zhang# # /opt/rocm-5.4.0/include/hipsparse/hipsparse.h:8741:28: error: expected '= constant-expression' or end of enumerator definition 77a8c70ff5SJunchao Zhang# # HIPSPARSE_ORDER_COLUMN [[deprecated("Please use HIPSPARSE_ORDER_COL instead")]] = 1, 78baca6076SPierre 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 79a8c70ff5SJunchao Zhang# '--CFLAGS=-std=c2x -Wno-constant-logical-operand', 80a8c70ff5SJunchao Zhang# 'LIBS={GTLDIR} {GTLLIBS}'.format(GTLDIR=os.environ['PE_MPICH_GTL_DIR_amd_gfx90a'], GTLLIBS=os.environ['PE_MPICH_GTL_LIBS_amd_gfx90a']), 81a8c70ff5SJunchao Zhang# #'--with-openmp=1', # enable if using "craype-accel-amd-gfx90a" module 82a8c70ff5SJunchao Zhang# '--with-mpiexec=srun -p batch -N 1 -A csc314 -t 00:10:00', 83ec0e25d5SJunchao Zhang# '--with-batch', 84a8c70ff5SJunchao Zhang# '--with-hip', 85a8c70ff5SJunchao Zhang# '--with-hipc=hipcc', 86a8c70ff5SJunchao Zhang# '--download-kokkos', 87a8c70ff5SJunchao Zhang# '--download-kokkos-kernels', 88a8c70ff5SJunchao Zhang# ] 89a8c70ff5SJunchao Zhang# configure.petsc_configure(configure_options)