Skip to content

Commit

Permalink
remove special intel_mp_fourier library; add intel compile instructio…
Browse files Browse the repository at this point in the history
…ns to setup.py
  • Loading branch information
dstndstn committed Nov 17, 2017
1 parent 9b11c75 commit 91015f7
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 57 deletions.
30 changes: 15 additions & 15 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
from distutils.core import setup, Extension
from distutils.command.build_ext import *
from distutils.dist import Distribution

# import sys
# py3 = (sys.version_info[0] >= 3)
import os

# from http://stackoverflow.com/questions/12491328/python-distutils-not-include-the-swig-generated-module
from distutils.command.build import build
Expand Down Expand Up @@ -58,22 +56,26 @@ class CustomBuild(build):
#extra_compile_args=['-O0','-g'],
#extra_link_args=['-O0', '-g'],

module_fourier = Extension('tractor._mp_fourier',
sources = ['tractor/mp_fourier.i'],
include_dirs = numpy_inc,
extra_compile_args=['-std=c99'],
extra_objects = [],
undef_macros=['NDEBUG'],
)

module_em = Extension('tractor._emfit',
sources = ['tractor/emfit.i' ],
include_dirs = numpy_inc,
extra_objects = [],
undef_macros=['NDEBUG'],
)
#extra_compile_args=['-O0','-g'],
#extra_link_args=['-O0', '-g'],

kwargs = {}
if os.environ.get('CC') == 'icc':
kwargs.update(extra_compile_args=['-g', '-xhost', '-axMIC-AVX512'],
extra_link_args=['-g', '-lsvml'])
else:
kwargs.update(extra_compile_args=['-g', '-std=c99'],
extra_link_args=['-g'])

module_fourier = Extension('tractor._mp_fourier',
sources = ['tractor/mp_fourier.i'],
include_dirs = numpy_inc,
undef_macros=['NDEBUG'],
**kwargs)

class MyDistribution(Distribution):
display_options = Distribution.display_options + [
Expand Down Expand Up @@ -101,8 +103,6 @@ class MyDistribution(Distribution):
author_email="[email protected]",
packages=['tractor', 'wise'],
ext_modules = mods,
# py_modules = pymods,
# data_files=[('lib/python/wise', ['wise/wise-psf-avg.fits'])],
package_data={'wise':['wise-psf-avg.fits', 'allsky-atlas.fits']},
package_dir={'wise':'wise', 'tractor':'tractor'},
url="http://theTractor.org/",
Expand Down
8 changes: 0 additions & 8 deletions tractor/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@ mpf: mp_fourier
mp_fourier: _mp_fourier$(PYTHON_SO_EXT) mp_fourier.py
.PHONY: mp_fourier

intel_mp_fourier: _intel_mp_fourier$(PYTHON_SO_EXT) #intel_mp_fourier.py
.PHONY: intel_mp_fourier

mix: _mix$(PYTHON_SO_EXT) mix.py
.PHONY: mix

Expand All @@ -25,17 +22,12 @@ emfit: _emfit$(PYTHON_SO_EXT) emfit.py
_mp_fourier$(PYTHON_SO_EXT): mp_fourier.i setup-mpf.py
$(PYTHON) setup-mpf.py build_ext --inplace

_intel_mp_fourier$(PYTHON_SO_EXT): mp_fourier.i setup-mpf.py
cat mp_fourier.i | sed s/mp_fourier/intel_mp_fourier/g > intel_mp_fourier.i
CC=icc $(PYTHON) setup-mpf.py build_ext --inplace

mix.py _mix$(PYTHON_SO_EXT): mix.i approx3.c gauss_masked.c setup-mix.py
$(PYTHON) setup-mix.py build_ext --inplace

_emfit$(PYTHON_SO_EXT): emfit.i emfit2.c setup-emfit.py
$(PYTHON) setup-emfit.py build_ext --inplace


NUMPY_INC := $(shell $(PYTHON) -c "from __future__ import print_function; from numpy.distutils.misc_util import get_numpy_include_dirs as d; print(' '.join('-I'+x for x in d()))")

PYMOD_LIB ?= -L$(shell $(PYTHON_CONFIG) --prefix)/lib $(shell $(PYTHON_CONFIG) --libs)
Expand Down
7 changes: 2 additions & 5 deletions tractor/mixture_profiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,9 @@
import numpy as np

try:
from tractor import intel_mp_fourier as mp_fourier
from tractor import mp_fourier
except:
try:
from tractor import mp_fourier
except:
mp_fourier = None
mp_fourier = None

from tractor.patch import Patch

Expand Down
10 changes: 0 additions & 10 deletions tractor/mp_fourier.i
Original file line number Diff line number Diff line change
Expand Up @@ -57,16 +57,6 @@

%inline %{

// #ifdef __INTEL_COMPILER
// #define RESTRICT restrict
// #else
// #define RESTRICT __restrict
// #endif

// #ifndef __INTEL_COMPILER
// #define restrict __restrict
// #endif

#if 0
} // fool emacs indenter
#endif
Expand Down
10 changes: 3 additions & 7 deletions tractor/psf.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,10 @@


try:
from tractor import intel_mp_fourier as mp_fourier
from tractor import mp_fourier
except:
print('tractor.psf: failed import intel version of mp_fourier library. Falling back to generic version.')
try:
from tractor import mp_fourier
except:
print('tractor.psf: failed import C version of mp_fourier library. Falling back to python version.')
mp_fourier = None
print('tractor.psf: failed to import C version of mp_fourier library. Falling back to python version.')
mp_fourier = None

def lanczos_shift_image(img, dx, dy, inplace=False, force_python=False):
from scipy.ndimage import correlate1d
Expand Down
22 changes: 10 additions & 12 deletions tractor/setup-mpf.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,18 @@

numpy_inc = get_numpy_include_dirs()

kwargs = {}
if os.environ.get('CC') == 'icc':
mpf_module = Extension('_intel_mp_fourier',
sources=['intel_mp_fourier.i'],
include_dirs=numpy_inc,
extra_compile_args=['-g', '-xhost', '-qopt-report=5', '-axMIC-AVX512'],
extra_link_args=['-g', '-lsvml']
)
kwargs.update(extra_compile_args=['-g', '-xhost', '-axMIC-AVX512'],
extra_link_args=['-g', '-lsvml'])
else:
mpf_module = Extension('_mp_fourier',
sources = ['mp_fourier.i' ],
include_dirs = numpy_inc,
extra_compile_args=['-g', '-std=c99'],
extra_link_args=['-g'],
)
kwargs.update(extra_compile_args=['-g', '-std=c99'],
extra_link_args=['-g'])

mpf_module = Extension('_mp_fourier',
sources = ['mp_fourier.i' ],
include_dirs = numpy_inc,
**kwargs)

setup(name = 'Gaussian mixtures -- Fourier transform',
version = '1.0',
Expand Down

0 comments on commit 91015f7

Please sign in to comment.