Skip to content

Commit 76576a8

Browse files
authored
Merge pull request #43 from computationalmodelling/origin/intel
Add better support for icc compilation
2 parents 9539fbc + 652cbe8 commit 76576a8

File tree

5 files changed

+124
-38
lines changed

5 files changed

+124
-38
lines changed

.travis.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ install:
2222
- source activate fidimag-test
2323
- pip install pyvtk six nbval
2424
# Download and compile FFTW & Sundials locally
25-
- bash bin/install.sh
25+
- bash bin/install-sundials-2.5.sh
26+
- bash bin/install-fftw.sh
2627

2728
before_script:
2829
- make build

bin/install-fftw.sh

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
#!/bin/bash
2+
3+
# This script installs FFTW locally. It may need to environment
4+
# variables to work, like 'export CC=gcc' in ARCHER.
5+
6+
FFTW=fftw-3.3.4
7+
8+
set -e
9+
10+
# Create target directory if needed.
11+
12+
HERE_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
13+
FIDIMAG_DIR="$(dirname "$HERE_DIR")"
14+
LIBS_DIR=${FIDIMAG_DIR}/local
15+
mkdir -p $LIBS_DIR
16+
cd ${LIBS_DIR}
17+
echo "Installing FFTW to "$LIBS_DIR"."
18+
echo "Using CC="$CC" "
19+
20+
download_and_install() {
21+
# $1 name of the package
22+
# $2 URL where ${1}.tar.gz can be obtained
23+
# $3 configure options
24+
if [ ! -e ${1}.tar.gz ]; then
25+
echo "Downloading "${1}"."
26+
wget -q ${2}/${1}.tar.gz
27+
fi;
28+
29+
if [ ! -e ${1} ]; then
30+
tar -xzf ${1}.tar.gz
31+
cd ${1}
32+
echo "Configuring "${1}"."
33+
./configure --quiet --enable-shared --prefix=${LIBS_DIR} $3
34+
echo "Compiling and installing "${1}"."
35+
{
36+
make
37+
make install
38+
} > /dev/null
39+
echo "Done."
40+
cd ${LIBS_DIR}
41+
fi;
42+
}
43+
44+
download_and_install ${FFTW} http://www.fftw.org "--enable-openmp --enable-avx"
45+
46+
echo "Installation succesful."

bin/install.sh renamed to bin/install-sundials-2.5.sh

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
#!/bin/bash
22

3-
# This script installs SUNDIALS and FFTW locally. It may need to environment
3+
# This script installs SUNDIALS locally. It may need to environment
44
# variables to work, like 'export CC=gcc' in ARCHER.
55

66
SUNDIALS=sundials-2.5.0
7-
FFTW=fftw-3.3.4
87

98
set -e
109

@@ -43,6 +42,5 @@ download_and_install() {
4342
}
4443

4544
download_and_install ${SUNDIALS} http://ftp.mcs.anl.gov/pub/petsc/externalpackages --disable-lapack
46-
download_and_install ${FFTW} http://www.fftw.org --enable-openmp
4745

4846
echo "Installation succesful."

