Skip to content

Commit 9ab5e21

Browse files
committed
Upstream fixes from henryleberre/[amdgpu, gcc-acc]
1 parent 5e7fc2a commit 9ab5e21

File tree

5 files changed

+228
-114
lines changed

5 files changed

+228
-114
lines changed

CMakeLists.txt

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -89,12 +89,12 @@ if (CMAKE_Fortran_COMPILER_ID STREQUAL "GNU")
8989
endif()
9090
elseif (CMAKE_Fortran_COMPILER_ID STREQUAL "Cray")
9191
add_compile_options(
92-
-h nomessage=296:878:1391:1069
93-
-h msgs -h static -h keepfiles
92+
"SHELL:-h nomessage=296:878:1391:1069"
93+
"SHELL:-h msgs" "SHELL:-h static" "SHELL:-h keepfiles"
9494
)
9595

9696
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
97-
add_compile_options(-e D -h func_trace)
97+
add_compile_options(-e D "SHELL:-h func_trace")
9898
endif()
9999
elseif (CMAKE_Fortran_COMPILER_ID STREQUAL "Flang")
100100
add_compile_options(
@@ -185,10 +185,14 @@ macro(HANDLE_SOURCES target)
185185

186186
add_custom_command(
187187
OUTPUT ${f90}
188-
COMMAND ${FYPP_EXE} -I "${common_DIR}"
188+
COMMAND ${FYPP_EXE} -m re
189+
-I "${common_DIR}"
189190
-I "${common_DIR}/include"
190191
-I "${${target}_DIR}/include"
192+
-D MFC_${CMAKE_Fortran_COMPILER_ID}
193+
-D MFC_COMPILER="${CMAKE_Fortran_COMPILER_ID}"
191194
--line-numbering
195+
--no-folding
192196
"${fpp}" "${f90}"
193197
DEPENDS "${fpp};${${target}_incs};${common_incs}"
194198
COMMENT "Preprocessing (Fypp) ${fpp_filename}"
@@ -215,6 +219,8 @@ function(MFC_SETUP_TARGET)
215219

216220
add_executable(${ARGS_TARGET} ${ARGS_SOURCES})
217221

222+
target_compile_definitions(${ARGS_TARGET} PRIVATE MFC_${CMAKE_Fortran_COMPILER_ID})
223+
218224
if (MFC_MPI AND ARGS_MPI)
219225
find_package(MPI COMPONENTS Fortran REQUIRED)
220226

@@ -260,7 +266,7 @@ function(MFC_SETUP_TARGET)
260266
endif()
261267
endif()
262268
elseif (CMAKE_Fortran_COMPILER_ID STREQUAL "Cray")
263-
target_compile_options(${ARGS_TARGET} PRIVATE -h noacc -x acc)
269+
target_compile_options(${ARGS_TARGET} PRIVATE "SHELL:-h noacc" "SHELL:-x acc")
264270
endif()
265271

266272
string(TOUPPER "${ARGS_TARGET}" ARGS_TARGET_UPPER)

mfc.sh

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,10 @@ if [ "$1" == "load" ]; then
4242
if [ -v $u_computer ]; then
4343
log "Select a system:"
4444
log "$G""ORNL$W: Ascent (a), Crusher (c), Summit (s), Wombat (w)"
45-
log "$C""ACCESS$W: Bridges2 (b), Expanse (e)"
45+
log "$C""ACCESS$W: Bridges2 (b), Expanse (e), Delta (d)"
4646
log "$Y""GaTech$W: Phoenix (p)"
4747
log "$R""CALTECH$W: Richardson (r)"
48-
log_n "($G""a$W/$G""c$W/$G""s$W/$G""w$W/$C""b$W/$C""e$CR/$Y""p$CR/$R""r$CR): "
48+
log_n "($G""a$W/$G""c$W/$G""s$W/$G""w$W/$C""b$W/$C""e$CR/$C""d$CR/$Y""p$CR/$R""r$CR): "
4949
read u_computer
5050
log
5151
fi
@@ -92,6 +92,14 @@ if [ "$1" == "load" ]; then
9292
fi
9393

9494
MODULES=("${MODULES[@]}" "python/3.8.6")
95+
elif [ "$u_computer" == "d" ]; then # Delta
96+
if [ "$u_cg" == "c" ]; then
97+
MODULES=()
98+
elif [ "$u_cg" == "g" ]; then
99+
MODULES=("nvhpc/22.5")
100+
fi
101+
102+
MODULES=("${MODULES[@]}" "cmake" "openmpi")
95103
elif [ "$u_computer" == "a" ]; then # For Ascent
96104
if [ "$u_cg" == "c" ]; then
97105
MODULES=("gcc/11.1.0" "spectrum-mpi" "cuda")
@@ -145,7 +153,7 @@ if [ "$1" == "load" ]; then
145153
MODULES=("rocm/5.1.0" "craype-accel-amd-gfx90a")
146154
fi
147155

148-
MODULES=("${MODULES[@]}" "cmake/3.23.2" "cray-fftw/3.3.10.2" "hdf5/1.12.1" "cray-python/3.9.13.1" "ninja/1.10.2" "cray-mpich/8.1.23")
156+
MODULES=("${MODULES[@]}" "cce/15.0.1" "cmake/3.23.2" "cray-fftw/3.3.10.2" "hdf5/1.12.1" "cray-python/3.9.13.1" "ninja/1.10.2" "cray-mpich/8.1.23")
149157
else
150158
echo -e $RED"Error: Requested system $u_computer is not supported (yet!)"$COLOR_RESET
151159

misc/gnu13oacc.sh

Lines changed: 0 additions & 72 deletions
This file was deleted.

misc/gnu_acc.sh

Lines changed: 190 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,190 @@
1+
#!/bin/bash
2+
3+
# Author: Henry Le Berre
4+
# Description: Builds gcc/g++/gfortran with nvptx-none and amdgcn-amdhsa offloading
5+
# from the devel/omp/gcc-12 branch.
6+
7+
set -e
8+
9+
JOBS=1
10+
INSTALL_PREFIX=""
11+
12+
while [[ $# -gt 0 ]]; do
13+
case $1 in
14+
--prefix) INSTALL_PREFIX="$2"; shift; shift; ;;
15+
-a|--amd) AMD=1; shift; ;;
16+
-n|--nvidia) NVIDIA=1; shift; ;;
17+
-d|--temp-dir) TEMP_DIR="$2"; shift; shift; ;;
18+
-j|--jobs) JOBS="$2"; shift; shift; ;;
19+
-h|--help) PRINT_HELP=1; shift; ;;
20+
-*|--*)
21+
echo "Unknown option $1"
22+
exit 1
23+
;;
24+
esac
25+
done
26+
27+
if [[ -n "$PRINT_HELP" ]]; then
28+
echo "Usage: $0 [options]"
29+
echo "Options:"
30+
echo " --prefix <path> Installation prefix."
31+
echo " -a, --amd Offload for AMD GPUs."
32+
echo " -n, --nvidia Offload for NVIDIA GPUs."
33+
echo " -d, --temp-dir Temporary directory to use for building. [default: mktemp -d]"
34+
echo " -j, --jobs <n> Number of jobs to run in parallel [default: $JOBS]."
35+
echo " -h, --help Print this help message."
36+
exit 0
37+
fi
38+
39+
if [[ -z "$INSTALL_PREFIX" ]]; then
40+
echo "Error: No installation prefix specified."
41+
exit 1
42+
fi
43+
44+
if [[ -z "$TEMP_DIR" ]]; then
45+
TEMP_DIR="$(mktemp -d)"
46+
fi
47+
48+
if [[ ! -z "$NVIDIA" ]]; then
49+
git clone --depth=1 \
50+
'https://github.com/MentorEmbedded/nvptx-tools.git' \
51+
"$TEMP_DIR/repositories/nvptx-tools"
52+
53+
mkdir -p "$TEMP_DIR/staging/nvptx-tools"
54+
55+
(cd "$TEMP_DIR/staging/nvptx-tools"; "$TEMP_DIR/repositories/nvptx-tools/configure" --prefix="$INSTALL_PREFIX")
56+
57+
make install \
58+
-j $JOBS \
59+
-C "$TEMP_DIR/staging/nvptx-tools"
60+
61+
rm -rf "$TEMP_DIR/staging/nvptx-tools"
62+
fi
63+
64+
if [[ ! -z "$AMD" ]]; then
65+
mkdir -p "$TEMP_DIR/repositories/llvm-project"
66+
67+
wget -O "$TEMP_DIR/repositories/llvmorg.tar.gz" \
68+
'https://github.com/llvm/llvm-project/archive/refs/tags/llvmorg-13.0.1.tar.gz'
69+
70+
tar -C "$TEMP_DIR/repositories/llvm-project" \
71+
-vxf "$TEMP_DIR/repositories/llvmorg.tar.gz" \
72+
--strip-components 1
73+
74+
rm "$TEMP_DIR/repositories/llvmorg.tar.gz"
75+
76+
cmake \
77+
-D LLVM_ENABLE_PROJECTS=lld \
78+
-B "$TEMP_DIR/staging/llvm-project" \
79+
-D LLVM_TARGETS_TO_BUILD="X86;AMDGPU" \
80+
-S "$TEMP_DIR/repositories/llvm-project/llvm"
81+
82+
make -C "$TEMP_DIR/staging/llvm-project" \
83+
-j $JOBS
84+
85+
mkdir -p "$INSTALL_PREFIX/amdgcn-amdhsa/bin"
86+
87+
cp -a "$TEMP_DIR/staging/llvm-project/bin/llvm-ar" \
88+
"$INSTALL_PREFIX/amdgcn-amdhsa/bin/ar"
89+
cp -a "$TEMP_DIR/staging/llvm-project/bin/llvm-ar" \
90+
"$INSTALL_PREFIX/amdgcn-amdhsa/bin/ranlib"
91+
cp -a "$TEMP_DIR/staging/llvm-project/bin/llvm-mc" \
92+
"$INSTALL_PREFIX/amdgcn-amdhsa/bin/as"
93+
cp -a "$TEMP_DIR/staging/llvm-project/bin/llvm-nm" \
94+
"$INSTALL_PREFIX/amdgcn-amdhsa/bin/nm"
95+
cp -a "$TEMP_DIR/staging/llvm-project/bin/lld" \
96+
"$INSTALL_PREFIX/amdgcn-amdhsa/bin/ld"
97+
98+
rm -rf "$TEMP_DIR/repositories/llvm-project"
99+
fi
100+
101+
git clone --depth=1 \
102+
--branch master \
103+
'git://sourceware.org/git/newlib-cygwin.git' \
104+
"$TEMP_DIR/repositories/newlib-cygwin"
105+
106+
git clone --depth=1 \
107+
--branch devel/omp/gcc-12 \
108+
'git://gcc.gnu.org/git/gcc.git' \
109+
"$TEMP_DIR/repositories/gcc"
110+
111+
(cd "$TEMP_DIR/repositories/gcc"; "$TEMP_DIR/repositories/gcc/contrib/download_prerequisites")
112+
113+
ln -s "$TEMP_DIR/repositories/newlib-cygwin/newlib" \
114+
"$TEMP_DIR/repositories/gcc/newlib"
115+
116+
if [[ ! -z "$AMD" ]]; then
117+
mkdir -p "$TEMP_DIR/staging/amdgcn-amdhsa-gcc"
118+
119+
(cd "$TEMP_DIR/staging/amdgcn-amdhsa-gcc"; "$TEMP_DIR/repositories/gcc/configure" \
120+
--prefix="$INSTALL_PREFIX" \
121+
--target=amdgcn-amdhsa \
122+
--with-newlib \
123+
--enable-languages=c,c++,fortran,lto \
124+
--disable-bootstrap \
125+
--disable-libquadmath \
126+
--disable-sjlj-exceptions \
127+
--with-build-time-tools="$INSTALL_PREFIX/amdgcn-amdhsa/bin" \
128+
--enable-as-accelerator-for=x86_64-pc-linux-gnu)
129+
130+
make -j $JOBS \
131+
-C "$TEMP_DIR/staging/amdgcn-amdhsa-gcc"
132+
133+
make install \
134+
-j $JOBS \
135+
-C "$TEMP_DIR/staging/amdgcn-amdhsa-gcc"
136+
137+
rm -rf "$TEMP_DIR/staging/amdgcn-amdhsa-gcc"
138+
fi
139+
140+
if [[ ! -z "$NVIDIA" ]]; then
141+
mkdir -p "$TEMP_DIR/staging/nvptx-none-gcc"
142+
143+
(cd "$TEMP_DIR/staging/nvptx-none-gcc"; "$TEMP_DIR/repositories/gcc/configure" \
144+
--prefix="$INSTALL_PREFIX" \
145+
--target=nvptx-none \
146+
--with-newlib \
147+
--enable-languages=c,c++,fortran,lto \
148+
--disable-bootstrap \
149+
--disable-libquadmath \
150+
--disable-sjlj-exceptions \
151+
--enable-newlib-io-long-long \
152+
--with-build-time-tools="$INSTALL_PREFIX/nvptx-none/bin" \
153+
--enable-as-accelerator-for=x86_64-pc-linux-gnu)
154+
155+
make -j $JOBS \
156+
-C "$TEMP_DIR/staging/nvptx-none-gcc"
157+
158+
make install \
159+
-j $JOBS \
160+
-C "$TEMP_DIR/staging/nvptx-none-gcc"
161+
fi
162+
163+
mkdir -p "$TEMP_DIR/staging/host-gcc"
164+
165+
if [[ ! -z "$AMD" ]]; then
166+
OFFLOAD_OPT="--enable-offload-targets=amdgcn-amdhsa=$INSTALL_PREFIX/amdgcn-amdhsa"
167+
fi
168+
169+
if [[ ! -z "$NVIDIA" ]]; then
170+
OFFLOAD_OPT="--enable-offload-targets=nvptx-none=$INSTALL_PREFIX/nvptx-none"
171+
fi
172+
173+
(cd "$TEMP_DIR/staging/host-gcc"; "$TEMP_DIR/repositories/gcc/configure" \
174+
--host=`uname -m`-pc-linux-gnu \
175+
--build=`uname -m`-pc-linux-gnu \
176+
--target=`uname -m`-pc-linux-gnu \
177+
--prefix="$INSTALL_PREFIX" \
178+
--disable-multilib \
179+
--enable-languages=c,c++,fortran,lto \
180+
--disable-bootstrap \
181+
"$OFFLOAD_OPT")
182+
183+
make -j $JOBS \
184+
-C "$TEMP_DIR/staging/host-gcc"
185+
186+
make install \
187+
-j $JOBS \
188+
-C "$TEMP_DIR/staging/host-gcc"
189+
190+
rm -rf "$TEMP_DIR"

0 commit comments

Comments
 (0)