aboutsummaryrefslogtreecommitdiff
path: root/ur_optimize
blob: 2cf03398a50da34105556e3534975f6103702eed (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
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