bin/install-sundials.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,4 +61,4 @@ download_and_cmake_install() {
6161
download_and_cmake_install \
6262
${SUNDIALS} \
6363
http://computation.llnl.gov/projects/sundials-suite-nonlinear-differential-algebraic-equation-solvers/download \
64-
"-DBUILD_STATIC_LIBS=OFF -DBUILD_SHARED_LIBS=ON -DCMAKE_INSTALL_PREFIX="${LIBS_DIR}" -DEXAMPLES_ENABLE=OFF -DLAPACK_ENABLE=ON -DOPENMP_ENABLE=ON"
64+
"-DBUILD_STATIC_LIBS=OFF -DBUILD_SHARED_LIBS=ON -DCMAKE_INSTALL_PREFIX="${LIBS_DIR}" -DEXAMPLES_ENABLE=OFF -DLAPACK_ENABLE=ON -DOPENMP_ENABLE=ON --enable-sse2"

setup.py

Lines changed: 74 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
from Cython.Distutils import build_ext
44
from Cython.Build import cythonize
55
import numpy
6-
import fnmatch
76
import os
87
import glob
98
import re
@@ -22,15 +21,18 @@
2221
ATOM_DIR = os.path.join(SRC_DIR, "atomistic", "lib")
2322
MICRO_DIR = os.path.join(SRC_DIR, "micro", "lib")
2423
BARYAKHTAR_DIR = os.path.join(MICRO_DIR, "baryakhtar")
25-
DEMAG_DIR = os.path.join(SRC_DIR, "common","dipolar")
24+
DEMAG_DIR = os.path.join(SRC_DIR, "common", "dipolar")
2625

2726
LOCAL_DIR = os.path.join(MODULE_DIR, "local")
2827
INCLUDE_DIR = os.path.join(LOCAL_DIR, "include")
2928
LIB_DIR = os.path.join(LOCAL_DIR, "lib")
3029
print("LIB_DIR={}".format(LIB_DIR))
3130

3231

33-
pkg_init_path = os.path.join(os.path.dirname(__file__), 'fidimag', '__init__.py')
32+
pkg_init_path = os.path.join(
33+
os.path.dirname(__file__), 'fidimag', '__init__.py')
34+
35+
3436
def get_version():
3537
with open(pkg_init_path) as f:
3638
for line in f:
@@ -74,53 +76,92 @@ def glob_cfiles(path, excludes):
7476
dipolar_sources.append(os.path.join(DEMAG_DIR, 'dipolar.pyx'))
7577
dipolar_sources += glob_cfiles(DEMAG_DIR, excludes=["dipolar.c"])
7678

79+
com_libs = ['m', 'fftw3_omp', 'fftw3', 'sundials_cvodes',
80+
'sundials_nvecserial']
81+
82+
com_args = ['-std=c99']
83+
com_link = ['-L%s' % LIB_DIR]
84+
85+
if 'icc' in os.environ['CC']:
86+
com_args.append('-openmp')
87+
com_link.append('-openmp')
88+
else:
89+
com_args.append('-fopenmp')
90+
com_args.append('-fopenmp')
91+
92+
93+
com_inc = [numpy.get_include(), INCLUDE_DIR]
94+
7795
ext_modules = [
7896
Extension("fidimag.extensions.clib",
7997
sources=sources,
80-
include_dirs=[numpy.get_include(), INCLUDE_DIR],
81-
libraries=['m', 'fftw3_omp', 'fftw3',
82-
'sundials_cvodes', 'sundials_nvecserial'],
83-
extra_compile_args=["-fopenmp", '-std=c99'],
84-
extra_link_args=['-L%s' % LIB_DIR, '-fopenmp'],
98+
include_dirs=com_inc,
99+
libraries=com_libs,
100+
extra_compile_args=com_args,
101+
extra_link_args=com_link,
102+
),
103+
Extension("fidimag.extensions.cvode",
104+
sources=cvode_sources,
105+
include_dirs=com_inc,
106+
libraries=com_libs,
107+
extra_compile_args=com_args,
108+
extra_link_args=com_link,
109+
),
110+
Extension("fidimag.extensions.baryakhtar_clib",
111+
sources=baryakhtar_sources,
112+
include_dirs=com_inc,
113+
libraries=com_libs,
114+
extra_compile_args=com_args,
115+
extra_link_args=com_link,
116+
),
117+
Extension("fidimag.extensions.micro_clib",
118+
sources=micro_sources,
119+
include_dirs=com_inc,
120+
libraries=com_libs,
121+
extra_compile_args=com_args,
122+
extra_link_args=com_link,
123+
),
124+
Extension("fidimag.extensions.neb_clib",
125+
sources=neb_sources,
126+
include_dirs=com_inc,
127+
libraries=com_libs,
128+
extra_compile_args=com_args,
129+
extra_link_args=com_link,
85130
),
86131
Extension("fidimag.extensions.cvode",
87132
sources=cvode_sources,
88-
include_dirs=[numpy.get_include(), INCLUDE_DIR],
89-
libraries=[
90-
'm', 'fftw3', 'sundials_cvodes', 'sundials_nvecserial'],
91-
extra_compile_args=["-fopenmp", '-std=c99'],
92-
extra_link_args=['-L%s' % LIB_DIR, '-fopenmp'],
133+
include_dirs=com_inc,
134+
libraries=com_libs,
135+
extra_compile_args=com_args,
136+
extra_link_args=com_link,
93137
),
94138
Extension("fidimag.extensions.baryakhtar_clib",
95139
sources=baryakhtar_sources,
96-
include_dirs=[numpy.get_include(), INCLUDE_DIR],
97-
libraries=[
98-
'm', 'fftw3', 'sundials_cvodes', 'sundials_nvecserial'],
99-
extra_compile_args=["-fopenmp", '-std=c99'],
100-
extra_link_args=['-L%s' % LIB_DIR, '-fopenmp'],
140+
include_dirs=com_inc,
141+
libraries=com_libs,
142+
extra_compile_args=com_args,
143+
extra_link_args=com_link,
101144
),
102145
Extension("fidimag.extensions.micro_clib",
103146
sources=micro_sources,
104-
include_dirs=[numpy.get_include(), INCLUDE_DIR],
105-
libraries=[
106-
'm', 'fftw3', 'sundials_cvodes', 'sundials_nvecserial'],
107-
extra_compile_args=["-fopenmp", '-std=c99'],
108-
extra_link_args=['-L%s' % LIB_DIR, '-fopenmp'],
147+
include_dirs=com_inc,
148+
libraries=com_libs,
149+
extra_compile_args=com_args,
150+
extra_link_args=com_link,
109151
),
110152
Extension("fidimag.extensions.neb_clib",
111153
sources=neb_sources,
112-
include_dirs=[numpy.get_include(), INCLUDE_DIR],
113-
libraries=['m', 'fftw3_omp', 'fftw3',
114-
'sundials_cvodes', 'sundials_nvecserial'],
115-
extra_compile_args=["-fopenmp", '-std=c99'],
116-
extra_link_args=['-L%s' % LIB_DIR, '-fopenmp'],
154+
include_dirs=com_inc,
155+
libraries=com_libs,
156+
extra_compile_args=com_args,
157+
extra_link_args=com_link,
117158
),
118159
Extension("fidimag.extensions.dipolar",
119-
sources = dipolar_sources,
120-
include_dirs=[numpy.get_include(), INCLUDE_DIR],
121-
libraries=['m', 'fftw3_omp', 'fftw3'],
122-
extra_compile_args=["-fopenmp", '-std=c99'],
123-
extra_link_args=['-L%s' % LIB_DIR, '-fopenmp'],
160+
sources=dipolar_sources,
161+
include_dirs=com_inc,
162+
libraries=com_libs,
163+
extra_compile_args=com_args,
164+
extra_link_args=com_link,
124165
),
125166
]
126167

0 commit comments

Comments
 (0)