Commit 34138251 authored by Martin Reinecke's avatar Martin Reinecke
Browse files

improve Python packaging

parent 31dfac48
...@@ -92,9 +92,7 @@ void sharp_standard_alm_info::add_alm(size_t mi, const dcmplx *almtmp, const any ...@@ -92,9 +92,7 @@ void sharp_standard_alm_info::add_alm(size_t mi, const dcmplx *almtmp, const any
} }
ptrdiff_t sharp_standard_alm_info::index (size_t l, size_t mi) ptrdiff_t sharp_standard_alm_info::index (size_t l, size_t mi)
{ { return mvstart[mi]+stride*ptrdiff_t(l); }
return mvstart[mi]+stride*ptrdiff_t(l);
}
/* This currently requires all m values from 0 to nm-1 to be present. /* This currently requires all m values from 0 to nm-1 to be present.
It might be worthwhile to relax this criterion such that holes in the m It might be worthwhile to relax this criterion such that holes in the m
distribution are permissible. */ distribution are permissible. */
......
...@@ -135,7 +135,7 @@ void sharp_standard_geom_info::get_ring(bool weighted, size_t iring, const any & ...@@ -135,7 +135,7 @@ void sharp_standard_geom_info::get_ring(bool weighted, size_t iring, const any &
else if (map.type()==typeid(double *)) tget(weighted, iring, any_cast<double *>(map), ringtmp); else if (map.type()==typeid(double *)) tget(weighted, iring, any_cast<double *>(map), ringtmp);
else if (map.type()==typeid(const float *)) tget(weighted, iring, any_cast<const float *>(map), ringtmp); else if (map.type()==typeid(const float *)) tget(weighted, iring, any_cast<const float *>(map), ringtmp);
else if (map.type()==typeid(float *)) tget(weighted, iring, any_cast<float *>(map), ringtmp); else if (map.type()==typeid(float *)) tget(weighted, iring, any_cast<float *>(map), ringtmp);
else MR_assert(false,"bad map data type",map.type().name()); else MR_fail("bad map data type",map.type().name());
} }
unique_ptr<sharp_geom_info> sharp_make_subset_healpix_geom_info (size_t nside, ptrdiff_t stride, size_t nrings, unique_ptr<sharp_geom_info> sharp_make_subset_healpix_geom_info (size_t nside, ptrdiff_t stride, size_t nrings,
......
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <stdint.h>
/* f : number to convert.
* num, denom: returned parts of the rational.
* md: max denominator value. Note that machine floating point number
* has a finite resolution (10e-16 ish for 64 bit double), so specifying
* a "best match with minimal error" is often wrong, because one can
* always just retrieve the significand and return that divided by
* 2**52, which is in a sense accurate, but generally not very useful:
* 1.0/7.0 would be "2573485501354569/18014398509481984", for example.
*/
void rat_approx0(double f, int64_t md, int64_t *num, int64_t *denom)
{
/* a: continued fraction coefficients. */
int64_t h[3] = { 0, 1, 0 }, k[3] = { 1, 0, 0 };
if (md <= 1) { *denom = 1; *num = (int64_t) f; return; }
int neg = 0;
if (f < 0) { neg = 1; f = -f; }
int64_t n = 1;
while (f != floor(f)) { n <<= 1; f *= 2; }
int64_t d = f;
/* continued fraction and check denominator each step */
for (int i = 0; i < 64; i++) {
int64_t a = n ? d / n : 0;
if (i && !a) break;
int64_t x = d; d = n; n = x % n;
x = a;
if (k[1] * a + k[0] >= md) {
x = (md - k[0]) / k[1];
if (x * 2 >= a || k[1] >= md)
i = 65;
else
break;
}
h[2] = x * h[1] + h[0]; h[0] = h[1]; h[1] = h[2];
k[2] = x * k[1] + k[0]; k[0] = k[1]; k[1] = k[2];
}
*denom = k[1];
*num = neg ? -h[1] : h[1];
}
void rat_approx(double f, int64_t md, int64_t *num, int64_t *denom)
{
/* a: continued fraction coefficients. */
int64_t a, h[3] = { 0, 1, 0 }, k[3] = { 1, 0, 0 };
int64_t x, d, n = 1;
int i, neg = 0;
if (md <= 1) { *denom = 1; *num = (int64_t) f; return; }
if (f < 0) { neg = 1; f = -f; }
while (f != floor(f)) { n <<= 1; f *= 2; }
d = f;
/* continued fraction and check denominator each step */
for (i = 0; i < 64; i++) {
a = n ? d / n : 0;
if (i && !a) break;
x = d; d = n; n = x % n;
x = a;
if (k[1] * a + k[0] >= md) {
x = (md - k[0]) / k[1];
if (x * 2 >= a || k[1] >= md)
i = 65;
else
break;
}
h[2] = x * h[1] + h[0]; h[0] = h[1]; h[1] = h[2];
k[2] = x * k[1] + k[0]; k[0] = k[1]; k[1] = k[2];
}
*denom = k[1];
*num = neg ? -h[1] : h[1];
}
int tofrac(double x, size_t maxden, size_t *nom, size_t *den)
{
double startx = x;
/* initialize matrix */
long m[2][2];
m[0][0] = m[1][1] = 1;
m[0][1] = m[1][0] = 0;
/* loop finding terms until denom gets too big */
long ai;
while (m[1][0]*(ai=(long)x) + m[1][1] <= maxden)
{
long t = m[0][0] * ai + m[0][1];
m[0][1] = m[0][0];
m[0][0] = t;
t = m[1][0] * ai + m[1][1];
m[1][1] = m[1][0];
m[1][0] = t;
if(x==(double)ai) {printf("1\n");break;} // AF: division by zero
x = 1/(x - (double) ai);
if(x>(double)0x7FFFFFFF) {printf("2\n");break;} // AF: representation failure
}
*nom=m[0][0]; *den=m[1][0];
if (fabs(x-(*nom/ *den))<(1e-15*fabs(x)))
return 1;
else
return 0;
/* now remaining x is between 0 and 1/ai */
/* approx as either 0 or 1/m where m is max that will fit in maxden */
/* first try zero */
printf("%ld/%ld, error = %e\n", m[0][0], m[1][0],
startx - ((double) m[0][0] / (double) m[1][0]));
}
int main(void)
{
size_t num, den;
rat_approx(-27./67564.-1e-14,1<<30,&num, &den);
printf ("%d %d\n",(int)num,(int)den);
}
../Healpix_cxx/
\ No newline at end of file
prune mr_util
prune libsharp2
prune Healpix_cxx
include mr_util/threading.cc
include mr_util/geom_utils.cc
include mr_util/pointing.cc
include mr_util/string_utils.cc
include mr_util/space_filling.cc
include libsharp2/sharp.h
include libsharp2/sharp_internal.h
include libsharp2/sharp.cc
include libsharp2/sharp_core.cc
include libsharp2/sharp_core_inc.cc
include libsharp2/sharp_geomhelpers.cc
include libsharp2/sharp_almhelpers.cc
include libsharp2/sharp_geomhelpers.h
include libsharp2/sharp_almhelpers.h
include libsharp2/sharp_ylmgen.cc
include Healpix_cxx/healpix_base.cc
include Healpix_cxx/healpix_tables.cc
include mr_util/fft1d.h
include mr_util/mav.h
include mr_util/threading.h
include mr_util/math_utils.h
include mr_util/aligned_array.h
include mr_util/space_filling.h
include mr_util/gl_integrator.h
include mr_util/simd.h
include mr_util/rangeset.h
include mr_util/cmplx.h
include mr_util/string_utils.h
include mr_util/geom_utils.h
include mr_util/timers.h
include mr_util/pointing.h
include mr_util/vec3.h
include mr_util/constants.h
include mr_util/unity_roots.h
include mr_util/error_handling.h
include Healpix_cxx/healpix_base.h
include Healpix_cxx/healpix_tables.h
include mr_util/useful_macros.h
../libsharp2/
\ No newline at end of file
../mr_util/
\ No newline at end of file
...@@ -11,7 +11,7 @@ class _deferred_pybind11_include(object): ...@@ -11,7 +11,7 @@ class _deferred_pybind11_include(object):
return pybind11.get_include(self.user) return pybind11.get_include(self.user)
include_dirs = ['..', _deferred_pybind11_include(True), include_dirs = ['.', _deferred_pybind11_include(True),
_deferred_pybind11_include()] _deferred_pybind11_include()]
extra_compile_args = ['--std=c++17', '-march=native', '-ffast-math', '-O3'] extra_compile_args = ['--std=c++17', '-march=native', '-ffast-math', '-O3']
python_module_link_args = [] python_module_link_args = []
...@@ -26,7 +26,7 @@ if sys.platform == 'darwin': ...@@ -26,7 +26,7 @@ if sys.platform == 'darwin':
elif sys.platform == 'win32': elif sys.platform == 'win32':
extra_compile_args = ['/Ox', '/EHsc', '/std:c++17'] extra_compile_args = ['/Ox', '/EHsc', '/std:c++17']
else: else:
extra_compile_args += ['-Wfatal-errors', '-Wfloat-conversion', '-Wsign-conversion', '-Wconversion' ,'-W', '-Wall', '-Wstrict-aliasing=2', '-Wwrite-strings', '-Wredundant-decls', '-Woverloaded-virtual', '-Wcast-qual', '-Wcast-align', '-Wpointer-arith'] extra_compile_args += ['-Wfatal-errors', '-Wfloat-conversion','-W', '-Wall', '-Wstrict-aliasing=2', '-Wwrite-strings', '-Wredundant-decls', '-Woverloaded-virtual', '-Wcast-qual', '-Wcast-align', '-Wpointer-arith']
python_module_link_args += ['-march=native', '-ffast-math', '-Wl,-rpath,$ORIGIN'] python_module_link_args += ['-march=native', '-ffast-math', '-Wl,-rpath,$ORIGIN']
# if you don't want debugging info, add "-s" to python_module_link_args # if you don't want debugging info, add "-s" to python_module_link_args
...@@ -34,15 +34,15 @@ else: ...@@ -34,15 +34,15 @@ else:
def get_extension_modules(): def get_extension_modules():
return [Extension('pyHealpix', return [Extension('pyHealpix',
language='c++', language='c++',
sources=['pyHealpix.cc','../mr_util/threading.cc', sources=['pyHealpix.cc','mr_util/threading.cc',
'../mr_util/geom_utils.cc', '../mr_util/pointing.cc', 'mr_util/geom_utils.cc', 'mr_util/pointing.cc',
'../mr_util/string_utils.cc', '../mr_util/space_filling.cc', 'mr_util/string_utils.cc', 'mr_util/space_filling.cc',
'../libsharp2/sharp.cc', '../libsharp2/sharp_core.cc', '../libsharp2/sharp_geomhelpers.cc', 'libsharp2/sharp.cc', 'libsharp2/sharp_core.cc', 'libsharp2/sharp_geomhelpers.cc',
'../libsharp2/sharp_almhelpers.cc','../libsharp2/sharp_ylmgen.cc','../Healpix_cxx/healpix_base.cc', 'libsharp2/sharp_almhelpers.cc','libsharp2/sharp_ylmgen.cc','Healpix_cxx/healpix_base.cc',
'../Healpix_cxx/healpix_tables.cc'], 'Healpix_cxx/healpix_tables.cc'],
depends=['../mr_util/fft1d.h', '../mr_util/mav.h', '../mr_util/threading.h', depends=['mr_util/fft1d.h', 'mr_util/mav.h', 'mr_util/threading.h',
'../mr_util/aligned_array.h', '../mr_util/simd.h', 'mr_util/aligned_array.h', 'mr_util/simd.h',
'../mr_util/cmplx.h', '../mr_util/unity_roots.h', '../mr_util/error_handling.h', 'mr_util/cmplx.h', 'mr_util/unity_roots.h', 'mr_util/error_handling.h',
'setup.py'], 'setup.py'],
include_dirs=include_dirs, include_dirs=include_dirs,
......
prune mr_util
include mr_util/useful_macros.h
include mr_util/fft.h
include mr_util/fft1d.h
include mr_util/mav.h
include mr_util/threading.h
include mr_util/aligned_array.h
include mr_util/simd.h
include mr_util/cmplx.h
include mr_util/unity_roots.h
include mr_util/error_handling.h
include mr_util/threading.cc
../mr_util/
\ No newline at end of file
...@@ -709,6 +709,6 @@ PYBIND11_MODULE(pypocketfft, m) ...@@ -709,6 +709,6 @@ PYBIND11_MODULE(pypocketfft, m)
"out"_a=None, "nthreads"_a=1); "out"_a=None, "nthreads"_a=1);
static PyMethodDef good_size_meth[] = static PyMethodDef good_size_meth[] =
{{"good_size", good_size, METH_VARARGS, good_size_DS}, {0}}; {{"good_size", good_size, METH_VARARGS, good_size_DS}, {0, 0, 0, 0}};
PyModule_AddFunctions(m.ptr(), good_size_meth); PyModule_AddFunctions(m.ptr(), good_size_meth);
} }
...@@ -11,7 +11,7 @@ class _deferred_pybind11_include(object): ...@@ -11,7 +11,7 @@ class _deferred_pybind11_include(object):
return pybind11.get_include(self.user) return pybind11.get_include(self.user)
include_dirs = ['..', _deferred_pybind11_include(True), include_dirs = ['.', _deferred_pybind11_include(True),
_deferred_pybind11_include()] _deferred_pybind11_include()]
extra_compile_args = ['--std=c++14', '-march=native', '-ffast-math', '-O3'] extra_compile_args = ['--std=c++14', '-march=native', '-ffast-math', '-O3']
python_module_link_args = [] python_module_link_args = []
...@@ -36,10 +36,10 @@ else: ...@@ -36,10 +36,10 @@ else:
def get_extension_modules(): def get_extension_modules():
return [Extension('pypocketfft', return [Extension('pypocketfft',
language='c++', language='c++',
sources=['pypocketfft.cc','../mr_util/threading.cc'], sources=['pypocketfft.cc','mr_util/threading.cc'],
depends=['../mr_util/fft.h', '../mr_util/fft1d.h', '../mr_util/mav.h', '../mr_util/threading.h', depends=['mr_util/useful_macros.h', 'mr_util/fft.h', 'mr_util/fft1d.h', 'mr_util/mav.h', 'mr_util/threading.h',
'../mr_util/aligned_array.h', '../mr_util/simd.h', 'mr_util/aligned_array.h', 'mr_util/simd.h',
'../mr_util/cmplx.h', '../mr_util/unity_roots.h', '../mr_util/error_handling.h', 'mr_util/cmplx.h', 'mr_util/unity_roots.h', 'mr_util/error_handling.h',
'setup.py'], 'setup.py'],
include_dirs=include_dirs, include_dirs=include_dirs,
define_macros=define_macros, define_macros=define_macros,
......
prune mr_util
prune libsharp2
include mr_util/threading.cc
#include mr_util/geom_utils.cc
#include mr_util/pointing.cc
include mr_util/string_utils.cc
#include mr_util/space_filling.cc
include libsharp2/sharp.h
include libsharp2/sharp_internal.h
include libsharp2/sharp.cc
include libsharp2/sharp_core.cc
include libsharp2/sharp_core_inc.cc
include libsharp2/sharp_geomhelpers.cc
include libsharp2/sharp_almhelpers.cc
include libsharp2/sharp_geomhelpers.h
include libsharp2/sharp_almhelpers.h
include libsharp2/sharp_ylmgen.cc
include mr_util/fft1d.h
#include mr_util/mav.h
include mr_util/threading.h
include mr_util/math_utils.h
include mr_util/aligned_array.h
#include mr_util/space_filling.h
include mr_util/gl_integrator.h
include mr_util/simd.h
#include mr_util/rangeset.h
include mr_util/cmplx.h
include mr_util/string_utils.h
#include mr_util/geom_utils.h
include mr_util/timers.h
#include mr_util/pointing.h
#include mr_util/vec3.h
include mr_util/constants.h
include mr_util/unity_roots.h
include mr_util/error_handling.h
include mr_util/useful_macros.h
../libsharp2/
\ No newline at end of file
../mr_util/
\ No newline at end of file
...@@ -11,7 +11,7 @@ class _deferred_pybind11_include(object): ...@@ -11,7 +11,7 @@ class _deferred_pybind11_include(object):
return pybind11.get_include(self.user) return pybind11.get_include(self.user)
include_dirs = ['..', _deferred_pybind11_include(True), include_dirs = ['.', _deferred_pybind11_include(True),
_deferred_pybind11_include()] _deferred_pybind11_include()]
extra_compile_args = ['--std=c++17', '-march=native', '-ffast-math', '-O3'] extra_compile_args = ['--std=c++17', '-march=native', '-ffast-math', '-O3']
python_module_link_args = [] python_module_link_args = []
...@@ -34,12 +34,12 @@ else: ...@@ -34,12 +34,12 @@ else:
def get_extension_modules(): def get_extension_modules():
return [Extension('pysharp', return [Extension('pysharp',
language='c++', language='c++',
sources=['pysharp.cc','../mr_util/threading.cc','../mr_util/string_utils.cc', sources=['pysharp.cc','mr_util/threading.cc','mr_util/string_utils.cc',
'../libsharp2/sharp.cc', '../libsharp2/sharp_core.cc', '../libsharp2/sharp_geomhelpers.cc', 'libsharp2/sharp.cc', 'libsharp2/sharp_core.cc', 'libsharp2/sharp_geomhelpers.cc',
'../libsharp2/sharp_almhelpers.cc','../libsharp2/sharp_ylmgen.cc'], 'libsharp2/sharp_almhelpers.cc','libsharp2/sharp_ylmgen.cc'],
depends=['../mr_util/string_utils.h', '../mr_util/fft1d.h', '../mr_util/mav.h', '../mr_util/threading.h', depends=['mr_util/string_utils.h', 'mr_util/fft1d.h', 'mr_util/mav.h', 'mr_util/threading.h',
'../mr_util/aligned_array.h', '../mr_util/simd.h', 'mr_util/aligned_array.h', 'mr_util/simd.h',
'../mr_util/cmplx.h', '../mr_util/unity_roots.h', '../mr_util/error_handling.h', 'mr_util/cmplx.h', 'mr_util/unity_roots.h', 'mr_util/error_handling.h',
'setup.py'], 'setup.py'],
include_dirs=include_dirs, include_dirs=include_dirs,
......
Markdown is supported
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