Commit efa9f2af authored by Christopher Subich's avatar Christopher Subich
Browse files

General-purpose makefile, with system-specific settings

in systems/ directory
parent a28322a0
......@@ -30,6 +30,8 @@ zgrid*
/UMFPACK
/UFconfig
/AMD
/include
/lib
# Also exclude blitz and fftw, if these are local to the build
......@@ -37,11 +39,14 @@ zgrid*
/fftw*
# And any tarballs
.tgz
.tar.gz
.tar
*.tgz
*.tar.gz
*.tar
# temporaries
*tmp/*
*tmp
# Exclude the system-specific make file
src/system.mk
......@@ -9,12 +9,12 @@
# This is a C++ "meta-template library" for arrays that allows
# manipulation of multidimensional arrays in C++ code with a
# MATLAB-like syntax
BUILD_BLITZ=yes
BUILD_BLITZ=no
# fftw -- www.fftw.org
# This is a self-contained library for high-performance Fast
# Fourier Transforms
BUILD_FFTW=yes
BUILD_FFTW=no
# UMFPACK -- www.cise.ufl.edu/research/sparse/umfpack
# AMD -- www.cise.ufl.edu/research/sparse/amd/
......@@ -26,25 +26,24 @@ BUILD_FFTW=yes
BUILD_UMFPACK=yes
# Some system configuration here will be necessary, since this
# script does not know your system's layout. Needed:
# C-compiler
CC=gcc
# C++ compiler
CXX=g++
# Linker
LD=ld
# Flags to link to BLAS
BLAS_LIB=-lblas
BLAS_DIR=
# Flags to link to LAPACK
LAPACK_LIB=-llapack
LAPACK_DIR=
# Read in the appropriate system script. If none is specified on the
# command line, guess based on the hostname
if [ $# -gt 0 ]; then
if [ -f $1 ]; then
echo Reading system-specific variables from $1
source $1
elif [ -f systems/$1.sh ]; then
echo Reading system-specific variables from systems/$1.sh
source systems/$1.sh
else
echo Neither $1 nor /systems/$1.sh are found!
exit 1
fi
else
echo Guessing that system-specific variables are in systems/`hostname -s`.sh
source systems/`hostname -s`.sh || (echo "... but they're not"; exit 1)
fi
# Current working directory
CWD=`pwd`
......@@ -120,8 +119,8 @@ else
cat UFconfig.mk | sed \
-e "s/^CC.*/CC = ${CC}/" \
-e "s/^CPLUSPLUS.*/CPLUSPLUS = ${CXX}/" \
-e "s/^BLAS.*/BLAS = ${BLAS_DIR} ${BLAS_LIB}/" \
-e "s/^LAPACK.*/LAPACK = ${LAPACK_DIR} ${LAPACK_LIB}/" \
-e "s/^BLAS.*/BLAS = ${BLAS_INCDIR} ${BLAS_LIBDIR} ${BLAS_LIB}/" \
-e "s/^LAPACK.*/LAPACK = ${LAPACK_INCDIR} ${LAPACK_LIBDIR} ${LAPACK_LIB}/" \
> UFconfig.new
mv UFconfig.new UFconfig.mk
popd
......@@ -139,6 +138,8 @@ else
cp Include/* ../include
cp Lib/* ../lib
popd
cp UFconfig/UFconfig.h ./include/
echo "Done!"
fi
CC = mpicc
CXX = mpicc
LD = mpicc
# -ip -ipo seem to give about 10% better speed, but they also double compile
# times. For now, disable them.
BLITZ_DEBUG = -g -DBZ_DEBUG #-ftrapuv -check-uninit
SLOW_OPTIM = -O3 -ffast-math #-ip -ipo
# Compile with all warnings, but disable some remarks. Notably:
# 1572-- "unreliable" == comparison of floating points
# 981 -- unspecified order of evaluation of operands
# 444 -- destructor is not virtual
# 383 -- value copied to temporary, reference to temporary used
# 869 -- parameter not referenced
INCLUDE_DIRS = -I../UMFPACK/Include -I../AMD/Include -I../UFconfig
CFLAGS = $(INCLUDE_DIRS) $(BLITZ_DEBUG) $(SLOW_OPTIM) #-Wall -wd981 -wd444 -wd1572 -wd383 -wd869
# disabling notifications for
# 11000 - performing multi-file optimizations
# 11005 - generating object file <temporary name>.o
LIB_DIRS = -L../UMFPACK/Lib -L../AMD/Lib #-L/opt/scsl/lib
LAPACK_LIB = -llapack
UMFPACK_LIB = -lumfpack -lamd
LDFLAGS = $(SLOW_OPTIM) #-wd11000,11005
LDLIBS = $(LIB_DIRS) -lfftw3 -lblitz -lm -lstdc++ -lmpi $(LAPACK_LIB) $(UMFPACK_LIB)
# Makefile to build SPINS, generalized for multiple systemd
# The "system.mk" file in the current directory will contain
# system-specific make variables, most notably the
# C/C++ compiler/linker,
include system.mk
# Compile with debugging flags
DEBUG=true
# Compile with optimizations
OPTIM=true
# Compile with extra optimizations that may require significantly
# longer for compilation
SLOW_OPTIM=true
# Assemble the CFLAGS
CFLAGS:=$(SYSTEM_CFLAGS)
LDFLAGS:=$(SYSTEM_LDFLAGS)
ifeq ($(DEBUG),true)
CFLAGS:=$(CFLAGS) $(DEBUG_CFLAGS)
LDFLAGS:=$(LDFLAGS) $(DEBUG_LDFLAGS)
endif
ifeq ($(OPTIM),true)
CFLAGS:=$(CFLAGS) $(OPTIM_CFLAGS)
LDFLAGS:=$(LDFLAGS) $(OPTIM_LDFLAGS)
ifeq ($(SLOW_OPTIM),true)
CFLAGS:=$(CFLAGS) $(EXTRA_OPTIM_CFLAGS)
LDFLAGS:=$(LDFLAGS) $(EXTRA_OPTIM_LDFLAGS)
endif
endif
INCLUDE_DIRS := $(MPI_INCDIR) $(LAPACK_INCDIR) $(BLITZ_INCDIR) $(FFTW_INCDIR) $(UMF_INCDIR) -I../include
CFLAGS := $(CFLAGS) $(INCLUDE_DIRS)
LIB_DIRS := $(MPI_LIBDIR) $(LAPACK_LIBDIR) $(BLITZ_LIBDIR) $(FFTW_LIBDIR) $(UMF_LIBDIR) -I../lib
LDLIBS := $(MPI_LIB) $(LAPACK_LIB) -lfftw3 -lblitz -lm -lstdc++ -lumfpack -lamd
LDFLAGS := $(LDFLAGS) $(LIB_DIRS)
.PHONY: all
all: tests/test_deriv_x tests/test_write_x tests/test_esolve_x tests/test_heat_x tests/test_ode_x tests/test_ns_x
......
#!/bin/bash
# System-specific settings for belize.math.uwaterloo.ca
CC=mpicc
CXX=mpicc
LD=mpicc
# System-specific compiler flags
SYSTEM_CFLAGS="-Wno-deprecated"
SYSTEM_LDFLAGS=
# Compiler flags for debugging
DEBUG_CFLAGS="-g -DBZ_DEBUG"
DEBUG_LDFLAGS=
# Compiler flags for optimization
OPTIM_CFLAGS="-O3 -ffast-math"
OPTIM_LDFLAGS=
# Compiler flags for extra optimization, such as -ip -ipo on icc
EXTRA_OPTIM_CFLAGS=
EXTRA_OPTIM_LDFLAGS=
# Library names/locations/flags for MPI-compilation. This will
# probably not be necessary on systems with a working mpicc
# alias
MPI_CFLAGS=
MPI_LIB=
MPI_LIBDIR=
MPI_INCDIR=
# Library names/locations for LAPACK
LAPACK_LIB="-llapack"
LAPACK_LIBDIR=
LAPACK_INCDIR=
# Library locations for blitz; leave blank to use system-installed
# or compiled-with-this-package version
BLITZ_LIBDIR=
BLITZ_INCDIR=
# Library locations for fftw
FFTW_LIBDIR=
FFTW_INCDIR=
# Library locations for UMFPACK
UMF_INCDIR=
UMF_LIBDIR=
# Location/library for BLAS
BLAS_LIB="-lblas"
BLAS_LIBDIR=
BLAS_INCDIR=
#!/bin/bash
# Helper script to generate an appropriate system.mk file, based on a
# configuration script in this directory
# Read in the appropriate system script. If none is specified on the
# command line, guess based on the hostname
if [ $# -gt 0 ]; then
if [ -f $1 ]; then
echo Reading system-specific variables from $1
source $1
elif [ -f $1.sh ]; then
echo Reading system-specific variables from $1.sh
source $1.sh
else
echo Neither $1 nor $1.sh are found!
exit 1
fi
else
echo Guessing that system-specific variables are in `hostname -s`.sh
source `hostname -s`.sh || (echo "But they're not"; exit 1)
fi
# Now, generate ../src/system.mk
echo "Generating ../src/system.mk"
cat > ../src/system.mk << EOF
# System-specific settings for `hostname -s`
# Compiler settings
CC:=$CC
CXX:=$CXX
LD:=$LD
# Compiler flags
SYSTEM_CFLAGS:=$SYSTEM_CFLAGS
SYSTEM_LDFLAGS:=$SYSTEM_LDFLAGS
# Debugging flags
DEBUG_CFLAGS:=$DEBUG_CFLAGS
DEBUG_LDFLAGSL=$DEBUG_LDFLAGS
# Optimization flags
OPTIM_CFLAGS:=$OPTIM_CFLAGS
OPTIM_LDFLAGS:=$OPTIM_LDFLAGS
# Extra-slow optimization flags
EXTRA_OPTIM_CFLAGS:=$EXTRA_OPTIM_CFLAGS
EXTRA_OPTIM_LDFLAGS:=$EXTRA_OPTIM_LDFLAGS
# Library names
# MPI
MPI_CFLAGS:=$MPI_CFLAGS
MPI_LIB:=$MPI_LIB
MPI_LIBDIR:=$MPI_LIBDIR
MPI_INCDIR:=$MPI_INCDIR
# LAPACK
LAPACK_LIB:=$LAPACK_LIB
LAPACK_LIBDIR:=$LAPACK_LIBDIR
LAPACK_INCDIR:=$LAPACK_INCDIR
# Blitz
BLITZ_LIBDIR:=$BLITZ_LIBDIR
BLITZ_INCDIR:=$BLITZ_INCDIR
# fftw
FFTW_LIBDIR:=$FFTW_LIBDIR
FFTW_INCDIR:=$FFTW_INCDIR
# UMFPack
UMF_LIBDIR:=$UMF_LIBDIR
UMF_INCDIR:=$UMF_INCDIR
# BLAS
BLAS_LIB:=$BLAS_LIB
BLAS_LIBDIR:=$BLAS_LIBDIR
BLAS_INCDIR:=$BLAS_INCDIR
EOF
#!/bin/bash
# System-specific settings for winisk.math.uwaterloo.ca
# This also doubles for kazan.math.uwaterloo.ca
CC=icc
CXX=icc
LD=icc
# System-specific compiler flags
SYSTEM_CFLAGS="-Wno-deprecated -Wall -wd981 -wd444 -wd1572 -wd383 -wd869"
SYSTEM_LDFLAGS=
# Compiler flags for debugging
DEBUG_CFLAGS="-g -DBZ_DEBUG"
DEBUG_LDFLAGS=
# Compiler flags for optimization
OPTIM_CFLAGS="-O3 -fpmodel fast=2"
OPTIM_LDFLAGS=
# Compiler flags for extra optimization, such as -ip -ipo on icc
EXTRA_OPTIM_CFLAGS="-ip -ipo"
EXTRA_OPTIM_LDFLAGS="-ip -ipo"
# Library names/locations/flags for MPI-compilation. This will
# probably not be necessary on systems with a working mpicc
# alias
MPI_CFLAGS=
MPI_LIB=-lmpi
MPI_LIBDIR=
MPI_INCDIR=
# Library names/locations for LAPACK
LAPACK_LIB=-lscs
LAPACK_LIBDIR=-L/opt/scsl/lib
LAPACK_INCDIR=
# Library locations for blitz; leave blank to use system-installed
# or compiled-with-this-package version
BLITZ_LIBDIR=
BLITZ_INCDIR=
# Library locations for fftw
FFTW_LIBDIR=
FFTW_INCDIR=
# Library locations for UMFPACK
UMF_INCDIR=
UMF_LIBDIR=
# Location/library for BLAS
BLAS_LIB=-lscs
BLAS_LIBDIR=-L/opt/scsl/lib
BLAS_INCDIR=
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment