From 91015f73cb17d0fbf3d2c8204983e75b1f817173 Mon Sep 17 00:00:00 2001 From: Dustin Lang Date: Fri, 17 Nov 2017 15:30:03 -0500 Subject: [PATCH] remove special intel_mp_fourier library; add intel compile instructions to setup.py --- setup.py | 30 +++++++++++++++--------------- tractor/Makefile | 8 -------- tractor/mixture_profiles.py | 7 ++----- tractor/mp_fourier.i | 10 ---------- tractor/psf.py | 10 +++------- tractor/setup-mpf.py | 22 ++++++++++------------ 6 files changed, 30 insertions(+), 57 deletions(-) diff --git a/setup.py b/setup.py index 22a591ad..be3475dd 100644 --- a/setup.py +++ b/setup.py @@ -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 @@ -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 + [ @@ -101,8 +103,6 @@ class MyDistribution(Distribution): author_email="dstndstn@gmail.com", 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/", diff --git a/tractor/Makefile b/tractor/Makefile index bf74fb20..20775e6e 100644 --- a/tractor/Makefile +++ b/tractor/Makefile @@ -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 @@ -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) diff --git a/tractor/mixture_profiles.py b/tractor/mixture_profiles.py index e90a28bc..4e1e6a49 100755 --- a/tractor/mixture_profiles.py +++ b/tractor/mixture_profiles.py @@ -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 diff --git a/tractor/mp_fourier.i b/tractor/mp_fourier.i index 680a7958..b8df11c2 100644 --- a/tractor/mp_fourier.i +++ b/tractor/mp_fourier.i @@ -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 diff --git a/tractor/psf.py b/tractor/psf.py index caedd553..bb7643f3 100644 --- a/tractor/psf.py +++ b/tractor/psf.py @@ -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 diff --git a/tractor/setup-mpf.py b/tractor/setup-mpf.py index 76f1736b..696c87f3 100755 --- a/tractor/setup-mpf.py +++ b/tractor/setup-mpf.py @@ -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',