@@ -8,6 +8,10 @@ set -eo pipefail
88readonly DEFAULT_CONDUIT=" ofi"
99readonly DEFAULT_SYSTEM_CONFIG=" slingshot11"
1010readonly DEFAULT_CUDA=" ON"
11+ # Threading suffix used by GASNet archives (libgasnet-<conduit>-<thread>.a)
12+ readonly DEFAULT_THREADING=" par"
13+ # Pinned GASNet commit (matches what we validated on Perlmutter)
14+ readonly GASNET_GITREF_SHA=" e0af36ac9d3d632824be1851bcb3bc23bf05e489"
1115
1216# Determine script directory dynamically
1317readonly SCRIPT_DIR=" ${CONDA_PREFIX} /gex-wrapper"
@@ -16,22 +20,25 @@ readonly SCRIPT_DIR="${CONDA_PREFIX}/gex-wrapper"
1620conduit=" ${DEFAULT_CONDUIT} "
1721system_config=" ${DEFAULT_SYSTEM_CONFIG} "
1822cuda=" ${DEFAULT_CUDA} "
23+ threading=" ${DEFAULT_THREADING} "
24+ extra_linker_flags=" "
1925
2026# Help function to display usage
2127gex_wrapper_help () {
22- echo " Usage: build-gex-wrapper [-h | --help] [-c conduit | --conduit conduit] [-s system_config | --system_config system_config] [-u ON/OFF | --use-cuda ON/OFF]"
28+ echo " Usage: build-gex-wrapper [-h | --help] [-c conduit | --conduit conduit] [-s system_config | --system_config system_config] [-u ON/OFF | --use-cuda ON/OFF] [-f flags | --linker-flags \" <flags> \" ] "
2329 echo " Build the Realm GASNet-EX wrapper in your conda environment."
2430 echo
2531 echo " Options:"
2632 echo " -h, --help Display this help and exit"
27- echo " -c, --conduit CONDUIT Specify the GASNet conduit to use (default '${DEFAULT_CONDUIT} ')"
28- echo " -s, --system_config SYS Specify the system -specific configuration (default '${DEFAULT_SYSTEM_CONFIG} ')"
33+ echo " -c, --conduit CONDUIT GASNet conduit to use (default '${DEFAULT_CONDUIT} ')"
34+ echo " -s, --system_config SYS System -specific configuration (default '${DEFAULT_SYSTEM_CONFIG} ')"
2935 echo " -u, --use-cuda ON/OFF Enable (ON) or disable (OFF) CUDA (default '${DEFAULT_CUDA} ')"
36+ echo " -f, --linker-flags STR Extra linker flags to append (default '-lhugetlbfs' when conduit='ofi' and system='slingshot11')"
3037 echo
3138}
3239
3340# Parse command-line options (supporting both single-dash and double-dash)
34- ARGS=$( getopt -o hc:s:u: -l help,conduit:,system_config:,use-cuda: -- " $@ " ) || {
41+ ARGS=$( getopt -o hc:s:u:f: -l help,conduit:,system_config:,use-cuda:,linker-flags : -- " $@ " ) || {
3542 gex_wrapper_help
3643 exit 1
3744}
@@ -59,6 +66,10 @@ while true; do
5966 fi
6067 shift 2
6168 ;;
69+ -f | --linker-flags)
70+ extra_linker_flags=" $2 "
71+ shift 2
72+ ;;
6273 --)
6374 shift
6475 break
@@ -71,11 +82,16 @@ while true; do
7182 esac
7283done
7384
85+ # Default linker flags for Perlmutter OFI/slingshot11, unless overridden
86+ if [[ -z " ${extra_linker_flags} " && " ${conduit} " == " ofi" && " ${system_config} " == " slingshot11" ]]; then
87+ extra_linker_flags=" -lhugetlbfs"
88+ fi
89+
7490# Ensure CONDA_PREFIX is set
7591if [[ -z " ${CONDA_PREFIX} " ]]; then
7692 echo " Error: Please activate a conda environment before running this script."
7793 echo " Run:"
78- echo " \ $ conda activate <your-env-name>"
94+ echo " $ conda activate <your-env-name>"
7995 echo " Then re-run this script."
8096 exit 1
8197fi
84100if ! command -v cmake & > /dev/null; then
85101 echo " Error: cmake is not installed or not in PATH."
86102 echo " Please install it via your package manager or conda:"
87- echo " \ $ conda install -c conda-forge cmake"
103+ echo " $ conda install -c conda-forge cmake"
88104 exit 1
89105fi
90106
@@ -110,19 +126,35 @@ CMAKE_ARGS=(
110126 -DGASNet_CONDUIT=" ${conduit} "
111127 -DGASNet_SYSTEM=" ${system_config} "
112128 -DGEX_WRAPPER_BUILD_SHARED=ON
129+ -DGASNet_GITREF=" ${GASNET_GITREF_SHA} "
113130)
114131
115132if [[ " ${cuda} " == " ON" ]]; then
116133 CMAKE_ARGS+=(-DGASNet_CONFIGURE_ARGS=" --enable-kind-cuda-uva" )
117134fi
118135
136+ # Whole-archive embed of the conduit archive into the wrapper DSO.
137+ # Note: libgasnet-<conduit>-par.a already contains gasnet_tools, so do NOT also
138+ # link libgasnet_tools-par.a to avoid duplicate symbols.
139+ GASNET_LIBDIR_EMBED=" ${SCRIPT_DIR} /src/build/embed-gasnet/install/lib"
140+ MAIN_A=" ${GASNET_LIBDIR_EMBED} /libgasnet-${conduit} -${threading} .a"
141+ LINK_FLAGS=(" -Wl,--whole-archive,${MAIN_A} ,-no-whole-archive" )
142+
143+ if [[ -n " ${extra_linker_flags} " ]]; then
144+ read -r -a extra_linker_flags_array <<< " ${extra_linker_flags}"
145+ LINK_FLAGS+=(" ${extra_linker_flags_array[@]} " )
146+ fi
147+
148+ CMAKE_ARGS+=(-DCMAKE_SHARED_LINKER_FLAGS=" ${LINK_FLAGS[*]} " )
149+
119150cmake " ${CMAKE_ARGS[@]} " ..
120151cmake --build .
121152cmake --install .
122153
123154echo
124155echo " Reactivate the conda environment to set necessary environment variables:"
125156echo
126- echo " \$ conda deactivate"
127157# shellcheck disable=SC2154
128- echo " \$ conda activate ${CONDA_DEFAULT_ENV} "
158+ echo " $ conda deactivate"
159+ # shellcheck disable=SC2154
160+ echo " $ conda activate ${CONDA_DEFAULT_ENV} "
0 commit comments