Commit 736d7e43 authored by Martin Reinecke's avatar Martin Reinecke
Browse files

cleanup and better get_w()

parent 734ea4dd
......@@ -247,7 +247,17 @@ a_i_c peanoindex(const a_d_c &uv_, int nu, int nv)
}
int get_w(double epsilon)
{ return int(-log10(epsilon)+2.9999); }
{
static const vector<double> maxmaperr { 1e8, 0.32, 0.021, 6.2e-4,
1.08e-5, 1.25e-7, 8.25e-10, 5.70e-12, 1.22e-13, 2.48e-15, 4.82e-17,
6.74e-19, 5.41e-21, 4.41e-23, 7.88e-25, 3.9e-26 };
double epssq = epsilon*epsilon;
for (size_t i=1; i<maxmaperr.size(); ++i)
if (epssq>maxmaperr[i]) return i;
throw runtime_error("requested epsilon too small - minimum is 2e-13");
}
class Helper
{
......
from setuptools import setup, Extension, Distribution
import setuptools.command.build_ext
from setuptools import setup, Extension
import sys
import sysconfig
import os
import os.path
import distutils.sysconfig
import itertools
from glob import iglob
def _get_distutils_build_directory():
"""
Returns the directory distutils uses to build its files.
We need this directory since we build extensions which have to link
other ones.
"""
pattern = "lib.{platform}-{major}.{minor}"
return os.path.join(
'build', pattern.format(platform=sysconfig.get_platform(),
major=sys.version_info[0],
minor=sys.version_info[1]))
class _deferred_pybind11_include(object):
......@@ -32,68 +11,29 @@ class _deferred_pybind11_include(object):
return pybind11.get_include(self.user)
def _get_cc_files(directory):
path = directory
iterable_sources = (iglob(os.path.join(root, '*.cc'))
for root, dirs, files in os.walk(path))
source_files = itertools.chain.from_iterable(iterable_sources)
return list(source_files)
def _remove_strict_prototype_option_from_distutils_config():
strict_prototypes = '-Wstrict-prototypes'
config = distutils.sysconfig.get_config_vars()
for key, value in config.items():
if strict_prototypes in str(value):
config[key] = config[key].replace(strict_prototypes, '')
_remove_strict_prototype_option_from_distutils_config()
extra_compile_args = []
openmp_libs = []
extra_cc_compile_args = []
include_dirs = ['./', _deferred_pybind11_include(),
_deferred_pybind11_include(True)]
library_dirs = [_get_distutils_build_directory()]
python_module_link_args = []
base_library_link_args = []
if sys.platform == 'darwin':
extra_cc_compile_args.append('--std=c++14')
extra_cc_compile_args.append('--stdlib=libc++')
extra_compile_args.append('-mmacosx-version-min=10.9')
import distutils.sysconfig
extra_compile_args += ['--std=c++14', '--stdlib=libc++', '-mmacosx-version-min=10.9']
vars = distutils.sysconfig.get_config_vars()
vars['LDSHARED'] = vars['LDSHARED'].replace('-bundle', '')
python_module_link_args.append('-bundle')
builder = setuptools.command.build_ext.build_ext(Distribution())
base_library_link_args.append('-dynamiclib')
python_module_link_args+=['-bundle']
else:
extra_compile_args += ['-fopenmp', '-march=native', '-O3', '-ffast-math']
python_module_link_args += ['-fopenmp', '-march=native']
extra_cc_compile_args.append('--std=c++14')
python_module_link_args.append("-Wl,-rpath,$ORIGIN")
extra_cc_compile_args = extra_compile_args + extra_cc_compile_args
extra_compile_args += ['--std=c++14', '-fopenmp', '-march=native', '-O3', '-ffast-math']
python_module_link_args += ['-fopenmp', '-march=native', '-Wl,-rpath,$ORIGIN']
def get_extension_modules():
extension_modules = []
gridder_sources = _get_cc_files('.')
gridder_library = Extension('nifty_gridder',
sources=gridder_sources,
include_dirs=include_dirs,
extra_compile_args=extra_cc_compile_args,
extra_link_args=python_module_link_args,
library_dirs=library_dirs)
extension_modules.append(gridder_library)
return extension_modules
return [Extension('nifty_gridder',
sources=['nifty_gridder.cc'],
include_dirs=include_dirs,
extra_compile_args=extra_compile_args,
extra_link_args=python_module_link_args)]
setup(name='nifty_gridder',
version='0.0.1',
......@@ -102,7 +42,7 @@ setup(name='nifty_gridder',
author='Martin Reinecke',
author_email='martin@mpa-garching.mpg.de',
packages=[],
setup_requires=['numpy>=1.10.4', 'pybind11>=2.2.1'],
setup_requires=['numpy>=1.15.0', 'pybind11>=2.2.4'],
ext_modules=get_extension_modules(),
install_requires=['numpy>=1.10.4', 'pybind11>=2.2.1']
install_requires=['numpy>=1.15.0', 'pybind11>=2.2.4']
)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment