@@ -12,6 +12,13 @@ USAGE:
1212
1313 --help Display this help text
1414 --prefix=PREFIX Install library into 'PREFIX' directory
15+ --network=<NET> Build Caffeine to target given GASNet network conduit.
16+ <NET> should be one of:
17+ smp: single-node shared-memory conduit (default)
18+ udp: portable UDP/IP (for Ethernet networks)
19+ ibv: InfiniBand IB Verbs
20+ ofi: OpenFabrics Interfaces
21+ ucx: Unified Communication X
1522 --prereqs Display a list of prerequisite software.
1623 Default prefix='\$HOME/.local/bin'
1724 --verbose Show verbose build commands
4350GCC_VERSION=${GCC_VERSION:= 14}
4451GASNET_VERSION=" stable"
4552VERBOSE=" "
53+ GASNET_CONDUIT=" ${GASNET_CONDUIT:- smp} "
4654
4755list_prerequisites ()
4856{
@@ -82,6 +90,16 @@ while [ "$1" != "" ]; do
8290 --prefix)
8391 PREFIX=$VALUE
8492 ;;
93+ --network)
94+ GASNET_CONDUIT=$( tr ' [:upper:]' ' [:lower:]' <<< $VALUE )
95+ case $GASNET_CONDUIT in
96+ smp|udp|mpi|ibv|ofi|ucx) ;;
97+ * )
98+ echo " ERROR: Unrecognized --network=$GASNET_CONDUIT "
99+ print_usage_info
100+ exit 1
101+ esac
102+ ;;
85103 --verbose)
86104 VERBOSE=" --verbose"
87105 set -x
304322 printf " Is it ok to download and install $1 ? [yes] "
305323}
306324
307- # TODO: Expand this to other GASNet conduits (issue #66)
308- GASNET_CONDUIT=smp
309325pkg=" gasnet-$GASNET_CONDUIT -seq"
310326export PKG_CONFIG_PATH
311327
@@ -337,8 +353,8 @@ if ! $PKG_CONFIG $pkg ; then
337353 cmd=" $cmd --enable-$GASNET_CONDUIT "
338354 cmd=" $cmd --enable-seq --disable-par --disable-parsync"
339355 cmd=" $cmd --disable-segment-everything"
340- # TEMPORARY: disable MPI compatibility until Caffeine supports distributed conduits
341- cmd=" $cmd --without-mpicc "
356+ # TEMPORARY: disable MPI compatibility until we figure out how to support in fpm
357+ cmd=" $cmd --disable-mpi-compat "
342358 eval $cmd
343359 $MAKE -j 8 all
344360 $MAKE -j 8 install
@@ -366,6 +382,7 @@ GASNET_CPPFLAGS="`$PKG_CONFIG $pkg --variable=GASNET_CPPFLAGS`"
366382# in the directory path, and assumes that the first directory returned
367383# by pkg-config contains the GASNet lib directory
368384GASNET_LIBDIR=" $( echo $GASNET_LIBS | awk ' {print $1};' ) "
385+ GASNET_LIBDIR=${GASNET_LIBDIR# -L}
369386case " $GASNET_LIBDIR " in
370387 * spack* )
371388 cat << EOF
378395 exit 1
379396 ;;
380397 * )
381- ;; # Do nothing otherwise
398+ GASNET_PREFIX=$( dirname $GASNET_LIBDIR )
399+ if [ ! -r " $GASNET_PREFIX /include/gasnetex.h" ] ; then
400+ echo " ERROR: Failed to detect GASNet install prefix from $GASNET_LIBS "
401+ exit 1
402+ fi
403+ ;;
382404esac
383405
384406# Strip compiler flags
@@ -395,6 +417,9 @@ echo "# DO NOT EDIT OR COMMIT -- Created by caffeine/install.sh" > build/fpm.tom
395417cp manifest/fpm.toml.template build/fpm.toml
396418GASNET_LIB_LOCATIONS=` echo $GASNET_LIBS | awk ' {locs=""; for(i = 1; i <= NF; i++) if ($i ~ /^-L/) {locs=(locs " " $i);}; print locs; }' `
397419GASNET_LIB_NAMES=` echo $GASNET_LIBS | awk ' {names=""; for(i = 1; i <= NF; i++) if ($i ~ /^-l/) {names=(names " " $i);}; print names; }' | sed ' s/-l//g' `
420+ if [[ $GASNET_CONDUIT == " udp" ]] ; then
421+ GASNET_LIB_NAMES+=" stdc++" # udp-conduit requires C++ libraries
422+ fi
398423FPM_TOML_LINK_ENTRY=" link = [\" $( echo ${GASNET_LIB_NAMES} | sed ' s/ /", "/g' ) \" ]"
399424echo " ${FPM_TOML_LINK_ENTRY} " >> build/fpm.toml
400425ln -f -s build/fpm.toml
@@ -428,9 +453,30 @@ if ! [[ "$user_compiler_flags " =~ -[DU]ASSERTIONS[=\ ] ]] ; then
428453 compiler_flag+=" -DASSERTIONS"
429454fi
430455
456+ GASNET_CONDUIT_UPPER=$( tr ' [:lower:]' ' [:upper:]' <<< $GASNET_CONDUIT )
457+ compiler_flag+=" -DCAF_NETWORK_$GASNET_CONDUIT_UPPER "
458+
431459# Should come last to allow command-line overrides
432460compiler_flag+=" $user_compiler_flags "
433461
462+ case $GASNET_CONDUIT in
463+ ibv|ofi|ucx)
464+ GASNET_RUNNER_ARG=" ${GASNET_RUNNER_ARG:- $GASNET_PREFIX / bin/ gasnetrun_$GASNET_CONDUIT -n \$ {CAF_IMAGES:- 2} }"
465+ ;;
466+ udp)
467+ GASNET_RUNNER_ARG=" ${GASNET_RUNNER_ARG:- $GASNET_PREFIX / bin/ amudprun -n \$ {CAF_IMAGES:- 2} }"
468+ ;;
469+ mpi)
470+ GASNET_RUNNER_ARG=" ${GASNET_RUNNER_ARG:- mpirun -n \$ {CAF_IMAGES:- 2} }"
471+ ;;
472+ smp)
473+ GASNET_RUNNER_ARG=" ${GASNET_RUNNER_ARG:- env GASNET_PSHM_NODES=\$ {CAF_IMAGES:- \$ {GASNET_PSHM_NODES:- } }}"
474+ ;;
475+ * )
476+ GASNET_RUNNER_ARG=" ${GASNET_RUNNER_ARG:- } "
477+ ;;
478+ esac
479+
434480RUN_FPM_SH=" build/run-fpm.sh"
435481cat << EOF > $RUN_FPM_SH
436482#!/bin/sh
@@ -441,6 +487,10 @@ if echo "--help -help --version -version --list -list new update list clean publ
441487 set -x
442488 exec \$ fpm "\$ fpm_sub_cmd" "\$ @"
443489elif echo "build test run install" | grep -w -q -e "\$ fpm_sub_cmd" ; then
490+ sed -i.bak 's/^link = .*\$ /$FPM_TOML_LINK_ENTRY /' build/fpm.toml
491+ if test -n "$GASNET_RUNNER_ARG " && echo "test run" | grep -w -q -e "\$ fpm_sub_cmd" ; then
492+ set -- "--runner=$GASNET_RUNNER_ARG " "\$ @"
493+ fi
444494 set -x
445495 exec \$ fpm "\$ fpm_sub_cmd" \\
446496 --profile debug \\
0 commit comments