Skip to content

Commit aa66ee9

Browse files
authored
Updates to build cleanly on NERSC:Perlmutter (#123)
* Add configuration for Perlmutter system * Update configuration files for building on Perlmutter-Intel * Ensure that BLAS configuration picks up Intel math library first * Add a simple alternative to figure out Fortran name mangling necessary for BLAS/LAPACK; by default, use lowercase_, but user can replace it with --with-fc-mangling='F_' to use uppercase_ etc. * Update conda_ubuntu_osx.yml Fixing github workflow configuration
1 parent 27c1d9e commit aa66ee9

File tree

6 files changed

+217
-169
lines changed

6 files changed

+217
-169
lines changed

.github/workflows/conda_ubuntu_osx.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,10 @@ jobs:
7474
run: |
7575
pwd
7676
export DYLD_LIBRARY_PATH=/Users/runner/miniconda3/envs/test-environment/lib:$DYLD_LIBRARY_PATH
77+
export PATH=/Users/runner/miniconda3/envs/test-environment/bin:$PATH
7778
which python
7879
ls -ltrh
79-
which autoreconf
80+
which ncdump h5dump autoreconf
8081
autoreconf -fi
8182
./configure --prefix=$HOME/tr_install --with-netcdf=/Users/runner/miniconda3/envs/test-environment --with-hdf5=/Users/runner/miniconda3/envs/test-environment --with-netcdf-include=/Users/runner/miniconda3/envs/test-environment/include --with-netcdf-lib=/Users/runner/miniconda3/envs/test-environment/lib
8283
make -j
@@ -86,8 +87,8 @@ jobs:
8687
run: |
8788
pwd
8889
echo $HOME
89-
# ls -ltrh /Users/runner/miniconda3/envs/test-environment/lib/
9090
export DYLD_LIBRARY_PATH=/Users/runner/miniconda3/envs/test-environment/lib:$DYLD_LIBRARY_PATH
91+
export PATH=/Users/runner/miniconda3/envs/test-environment/bin:$PATH
9192
# setting DYLD alone isn't enough, for each executables runtime path to lookup for libraries are required
9293
install_name_tool -add_rpath '/Users/runner/miniconda3/envs/test-environment/lib/' $HOME/tr_install/bin/GenerateCSMesh
9394
install_name_tool -add_rpath '@executable_path' $HOME/tr_install/bin/GenerateCSMesh

config/ax_blas.m4

Lines changed: 127 additions & 138 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# ===========================================================================
2+
# https://www.gnu.org/software/autoconf-archive/ax_blas.html
3+
# ===========================================================================
4+
#
15
# SYNOPSIS
26
#
37
# AX_BLAS([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]])
@@ -10,36 +14,29 @@
1014
#
1115
# To link with BLAS, you should link with:
1216
#
13-
# $BLAS_LIBS $LIBS
14-
#
15-
# in that order.
17+
# $BLAS_LIBS $LIBS $FLIBS
1618
#
17-
# To call a BLAS function, use the F77_FUNC macro, defined in config.h
19+
# in that order. FLIBS is the output variable of the
20+
# AC_F77_LIBRARY_LDFLAGS macro (called if necessary by AX_BLAS), and is
21+
# sometimes necessary in order to link with F77 libraries. Users will also
22+
# need to use AC_F77_DUMMY_MAIN (see the autoconf manual), for the same
23+
# reason.
1824
#
1925
# Many libraries are searched for, from ATLAS to CXML to ESSL. The user
2026
# may also use --with-blas=<lib> in order to use some specific BLAS
21-
# library <lib>.
27+
# library <lib>. In order to link successfully, however, be aware that you
28+
# will probably need to use the same Fortran compiler (which can be set
29+
# via the F77 env. var.) as was used to compile the BLAS library.
2230
#
2331
# ACTION-IF-FOUND is a list of shell commands to run if a BLAS library is
2432
# found, and ACTION-IF-NOT-FOUND is a list of commands to run it if it is
2533
# not found. If ACTION-IF-FOUND is not specified, the default action will
2634
# define HAVE_BLAS.
2735
#
28-
# This macro requires autoconf 2.50 or later.
29-
#
30-
# The macro is a modified version of ACX_BLAS, from the autoconf macro
31-
# archive. The original macro depends on a Fortran compiler, and this
32-
# version does not. This version has not been tested extensively, but
33-
# it is known to work with ATLAS and vecLib.
34-
#
35-
# LAST MODIFICATION
36+
# LICENSE
3637
#
37-
# 2008-12-29
38-
#
39-
# COPYLEFT
40-
#
41-
# Copyright (c) 2008 Patrick O. Perry <[email protected]>
4238
# Copyright (c) 2008 Steven G. Johnson <[email protected]>
39+
# Copyright (c) 2019 Geoffrey M. Oxberry <[email protected]>
4340
#
4441
# This program is free software: you can redistribute it and/or modify it
4542
# under the terms of the GNU General Public License as published by the
@@ -52,7 +49,7 @@
5249
# Public License for more details.
5350
#
5451
# You should have received a copy of the GNU General Public License along
55-
# with this program. If not, see <http://www.gnu.org/licenses/>.
52+
# with this program. If not, see <https://www.gnu.org/licenses/>.
5653
#
5754
# As a special exception, the respective Autoconf Macro's copyright owner
5855
# gives unlimited permission to copy, distribute and modify the configure
@@ -63,200 +60,192 @@
6360
# all other use of the material that constitutes the Autoconf Macro.
6461
#
6562
# This special exception to the GPL applies to versions of the Autoconf
66-
# Macro released by the Autoconf Macro Archive. When you make and
67-
# distribute a modified version of the Autoconf Macro, you may extend this
68-
# special exception to the GPL to apply to your modified version as well.
63+
# Macro released by the Autoconf Archive. When you make and distribute a
64+
# modified version of the Autoconf Macro, you may extend this special
65+
# exception to the GPL to apply to your modified version as well.
6966

67+
#serial 21
68+
69+
AU_ALIAS([ACX_BLAS], [AX_BLAS])
7070
AC_DEFUN([AX_BLAS], [
71-
AC_PREREQ([2.69])
71+
AC_PREREQ([2.55])
72+
AC_REQUIRE([AC_CANONICAL_HOST])
7273
ax_blas_ok=no
7374
7475
AC_ARG_WITH(blas,
75-
[AS_HELP_STRING([--with-blas=<lib>],[use BLAS library <lib>])])
76+
[AS_HELP_STRING([--with-blas=<lib>], [use BLAS library <lib>])])
7677
case $with_blas in
77-
yes | "") ;;
78-
no) acx_blas_ok=disable ;;
79-
-* | */* | *.a | *.so | *.so.* | *.o) BLAS_LIBS="$with_blas" ;;
80-
*) BLAS_LIBS="-l$with_blas" ;;
78+
yes | "") ;;
79+
no) ax_blas_ok=disable ;;
80+
-* | */* | *.a | *.so | *.so.* | *.dylib | *.dylib.* | *.o)
81+
BLAS_LIBS="$with_blas"
82+
;;
83+
*) BLAS_LIBS="-l$with_blas" ;;
8184
esac
8285
83-
_AX_BLAS(gemm_, [ax_blas_ok=yes; ax_blas_underscore=yes],
84-
[_AX_BLAS(gemm, [ax_blas_ok=yes; ax_blas_underscore=no],
85-
[_AX_BLAS(gemm__, [ax_blas_ok=yes; ax_blas_underscore=yes2])] )]
86-
)
87-
88-
AC_SUBST(BLAS_LIBS)
89-
DISTCHECK_CONFIGURE_FLAGS="$DISTCHECK_CONFIGURE_FLAGS --with-blas=$with_blas"
90-
if test x"$ax_blas_ok" = xyes; then
91-
ifelse([$1],, [
92-
AC_DEFINE(HAVE_BLAS,1, [Define if you have a BLAS library.])
93-
AH_TEMPLATE([F77_FUNC],
94-
[Define to a macro mangling the given Fortan function name])
95-
if test x"$ax_blas_underscore" = xyes; then
96-
AC_DEFINE([F77_FUNC(name)], [name ## _])
97-
else
98-
AC_DEFINE([F77_FUNC(name)], [name])
99-
fi
100-
],
101-
[$1])
102-
:
103-
else
104-
ax_blas_ok=no
105-
$2
106-
fi
107-
108-
])dnl AX_BLAS
109-
110-
111-
# _AX_BLAS(GEMM, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
112-
# --------------------------------------------------------
113-
# Look for a BLAS library in all of the standard places by checking for the
114-
# functions s$GEMM and d$GEMM. On success, define BLAS_LIBS, set
115-
# ax_blas_ok to yes, and execute ACTION-IF-FOUND. On failure, set ax_blas_ok
116-
# to no and execute ACTION-IF-NOT-FOUND.
117-
AC_DEFUN([_AX_BLAS], [
118-
AC_PREREQ([2.69])
119-
ax_blas_ok=no
120-
12186
# Get fortran linker names of BLAS functions to check for.
122-
sgemm=s$1
123-
dgemm=d$1
87+
#AC_F77_FUNC(daxpy)
88+
#AC_F77_FUNC(dgemm)
89+
#daxpy="daxpy DAXPY daxpy_ daxpy__ _daxpy DAXPY_ _DAXPY"
90+
#dgemm="dgemm DGEMM dgemm_ dgemm__ _dgemm DGEMM_ _DGEMM"
91+
#daxpy="daxpy_"
92+
#dgemm="dgemm_"
12493
12594
ax_blas_save_LIBS="$LIBS"
12695
LIBS="$LIBS $FLIBS"
12796
12897
# First, check BLAS_LIBS environment variable
12998
if test $ax_blas_ok = no; then
13099
if test "x$BLAS_LIBS" != x; then
131-
save_LIBS="$LIBS"; LIBS="$BLAS_LIBS $LIBS"
132-
AC_MSG_CHECKING([for $sgemm in $BLAS_LIBS])
133-
AC_TRY_LINK_FUNC($sgemm, [ax_blas_ok=yes], [BLAS_LIBS=""])
134-
AC_MSG_RESULT($ax_blas_ok)
135-
LIBS="$save_LIBS"
100+
save_LIBS="$LIBS"; LIBS="$BLAS_LIBS $LIBS"
101+
AC_MSG_CHECKING([for $daxpy in $BLAS_LIBS])
102+
AC_LINK_IFELSE([AC_LANG_CALL([], [$daxpy])], [ax_blas_ok=yes], [BLAS_LIBS=""])
103+
AC_MSG_RESULT($ax_blas_ok)
104+
LIBS="$save_LIBS"
136105
fi
137106
fi
138107
139108
# BLAS linked to by default? (happens on some supercomputers)
140109
if test $ax_blas_ok = no; then
141-
save_LIBS="$LIBS"; LIBS="$LIBS"
142-
AC_CHECK_FUNC($sgemm, [ax_blas_ok=yes])
143-
LIBS="$save_LIBS"
110+
save_LIBS="$LIBS"; LIBS="$LIBS"
111+
AC_MSG_CHECKING([if $daxpy is being linked in already])
112+
AC_LINK_IFELSE([AC_LANG_CALL([], [$daxpy])], [ax_blas_ok=yes])
113+
AC_MSG_RESULT($ax_blas_ok)
114+
LIBS="$save_LIBS"
144115
fi
145116
146-
# BLAS in ATLAS library? (http://math-atlas.sourceforge.net/)
117+
# BLAS linked to by flexiblas? (Default on FC33+ and RHEL9+)
118+
147119
if test $ax_blas_ok = no; then
148-
AC_CHECK_LIB(atlas, ATL_xerbla,
149-
[AC_CHECK_LIB(f77blas, $sgemm,
150-
[AC_CHECK_LIB(cblas, cblas_dgemm,
151-
[ax_blas_ok=yes
152-
BLAS_LIBS="-lcblas -lf77blas -latlas"],
153-
[], [-lf77blas -latlas])],
154-
[], [-latlas])])
120+
AC_CHECK_LIB(flexiblas, $daxpy, [ax_blas_ok=yes
121+
BLAS_LIBS="-lflexiblas"])
155122
fi
156123
157-
# BLAS in PhiPACK libraries? (requires generic BLAS lib, too)
124+
# BLAS in OpenBLAS library? (http://xianyi.github.com/OpenBLAS/)
158125
if test $ax_blas_ok = no; then
159-
AC_CHECK_LIB(blas, $sgemm,
160-
[AC_CHECK_LIB(dgemm, $dgemm,
161-
[AC_CHECK_LIB(sgemm, $sgemm,
162-
[ax_blas_ok=yes; BLAS_LIBS="-lsgemm -ldgemm -lblas"],
163-
[], [-lblas])],
164-
[], [-lblas])])
126+
AC_CHECK_LIB(openblas, $daxpy, [ax_blas_ok=yes
127+
BLAS_LIBS="-lopenblas"])
165128
fi
166129
167-
# BLAS in Intel MKL library?
130+
# BLAS in ATLAS library? (http://math-atlas.sourceforge.net/)
168131
if test $ax_blas_ok = no; then
169-
case $host_os in
170-
darwin*)
171-
AC_CHECK_LIB(mkl_intel_lp64, $sgemm,
172-
[ax_blas_ok=yes;BLAS_LIBS="-lmkl_intel_lp64 -lmkl_intel_thread -lmkl_core -liomp5 -lpthread"; OPENMP_LDFLAGS=""],,
173-
[-lmkl_intel_lp64 -lmkl_intel_thread -lmkl_core -liomp5 -lpthread])
174-
;;
175-
*)
176-
if test $host_cpu = x86_64; then
177-
AC_CHECK_LIB(mkl_intel_lp64, $sgemm,
178-
[ax_blas_ok=yes;BLAS_LIBS="-lmkl_intel_lp64 -lmkl_gnu_thread -lmkl_core -lgomp -lpthread -lm -ldl"],,
179-
[-lmkl_intel_lp64 -lmkl_gnu_thread -lmkl_core -lgomp -lpthread -lm -ldl])
180-
elif test $host_cpu = i686; then
181-
AC_CHECK_LIB(mkl_intel, $sgemm,
182-
[ax_blas_ok=yes;BLAS_LIBS="-lmkl_intel -lmkl_gnu_thread -lmkl_core -lgomp -lpthread -lm -ldl"],,
183-
[-lmkl_intel -lmkl_gnu_thread -lmkl_core -lgomp -lpthread -lm -ldl])
184-
fi
185-
;;
186-
esac
132+
AC_CHECK_LIB(atlas, ATL_xerbla,
133+
[AC_CHECK_LIB(f77blas, $daxpy,
134+
[AC_CHECK_LIB(cblas, cblas_dgemm,
135+
[ax_blas_ok=yes
136+
BLAS_LIBS="-lcblas -lf77blas -latlas"],
137+
[], [-lf77blas -latlas])],
138+
[], [-latlas])])
187139
fi
188140
189-
# BLAS in Intel MKL library?
141+
# BLAS in PhiPACK libraries? (requires generic BLAS lib, too)
190142
if test $ax_blas_ok = no; then
191-
AC_CHECK_LIB(mkl, $sgemm, [ax_blas_ok=yes;BLAS_LIBS="-lmkl"])
143+
AC_CHECK_LIB(blas, $daxpy,
144+
[AC_CHECK_LIB(dgemm, $dgemm,
145+
[AC_CHECK_LIB(daxpy, $daxpy,
146+
[ax_blas_ok=yes; BLAS_LIBS="-ldaxpy -ldgemm -lblas"],
147+
[], [-lblas])],
148+
[], [-lblas])])
192149
fi
193150
194151
# BLAS in Intel MKL library?
195152
if test $ax_blas_ok = no; then
196-
save_LDFLAGS="$LDFLAGS"; LDFLAGS="-L$MKLROOT/lib/intel64 $LDFLAGS"
197-
AC_CHECK_LIB(mkl_core, $sgemm, [ax_blas_ok=yes;BLAS_LIBS="-L$MKLROOT/lib/intel64 -lmkl_core"])
198-
LDFLAGS="$save_LDFLAGS"
153+
# MKL for gfortran
154+
if test x"$ac_cv_cxx_compiler_gnu" = xyes; then
155+
# 64 bit
156+
if test $host_cpu = x86_64; then
157+
AC_CHECK_LIB(mkl_gf_lp64, $daxpy,
158+
[ax_blas_ok=yes;BLAS_LIBS="-lmkl_gf_lp64 -lmkl_sequential -lmkl_core -lpthread"],,
159+
[-lmkl_gf_lp64 -lmkl_sequential -lmkl_core -lpthread])
160+
# 32 bit
161+
elif test $host_cpu = i686; then
162+
AC_CHECK_LIB(mkl_gf, $daxpy,
163+
[ax_blas_ok=yes;BLAS_LIBS="-lmkl_gf -lmkl_sequential -lmkl_core -lpthread"],,
164+
[-lmkl_gf -lmkl_sequential -lmkl_core -lpthread])
165+
fi
166+
# MKL for other compilers (Intel, PGI, ...?)
167+
else
168+
# 64-bit
169+
if test $host_cpu = x86_64; then
170+
AC_CHECK_LIB(mkl_intel_lp64, $daxpy,
171+
[ax_blas_ok=yes;BLAS_LIBS="-lmkl_intel_lp64 -lmkl_sequential -lmkl_core -limf -lpthread"],,
172+
[-lmkl_intel_lp64 -lmkl_sequential -lmkl_core -limf -lpthread])
173+
# 32-bit
174+
elif test $host_cpu = i686; then
175+
AC_CHECK_LIB(mkl_intel, $daxpy,
176+
[ax_blas_ok=yes;BLAS_LIBS="-lmkl_intel -lmkl_sequential -lmkl_core -limf -lpthread"],,
177+
[-lmkl_intel -lmkl_sequential -lmkl_core -limf -lpthread])
178+
fi
179+
fi
180+
fi
181+
# Old versions of MKL
182+
if test $ax_blas_ok = no; then
183+
AC_CHECK_LIB(mkl, $daxpy, [ax_blas_ok=yes;BLAS_LIBS="-lmkl -lguide -lpthread"],,[-lguide -lpthread])
199184
fi
200185
201186
# BLAS in Apple vecLib library?
202187
if test $ax_blas_ok = no; then
203-
save_LIBS="$LIBS"; LIBS="-framework vecLib $LIBS"
204-
AC_CHECK_FUNC($sgemm, [ax_blas_ok=yes;BLAS_LIBS="-framework vecLib"])
205-
LIBS="$save_LIBS"
188+
save_LIBS="$LIBS"; LIBS="-framework Accelerate $LIBS"
189+
AC_MSG_CHECKING([for $daxpy in -framework Accelerate])
190+
AC_LINK_IFELSE([AC_LANG_CALL([], [$daxpy])], [ax_blas_ok=yes;BLAS_LIBS="-framework Accelerate"])
191+
AC_MSG_RESULT($ax_blas_ok)
192+
LIBS="$save_LIBS"
206193
fi
207194
208195
# BLAS in Alpha CXML library?
209196
if test $ax_blas_ok = no; then
210-
AC_CHECK_LIB(cxml, $sgemm, [ax_blas_ok=yes;BLAS_LIBS="-lcxml"])
197+
AC_CHECK_LIB(cxml, $daxpy, [ax_blas_ok=yes;BLAS_LIBS="-lcxml"])
211198
fi
212199
213200
# BLAS in Alpha DXML library? (now called CXML, see above)
214201
if test $ax_blas_ok = no; then
215-
AC_CHECK_LIB(dxml, $sgemm, [ax_blas_ok=yes;BLAS_LIBS="-ldxml"])
202+
AC_CHECK_LIB(dxml, $daxpy, [ax_blas_ok=yes;BLAS_LIBS="-ldxml"])
216203
fi
217204
218205
# BLAS in Sun Performance library?
219206
if test $ax_blas_ok = no; then
220-
if test "x$GCC" != xyes; then # only works with Sun CC
221-
AC_CHECK_LIB(sunmath, acosp,
222-
[AC_CHECK_LIB(sunperf, $sgemm,
223-
[BLAS_LIBS="-xlic_lib=sunperf -lsunmath"
207+
if test "x$GCC" != xyes; then # only works with Sun CC
208+
AC_CHECK_LIB(sunmath, acosp,
209+
[AC_CHECK_LIB(sunperf, $daxpy,
210+
[BLAS_LIBS="-xlic_lib=sunperf -lsunmath"
224211
ax_blas_ok=yes],[],[-lsunmath])])
225-
fi
212+
fi
226213
fi
227214
228215
# BLAS in SCSL library? (SGI/Cray Scientific Library)
229216
if test $ax_blas_ok = no; then
230-
AC_CHECK_LIB(scs, $sgemm, [ax_blas_ok=yes; BLAS_LIBS="-lscs"])
217+
AC_CHECK_LIB(scs, $daxpy, [ax_blas_ok=yes; BLAS_LIBS="-lscs"])
231218
fi
232219
233220
# BLAS in SGIMATH library?
234221
if test $ax_blas_ok = no; then
235-
AC_CHECK_LIB(complib.sgimath, $sgemm,
236-
[ax_blas_ok=yes; BLAS_LIBS="-lcomplib.sgimath"])
222+
AC_CHECK_LIB(complib.sgimath, $daxpy,
223+
[ax_blas_ok=yes; BLAS_LIBS="-lcomplib.sgimath"])
237224
fi
238225
239226
# BLAS in IBM ESSL library? (requires generic BLAS lib, too)
240227
if test $ax_blas_ok = no; then
241-
AC_CHECK_LIB(blas, $sgemm,
242-
[AC_CHECK_LIB(essl, $sgemm,
243-
[ax_blas_ok=yes; BLAS_LIBS="-lessl -lblas"],
244-
[], [-lblas $FLIBS])])
228+
AC_CHECK_LIB(blas, $daxpy,
229+
[AC_CHECK_LIB(essl, $daxpy,
230+
[ax_blas_ok=yes; BLAS_LIBS="-lessl -lblas"],
231+
[], [-lblas $FLIBS])])
245232
fi
246233
247234
# Generic BLAS library?
248235
if test $ax_blas_ok = no; then
249-
AC_CHECK_LIB(blas, $sgemm, [ax_blas_ok=yes; BLAS_LIBS="-lblas"])
236+
AC_CHECK_LIB(blas, $daxpy, [ax_blas_ok=yes; BLAS_LIBS="-lblas"])
250237
fi
251238
239+
AC_SUBST(BLAS_LIBS)
240+
252241
LIBS="$ax_blas_save_LIBS"
253242
254243
# Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND:
255244
if test x"$ax_blas_ok" = xyes; then
256-
$2
257-
:
245+
ifelse([$1],,AC_DEFINE(HAVE_BLAS,1,[Define if you have a BLAS library.]),[$1])
246+
:
258247
else
259-
ax_blas_ok=no
260-
$3
248+
ax_blas_ok=no
249+
$2
261250
fi
262-
])dnl _AX_BLAS
251+
])dnl AX_BLAS

0 commit comments

Comments
 (0)