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