aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoseph Hunkeler <jhunkeler@gmail.com>2014-09-04 15:13:57 -0400
committerJoseph Hunkeler <jhunkeler@gmail.com>2014-09-04 15:13:57 -0400
commit6a9f20ca9b46d63dd15edda31ccaa98ea91ec606 (patch)
tree0df62795145f7da7c529cfdf949a9548e2695265
downloadur_optimize-6a9f20ca9b46d63dd15edda31ccaa98ea91ec606.tar.gz
Initial commit
-rwxr-xr-xur_optimize149
1 files changed, 149 insertions, 0 deletions
diff --git a/ur_optimize b/ur_optimize
new file mode 100755
index 0000000..2cf0339
--- /dev/null
+++ b/ur_optimize
@@ -0,0 +1,149 @@
+#!/bin/bash
+if [ ! -z "${UR_DIR}" ]; then
+ echo "UREKA must not be active."
+ exit 1
+fi
+
+export build_temp=/tmp/ur_optimize_build
+
+
+function init_optimize
+{
+ if [ -d "${PREFIX}" ]; then
+ echo "${PREFIX} exists. Abort."
+ exit 1
+ fi
+ mkdir -p ${PREFIX}
+ if (( $? > 0 )); then
+ exit $?
+ fi
+ if [ -d "${build_temp}" ]; then
+ deinit_optimize
+ fi
+ mkdir -p "${build_temp}"
+ cd "${build_temp}"
+}
+
+function deinit_optimize
+{
+ rm -rf "${build_temp}"
+}
+
+function stage_ATLAS
+{
+ local url="http://sourceforge.net/projects/math-atlas/files/Stable/3.10.2/atlas3.10.2.tar.bz2"
+ local tarball="$(basename ${url})"
+ wget "${url}"
+ tar xf "${tarball}"
+}
+
+function stage_LAPACK
+{
+ local url="http://www.netlib.org/lapack/lapack-3.5.0.tgz"
+ local tarball="$(basename ${url})"
+ wget "${url}"
+ #tar xf "${tarball}"
+}
+
+function build_ATLAS
+{
+ local BUILDROOT=`pwd`
+
+ stage_ATLAS
+ stage_LAPACK
+
+ cd ATLAS
+ mkdir -p BUILD && cd BUILD
+
+ ../configure --prefix=${PREFIX} \
+ --with-netlib-lapack-tarfile=${BUILDROOT}/lapack-3.5.0.tgz \
+ --shared \
+ -b 64 \
+ -Fa alg "-fPIC -Wl,-rpath=${PREFIX}/lib,--enable-new-dtags" \
+ -Si latune 1
+
+ make
+ make shared
+ make ptshared
+ make install
+
+ return $?
+}
+
+function build_modules
+{
+ export ATLAS="${PREFIX}"
+ export BLAS="${PREFIX}"
+ export LAPACK="${PREFIX}"
+
+ local packages=( numpy scipy )
+
+
+ for package in "${packages[@]}"
+ do
+ yes | pip uninstall ${package}
+ done
+
+ for package in "${packages[@]}"
+ do
+ yes | pip install --upgrade --force ${package}
+ done
+
+ return $?
+}
+
+
+NO_ARGS=0
+E_OPTERROR=85
+
+if [ $# -eq "$NO_ARGS" ]; then
+ echo "Usage: `basename $0` -p {ureka_installation_path}"
+ exit $E_OPTERROR
+fi
+
+while getopts ":p:" opt
+do
+ case $opt in
+ p)
+ export UREKA=${OPTARG}
+ ;;
+ :)
+ echo "-$OPTARG requires an argument (e.g. path to UREKA installation)"
+ ;;
+ esac
+done
+
+shift $(($OPTIND - 1))
+
+
+# Begin main script
+
+set -x
+export PREFIX="${UREKA}/ext"
+
+init_optimize
+
+build_ATLAS
+if (( $? > 0 )); then
+ echo "ATLAS build failed. Abort."
+ exit 1
+fi
+
+# Initialize UREKA for building modules
+eval `${UREKA}/bin/ur-setup-real -sh`
+
+# Configure build environment variables to avoid UREKA entirely
+# - ABSOLUTELY REQUIRED -
+export F77="gfortran"
+export F2C=""
+export CC="/usr/bin/gcc"
+export CXX="/usr/bin/g++"
+export CPP=${CXX}
+
+build_modules
+if (( $? > 0 )); then
+ echo "Python module builds failed. Abort."
+ exit 1
+fi
+
+deinit_optimize