Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New builder: SuperLU_MT #983

Merged
merged 9 commits into from
May 8, 2020
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
81 changes: 81 additions & 0 deletions S/SuperLU_MT/build_tarballs.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
# Note that this script can accept some limited command-line arguments, run
# `julia build_tarballs.jl --help` to see a usage message.
using BinaryBuilder

name = "SuperLU_MT"
version = v"3.1"

# Collection of sources required to build Elemental
sources = [
ArchiveSource("https://portal.nersc.gov/project/sparse/superlu/superlu_mt_3.1.tar.gz",
"407b544b9a92b2ed536b1e713e80f986824cf3016657a4bfc2f3e7d2a76ecab6"),
DirectorySource("bundled"),
]

# Bash recipe for building across all platforms
script = raw"""
cd SuperLU_MT_*

cp MAKE_INC/make.linux.openmp make.inc

atomic_patch -p1 ../patches/01-fix-makefile.patch

# Build object files suitable for a shared library, and link the libraries we need.
echo "CFLAGS += -fPIC -fopenmp \$(BLASLIB)" >> make.inc
echo "NOOPTS += -fPIC -fopenmp \$(BLASLIB)" >> make.inc

# On 64-bit systems, use 64-bit integers for indexing.
if [[ "$nbits" == 64 ]]; then
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we are building this for Sundials and modify Sundials to work with only 32-Bits

"
Moreover, since the superlumt library may be installed to support either 32-bit or 64-bit integers, it is assumed that the superlumt library is installed using the same integer precision as the sundials sunindextype option
"

cc. @ViralBShah

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I think it makes sense to make these binaries 32-bit only to avoid the 32/64-bit mess. @ChrisRackauckas fyi.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So we're doing 32-bit everywhere, and so the -D_LONGINT should go away?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, let's do that.

echo "CFLAGS += -D_LONGINT" >> make.inc
fi

# We need to add a suffix to BLAS symbols.
SYMBOLS=()
for fun in isamax sasum saxpy scopy strsv idamax dasum daxpy dcopy dtrsv ctrsv ztrsv; do
SYMBOLS+=("-D$fun=${fun}_")
done
echo "CFLAGS += ${SYMBOLS[@]}" >> make.inc

# Don't use 64-bit integers on non-64-bit systems.
if [[ "$nbits" != 64 ]]; then
sed -i "s/^CFLAGS.*+= -D_LONGINT$//" make.inc
fi

# Clang doesn't play nicely with OpenMP.
if [[ "$target" == *-freebsd* || "$target" == *-apple-* ]]; then
CC=gcc
fi

# Weird sed delimiters because some variables contain slashes.
sed -i "s~^BLASLIB.*~BLASLIB = -L$libdir -lopenblas~" make.inc
sed -i "s~^CC.*~CC = $CC~" make.inc
sed -i "s~^FORTRAN.*~FORTRAN = $FC~" make.inc

make superlulib "-j$nproc"
cp lib/single "$libdir/libsuperlumts.$dlext"
cp lib/double "$libdir/libsuperlumtd.$dlext"
cp lib/complex "$libdir/libsuperlumtc.$dlext"
cp lib/complex16 "$libdir/libsuperlumtz.$dlext"
cp SRC/*.h "$prefix/include"
"""

# These are the platforms we will build for by default, unless further
# platforms are passed in on the command line
platforms = supported_platforms()

# The products that we will ensure are always built
products = [
LibraryProduct("libsuperlumts", :libsuperlumts),
LibraryProduct("libsuperlumtd", :libsuperlumtd),
LibraryProduct("libsuperlumtc", :libsuperlumtc),
LibraryProduct("libsuperlumtz", :libsuperlumtz),
]

# Dependencies that must be installed before this package can be built
dependencies = [
Dependency("CompilerSupportLibraries_jll"),
Dependency("OpenBLAS32_jll"),
]

# Build the tarballs, and possibly a `build.jl` as well.
build_tarballs(ARGS, name, version, sources, script, platforms, products, dependencies)
42 changes: 42 additions & 0 deletions S/SuperLU_MT/bundled/patches/01-fix-makefile.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
diff --git a/SRC/Makefile b/SRC/Makefile
index 81209e5..83286b3 100644
--- a/SRC/Makefile
+++ b/SRC/Makefile
@@ -102,20 +102,16 @@ ZLUSRC = dcomplex.o zreadhb.o zreadrb.o zmatgen.o dzsum1.o izmax1.o \
all: single double complex complex16

single: $(SLUSRC) $(ALLAUX) $(SZAUX)
- $(ARCH) $(ARCHFLAGS) ../lib/$(SUPERLULIB) $(SLUSRC) $(ALLAUX) $(SZAUX)
- $(RANLIB) ../lib/$(SUPERLULIB)
+ $(CC) $(CFLAGS) -shared -o ../lib/single $(SLUSRC) $(ALLAUX) $(SZAUX)

double: $(DLUSRC) $(ALLAUX) $(DZAUX)
- $(ARCH) $(ARCHFLAGS) ../lib/$(SUPERLULIB) $(DLUSRC) $(ALLAUX) $(DZAUX)
- $(RANLIB) ../lib/$(SUPERLULIB)
+ $(CC) $(CFLAGS) -shared -o ../lib/double $(DLUSRC) $(ALLAUX) $(DZAUX)

complex: $(CLUSRC) $(ALLAUX) $(SZAUX)
- $(ARCH) $(ARCHFLAGS) ../lib/$(SUPERLULIB) $(CLUSRC) $(ALLAUX) $(SZAUX)
- $(RANLIB) ../lib/$(SUPERLULIB)
+ $(CC) $(CFLAGS) -shared -o ../lib/complex $(CLUSRC) $(ALLAUX) $(SZAUX)

complex16: $(ZLUSRC) $(ALLAUX) $(DZAUX)
- $(ARCH) $(ARCHFLAGS) ../lib/$(SUPERLULIB) $(ZLUSRC) $(ALLAUX) $(DZAUX)
- $(RANLIB) ../lib/$(SUPERLULIB)
+ $(CC) $(CFLAGS) -shared -o ../lib/complex16 $(ZLUSRC) $(ALLAUX) $(DZAUX)

##################################
# Do not optimize this routine #
@@ -127,10 +123,10 @@ dclock.o: dclock.c ; $(CC) -c $(PREDEFS) $(NOOPTS) $<

# Do not optimize this on Cray; related to 'volatile' variable.
await.o: await.c
- $(CC) -c $(NOOPTS) $< $(VERBOSE)
+ $(CC) -c $(NOOPTS) $<

.c.o:
- $(CC) $(CFLAGS) $(CDEFS) $(BLASDEF) -c $< $(VERBOSE)
+ $(CC) $(CFLAGS) $(CDEFS) $(BLASDEF) -c $<

clean:
rm -f *.o core ../lib/$(SUPERLULIB)