Skip to content

Commit abd2273

Browse files
authored
Merge pull request #1 from serge-sans-paille/master
Merge upstream into master
2 parents 30193b7 + 341818b commit abd2273

File tree

4,964 files changed

+157906
-169586
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

4,964 files changed

+157906
-169586
lines changed

.appveyor.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
image:
2-
- Previous Visual Studio 2017
2+
- Visual Studio 2017
33

44
platform:
55
- x64

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ website/*.html
66
website/license.txt
77
pythran/nt2
88
pythran/boost
9+
pythran/xsimd
910
parsetab.py
1011

1112
.eggs/*

.travis.yml

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ addons:
1212
- g++-5
1313
- clang-3.5
1414
- clang-format-3.6
15-
- libgmp-dev
1615
- libatlas-base-dev
1716

1817
install:
@@ -22,31 +21,31 @@ install:
2221

2322
env:
2423
- CC=clang-3.5 CXX=clang++-3.5 CXXFLAGS=-g TESTCASE='pythran/tests/test_[ab]*.py pythran/tests/test_c[b-z]*.py pythran/tests/test_numpy_[a-eg-r]*.py pythran/tests/test_numpy_f[a-t]*.py'
25-
- CC=clang-3.5 CXX=clang++-3.5 CXXFLAGS="-DUSE_BOOST_SIMD -march=native" TESTCASE='pythran/tests/test_[ab]*.py pythran/tests/test_c[b-z]*.py pythran/tests/test_numpy_[a-eg-r]*.py pythran/tests/test_numpy_f[a-t]*.py'
24+
- CC=clang-3.5 CXX=clang++-3.5 CXXFLAGS="-DUSE_XSIMD -march=native" TESTCASE='pythran/tests/test_[ab]*.py pythran/tests/test_c[b-z]*.py pythran/tests/test_numpy_[a-eg-r]*.py pythran/tests/test_numpy_f[a-t]*.py'
2625
- CC=gcc-5 CXX=g++-5 CXXFLAGS="-fopenmp" TESTCASE='pythran/tests/test_[ab]*.py pythran/tests/test_c[b-z]*.py pythran/tests/test_numpy_[a-eg-r]*.py pythran/tests/test_numpy_f[a-t]*.py'
2726

2827
- CC=clang-3.5 CXX=clang++-3.5 CXXFLAGS=-g TESTCASE='pythran/tests/test_ca*.py'
29-
- CC=clang-3.5 CXX=clang++-3.5 CXXFLAGS="-DUSE_BOOST_SIMD -march=native" TESTCASE='pythran/tests/test_ca*.py'
28+
- CC=clang-3.5 CXX=clang++-3.5 CXXFLAGS="-DUSE_XSIMD -march=native" TESTCASE='pythran/tests/test_ca*.py'
3029
- CC=gcc-5 CXX=g++-5 CXXFLAGS="-fopenmp" TESTCASE='pythran/tests/test_ca*.py'
31-
- CC=gcc-5 CXX=g++-5 CXXFLAGS="-DUSE_BOOST_SIMD -march=native -fopenmp" TESTCASE='pythran/tests/test_ca*.py'
30+
- CC=gcc-5 CXX=g++-5 CXXFLAGS="-DUSE_XSIMD -march=native -fopenmp" TESTCASE='pythran/tests/test_ca*.py'
3231

3332
- CC=clang-3.5 CXX=clang++-3.5 CXXFLAGS=-g TESTCASE='pythran/tests/test_[d-m]*.py pythran/tests/test_n[a-t]*.py'
34-
- CC=clang-3.5 CXX=clang++-3.5 CXXFLAGS="-DUSE_BOOST_SIMD -march=native" TESTCASE='pythran/tests/test_[d-m]*.py pythran/tests/test_n[a-t]*.py'
33+
- CC=clang-3.5 CXX=clang++-3.5 CXXFLAGS="-DUSE_XSIMD -march=native" TESTCASE='pythran/tests/test_[d-m]*.py pythran/tests/test_n[a-t]*.py'
3534
- CC=gcc-5 CXX=g++-5 CXXFLAGS="-fopenmp" TESTCASE='pythran/tests/test_[d-m]*.py pythran/tests/test_n[a-t]*.py'
3635

3736
- CC=clang-3.5 CXX=clang++-3.5 CXXFLAGS=-g TESTCASE='pythran/tests/test_numpy_f[u-z]*.py'
38-
- CC=clang-3.5 CXX=clang++-3.5 CXXFLAGS="-DUSE_BOOST_SIMD -march=native" TESTCASE='pythran/tests/test_numpy_f[u-z]*.py'
37+
- CC=clang-3.5 CXX=clang++-3.5 CXXFLAGS="-DUSE_XSIMD -march=native" TESTCASE='pythran/tests/test_numpy_f[u-z]*.py'
3938
- CC=gcc-5 CXX=g++-5 CXXFLAGS="-fopenmp" TESTCASE='pythran/tests/test_numpy_f[u-z]*.py'
4039

4140
- CC=clang-3.5 CXX=clang++-3.5 CXXFLAGS=-g TESTCASE='pythran/tests/test_numpy_[s-z]*.py'
42-
- CC=clang-3.5 CXX=clang++-3.5 CXXFLAGS="-DUSE_BOOST_SIMD -march=native" TESTCASE='pythran/tests/test_numpy_[s-z]*.py'
41+
- CC=clang-3.5 CXX=clang++-3.5 CXXFLAGS="-DUSE_XSIMD -march=native" TESTCASE='pythran/tests/test_numpy_[s-z]*.py'
4342
- CC=gcc-5 CXX=g++-5 CXXFLAGS="-fopenmp" TESTCASE='pythran/tests/test_numpy_[s-z]*.py'
4443

45-
- CC=clang-3.5 CXX=clang++-3.5 CXXFLAGS=-g TESTCASE='pythran/tests/test_[o-z]*.py'
46-
- CC=clang-3.5 CXX=clang++-3.5 CXXFLAGS="-DUSE_BOOST_SIMD -march=native" TESTCASE='pythran/tests/test_[o-z]*.py'
47-
- CC=gcc-5 CXX=g++-5 CXXFLAGS="-fopenmp" TESTCASE='pythran/tests/test_[o-z]*.py'
44+
- CC=clang-3.5 CXX=clang++-3.5 CXXFLAGS=-g TESTCASE='pythran/tests/test_[o-w]*.py'
45+
- CC=clang-3.5 CXX=clang++-3.5 CXXFLAGS="-DUSE_XSIMD -march=native" TESTCASE='pythran/tests/test_[o-w]*.py'
46+
- CC=gcc-5 CXX=g++-5 CXXFLAGS="-fopenmp" TESTCASE='pythran/tests/test_[o-w]*.py'
4847

49-
- PYTHON_VERSION=2 NOTEBOOK=true
48+
- PYTHRAN_DOC=true
5049

5150
# - TESTCASE=pythran/tests/test_base.py
5251
# - TESTCASE=pythran/tests/test_bisect.py

Changelog

Lines changed: 57 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,59 @@
1+
2018-11-06 Serge Guelton <[email protected]>
2+
3+
* Moving to xsimd as vectorization engine, requires -DUSE_XSIMD
4+
5+
* Better support of view conversion from Python to Pythran
6+
7+
* Improved Cython integration
8+
9+
* Improved documentation, add exemple section
10+
11+
* Updated ArchLinux Packaging
12+
13+
* Remove useless warnings during compilation
14+
15+
* Faster ``abs(x**2)`` for complex numbers
16+
17+
* IPython magic now accepts most optimization flags
18+
19+
* Automatic detection of partially (or fully) constant shape for arrays
20+
21+
* Add ignoreflags settings to .pythranrc to skip some compiler flags
22+
23+
* Quad number (aka long double) basic support
24+
25+
* And many minor bugfixes, as usual :-)
26+
27+
28+
2018-09-16 Serge Guelton <[email protected]>
29+
30+
* Decent support for ``is None`` pattern
31+
32+
* Bessel functions, aka scipy.special.stuff
33+
34+
* ``__builtin__.slice`` support
35+
36+
* ``np.unravel_index``, ``np.(u)intc`` support
37+
38+
* Cleanup and fix issues around sdist / build_ext and stuff
39+
40+
* O(1) View conversion to Python
41+
42+
* Dropped big int support
43+
44+
* Speed improvement for ``np.argmin``, ``np.argmax`` and square of complex
45+
46+
* Allow partially (or fully) constant shape for arrays
47+
48+
* Deterministic header inclusion (toward reproducible build?)
49+
50+
* Better error report on argument mismatch
51+
52+
* Better support for view arguments (but still lotta missing :-/)
53+
54+
* Better Windows support (fix compiler-specific bugs) incuding OpenMP
55+
56+
157
2018-06-06 Serge Guelton <[email protected]>
258

359
* Much better support of fancy indexing, still not 100% support though
@@ -13,7 +69,7 @@
1369
* Most tests now work on Python 2 and Python 3
1470

1571
* Many bugfixes triggered by the bug report of Yann Diorcet, Jean Laroche
16-
and David Menéndez Hurtado, Fabien Rozar, C. Claus
72+
and David Menéndez Hurtado, Fabien Rozar, C. Claus
1773

1874

1975
2018-04-23 Serge Guelton <[email protected]>

README.rst

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ Using ``pip``
3535

3636
Pythran depends on a few Python modules and several C++ libraries. On a debian-like platform, run::
3737

38-
$> sudo apt-get install libgmp-dev libatlas-base-dev
38+
$> sudo apt-get install libatlas-base-dev
3939
$> sudo apt-get install python-dev python-ply python-networkx python-numpy
4040

4141
2. Use ``easy_install`` or ``pip``::
@@ -57,9 +57,6 @@ Mac OSX
5757

5858
Using brew (http://brew.sh/)::
5959

60-
$> brew install gmp
61-
$> brew install cmake
62-
6360
$> easy_install pip
6461

6562
$> pip install numpy pythran
@@ -73,9 +70,9 @@ Depending on your setup, you may need to add the following to your \\~/.pythranr
7370
ArchLinux
7471
=========
7572

76-
Using `yaourt`::
73+
Using any working `AUR helper <https://wiki.archlinux.org/index.php/AUR_helpers>`_, say aurman::
7774

78-
$> yaourt -S python2-pythran-git
75+
$> aurman -S python-pythran
7976

8077
Windows
8178
=======

docs/CLI.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Firstly lets clear the working space::
1515
One of the most classic use case in Pythran is to generate a native .so module::
1616

1717
$> printf '#pythran export foo()\n#pythran export msg\nmsg = \"hello world\"\ndef foo(): print(msg)' > cli_foo.py
18-
$> pythran cli_foo.py
18+
$> pythran cli_foo.py -o cli_foo.so
1919
$> ls cli_foo.so
2020
cli_foo.so
2121

@@ -29,7 +29,7 @@ The generated native ``.so`` module can then be used with the Python interpreter
2929
Pythran version can be dumped through ``--version``::
3030

3131
$> pythran --version 2>&1
32-
0.8.6
32+
0.9.0
3333

3434
The module-level ``__pythran__`` variable indicates that the module loaded has been pythranized::
3535

@@ -39,7 +39,7 @@ The module-level ``__pythran__`` variable indicates that the module loaded has b
3939
You can choose your optimization level by using ``-O`` flag::
4040

4141
$> rm cli_foo.so
42-
$> pythran cli_foo.py -O2
42+
$> pythran cli_foo.py -O2 -o cli_foo.so
4343
$> ls cli_foo.so
4444
cli_foo.so
4545

@@ -49,13 +49,13 @@ Out of curiosity, you can check the generated output::
4949

5050
That's some heavily templated code ;-) Pythran can then compile it for you to a Python module::
5151

52-
$> pythran cli_foo.cpp
52+
$> pythran cli_foo.cpp -o cli_foo.so
5353

5454
Pythran can also generate raw C++ code, using the ``-e`` switch::
5555

5656
$> pythran -e cli_foo.py -o cli_foo.hpp
5757
$> printf '#include \"cli_foo.hpp\"\nusing namespace __pythran_cli_foo ; int main() { foo()(); return 0 ; }' > cli_foo.cpp
58-
$> `pythran-config --compiler --cflags` -std=c++11 cli_foo.cpp -o cli_foo -UUSE_GMP
58+
$> `pythran-config --compiler --cflags` -std=c++11 cli_foo.cpp -o cli_foo
5959
$> ./cli_foo
6060
hello world
6161

docs/EXAMPLES.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Examples
2+
========
3+
4+
.. toctree::
5+
6+
examples/Distutils Sample Project
7+
examples/Third Party Libraries

docs/INTERNAL.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,9 +160,9 @@ conditional::
160160
>>> _ = pm.apply(openmp.GatherOMPData, foo_tree)
161161
>>> print(pm.dump(backend.Python, foo_tree))
162162
def foo(n):
163+
'omp parallel'
164+
'omp single'
163165
if 1:
164-
'omp parallel'
165-
'omp single'
166166
s = 1
167167
return s
168168

docs/MANUAL.rst

Lines changed: 33 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ Prerequisite
3939

4040
Pythran depends on the following packages:
4141

42-
- GMP: https://gmplib.org/
4342
- ply: http://www.dabeaz.com/ply/
4443
- networkx: https://networkx.github.io/
4544
- numpy: http://www.numpy.org/
@@ -173,10 +172,11 @@ To the input file. You can compile it as the previous code::
173172

174173
and you'll get a decent binary. But what you really want to do is::
175174

176-
$> pythran -fopenmp -march=avx arc_distance.py
177-
178-
which basically tells the compiler to parallelize and vectorize loops. Then you'll get **really** fast code!
175+
$> pythran -DUSE_XSIMD -fopenmp -march=native arc_distance.py
179176

177+
which basically tells the compiler to parallelize and vectorize loops using
178+
whatever hardware available on your machine. Then you'll get **really** fast
179+
code!
180180

181181

182182
Concerning Pythran specifications
@@ -203,14 +203,15 @@ set), introduced by the ``list`` (resp. ``set``) keyword::
203203
| argument_type set # this is a set
204204
| argument_type []+ # this is a ndarray, C-style
205205
| argument_type [::]+ # this is a strided ndarray
206-
| argument_type [:,...,:]+ # this is a ndarray, Cython
206+
| argument_type [:,...,:]+ # this is a ndarray, Cython style
207+
| argument_type [:,...,3]+ # this is a ndarray, some dimension fixed
207208
| argument_type:argument_type dict # this is a dictionary
208209

209-
basic_type = bool | int | long | float | str | None
210+
basic_type = bool | int | float | str | None
210211
| uint8 | uint16 | uint32 | uint64 | uintp
211212
| int8 | int16 | int32 | int64 | intp
212-
| float32 | float64
213-
| complex64 | complex128
213+
| float32 | float64 | float128
214+
| complex64 | complex128 | complex256
214215

215216
The same syntax can be used to export global variable (in read only mode)::
216217

@@ -315,9 +316,13 @@ When distributing a Python application with Pythran modules, you can either:
315316
import setuptools
316317
setuptools.dist.Distribution(dict(setup_requires='pythran'))
317318

318-
from pythran.dist import PythranExtension
319+
from pythran.dist import PythranExtension, PythranBuildExt
319320
setup(...,
320-
ext_modules=[PythranExtension("mymodule", ["mymodule.py"])])
321+
ext_modules=[PythranExtension("mymodule", ["mymodule.py"])],
322+
cmdclass={"build_ext": PythranBuildExt})
323+
324+
``PythranBuildExt`` is optional, but necessary to build extensions with
325+
different C++ compilers.
321326

322327
Capsule Corp
323328
------------
@@ -330,7 +335,9 @@ line::
330335
#pythran export capsule foo(double*, doule)
331336

332337
Note that pointer types are only supported within the context of a capsule, as
333-
they don't match any real Python type.
338+
they don't match any real Python type. **Any** Pythran type is valid as capsule
339+
parameter, but beware that non scalar or pointer types only make sense withing
340+
the Pythran context.
334341

335342
Advanced Usage
336343
--------------
@@ -347,7 +354,8 @@ Tired of typing the same compiler switches again and again? Store them in
347354
``$XDG_CONFIG_HOME/.pythranrc``!
348355

349356
Wants to try your own compiler? Update the `CC` and `CXX` fields from your
350-
`pythranrc`, or set the same env variables to the right compilers.
357+
`pythranrc`, or set the same env variables to the right compilers. Environment
358+
variables have greater precedence than configuration file.
351359

352360
The careful reader might have noticed the ``-p`` flag from the command line. It
353361
makes it possible to define your own optimization sequence::
@@ -439,23 +447,22 @@ This section contains compiler flags configuration. For education purpose, the d
439447

440448
:``defines``:
441449

442-
Preprocessor definitions. Pythran is sensible to ``USE_BOOST_SIMD`` and
443-
``PYTHRAN_OPENMP_MIN_ITERATION_COUNT``. The former turns on Boost.simd
450+
Preprocessor definitions. Pythran is sensible to ``USE_XSIMD`` and
451+
``PYTHRAN_OPENMP_MIN_ITERATION_COUNT``. The former turns on `xsimd <https://github.com/QuantStack/xsimd>`_
444452
vectorization and the latter controls the mimimal loop trip count to turn a
445-
sequential loop into a parallel loop. The default is to set ``USE_GMP``, so
446-
that Python's longs are represented using GMP.
453+
sequential loop into a parallel loop.
447454

448455
:``undefs``:
449456

450457
Some preprocessor definitions to remove.
451458

452459
:``include_dirs``:
453460

454-
Additionnal include directories to search for headers.
461+
Additional include directories to search for headers.
455462

456463
:``cflags``:
457464

458-
Additionnal random compiler flags (``-f``, ``-O``). Optimization flags generally
465+
Additional random compiler flags (``-f``, ``-O``). Optimization flags generally
459466
go there. The default is to set ``-std=c++11`` for C++11 support.
460467

461468
:``libs``:
@@ -470,12 +477,19 @@ This section contains compiler flags configuration. For education purpose, the d
470477

471478
:``ldflags``:
472479

473-
Additionnal random linker flags.
480+
Additional random linker flags.
474481

475482
:``blas``:
476483

477484
BLAS library to use. Default is ``blas``, but ``atlas`` or ``mkl`` are also viable choices.
478485

486+
:``ignoreflags``:
487+
488+
Space-separated list of compiler flags that should not be forwarded to the
489+
pythran backend compiler when inherited, for instance, from
490+
``python-config``. For instance ``-Wstrict-prototypes`` is a C-only option
491+
that should be pruned.
492+
479493

480494
``[pythran]``
481495
*************

docs/TUTORIAL.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ subset of Python AST) into a C++ AST::
7676
>>> from pythran import backend
7777
>>> cxx = pm.dump(backend.Cxx, tree)
7878
>>> str(cxx)
79-
'#include <pythonic/include/__builtin__/pythran/ifexp.hpp>\n#include <pythonic/__builtin__/pythran/ifexp.hpp>\nnamespace __pythran_tutorial_module\n{\n struct fib\n {\n typedef void callable;\n typedef void pure;\n template <typename argument_type0 >\n struct type\n {\n typedef typename pythonic::returnable<typename std::remove_cv<typename std::remove_reference<argument_type0>::type>::type>::type result_type;\n } \n ;\n template <typename argument_type0 >\n typename type<argument_type0>::result_type operator()(argument_type0&& n) const\n ;\n } ;\n template <typename argument_type0 >\n typename fib::type<argument_type0>::result_type fib::operator()(argument_type0&& n) const\n {\n return pythonic::__builtin__::pythran::ifexp((bool)(n < 2L), [&] () { return n; }, [&] () { return (fib()((n - 1L)) + fib()((n - 2L))); });\n }\n}'
79+
'#include <pythonic/include/__builtin__/pythran/ifexp.hpp>\n#include <pythonic/include/operator_/add.hpp>\n#include <pythonic/include/operator_/lt.hpp>\n#include <pythonic/__builtin__/pythran/ifexp.hpp>\n#include <pythonic/operator_/add.hpp>\n#include <pythonic/operator_/lt.hpp>\nnamespace __pythran_tutorial_module\n{\n struct fib\n {\n typedef void callable;\n typedef void pure;\n template <typename argument_type0 >\n struct type\n {\n typedef typename pythonic::returnable<typename std::remove_cv<typename std::remove_reference<argument_type0>::type>::type>::type result_type;\n } \n ;\n template <typename argument_type0 >\n typename type<argument_type0>::result_type operator()(argument_type0&& n) const\n ;\n } ;\n template <typename argument_type0 >\n typename fib::type<argument_type0>::result_type fib::operator()(argument_type0&& n) const\n {\n return pythonic::__builtin__::pythran::ifexp((bool)(pythonic::operator_::lt(n, 2L)), [&] () { return n; }, [&] () { return (pythonic::operator_::add(fib()((n - 1L)), fib()((n - 2L)))); });\n }\n}'
8080

8181
The above string is understandable by a C++11 compiler, but it quickly reaches the limit of our developer brain, so most of the time, we are more comfortable with the Python backend::
8282

@@ -111,12 +111,12 @@ computation, if any::
111111
>>> tree = ast.parse("""
112112
... def foo(x):
113113
... #omp critical
114-
... a,b = bar(x)
114+
... a,b = 1, x + 1
115115
... return a + b""")
116116
>>> _ = pm.apply(transformations.NormalizeTuples, tree) # in-place
117117
>>> print(pm.dump(backend.Python, tree))
118118
def foo(x):
119-
__tuple0 = bar(x)
119+
__tuple0 = (1, (x + 1))
120120
a = __tuple0[0]
121121
b = __tuple0[1]
122122
return (a + b)
@@ -154,7 +154,7 @@ More complex ones rely on introspection to implement constant folding::
154154

155155
One can also detect some common generator expression patterns to call the itertool module::
156156

157-
>>> norm = 'def norm(l): return sum(n*n for n in l)'
157+
>>> norm = 'def norm(l): return __builtin__.sum(n*n for n in l)'
158158
>>> tree = ast.parse(norm)
159159
>>> _ = pm.apply(optim.ComprehensionPatterns, tree)
160160
>>> 'map' in pm.dump(backend.Python, tree)

0 commit comments

Comments
 (0)