New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
D5.2: Facility to compile Pythran compliant user kernels and Sage code and automatically take advantage of multi-cores and SIMD instruction units in Cython #115
Comments
Deliverable postponed to month 18 due to hiring issues. |
@ClementPernet (WP leader and lead beneficiary) |
The aim of this project was to optimize the overall performance of Cython code Indeed, when operations are done on Numpy arrays, Cython relies on the original The Pythran project is a Python to C++ compiler, that aims at optimizing The project has been focused on using this Pythran backend for Numpy arrays in
We thus need to be able to fall-back to the Cython implementation if we are not The integration within Cython works this way:
Cython has a comprehensive suite test regarding the Numpy features it supports. A PR is on its way to Cython to integrate this into the project. We are waiting Some benchmarks:
def sqrt_sum(Numpy.ndarray[FLOATTYPE_t, ndim=1] a, Numpy.ndarray[FLOATTYPE_t, ndim=1] b): On my computer (Core i7-6700HQ), this gives there results, with an array of
which makes a speedup of ~3.9x using SIMD instructions.
The input we use is the following: N = 1000
It seems that the Pythran backend does not manage to benefit much from SIMD Summary of current status:
What remains to be done:
Code:
|
Dear M18 deliverable leaders, Just a reminder that reports are due for mid-february, to buy us some time for proofreading, feedback, and final submission before February 28th. See our README for details on the process. In practice, I'll be offline February 12-19, and the week right after will be pretty busy. Therefore, it would be helpful if a first draft could be available sometime this week, so that I can have a head start reviewing it. Thanks in advance! |
Hi @ClementPernet, |
Hi @ClementPernet, |
Since this seems almost ready, if you get a chance to do the above tomorrow morning, that would be great, as I could then submit it in the afternoon and tick the box to focus on the others :-) |
Hello @nthiery , I'll add this one in the morning, sorry about the missing file! |
The Cython PR seem faily close to be merged: cython/cython#1607 |
@ClementPernet it seems complicated yes, I don't know how long it will take. About the abstract, if I understand correctly, I have to make something shorter than what's a the top of this issue? |
Hi @aguinet, |
@aguinet What's the status of the abstract ? We need to polish the deliverable today. Keep us updated. |
I added some notes about what's Cython and its usage within SageMath and OpenDreamKit.
|
Thanks @aguinet; the above text reads nicely. I am uncomfortable though: in good parts this text duplicates the content the report without being quite shorter; so that does not fits the need (remember: the text is meant to appear at the beginning of the report, playing the role of an abstract). |
Okay i'll do that tonight! |
I merged new content of Adrien's post to the deliverable. I will write up an abstract later tonight. |
Ok @aguinet , send me your abstract when it's ready and I'll merge everything together. |
@nthiery : Updated version of the report pushed. Ready for proof-reading. |
Thanks @ClementPernet, @aguinet. I moved your material from github-issue-description.tex into, well, the github issue description :-), and allowed myself to work some more on it. I reverted the lead to "UJF", since the change of name is not yet in the grant agreement, and this resulted in the report showing both affiliation. I also added @aguinet as coauthor; on other occasions, I would have prefereed to ask for confirmation, but I needed to move fast :-) The report is now submitted to the EU! Congrats @aguinet on this first contribution, and thanks @aguinet and @ClementPernet for this deliverable! I had been dreaming about having the best of Cythan and Pythran worlds at my finger tip, and you made it a reality. I am looking forward further collaborations between those two projects. |
The
Python
programming language is widely used in the development of computational mathematics systems likeSageMath
for its expressiveness and flexibility. Yet, as an interpreted language, it suffers from inherent inefficiencies.Over the years several tools have been developed to overcome this barrier. A major player is
Cython
, which is both an extension of the Python language, and a compiler generating compilableC
code. At the cost of additional work from the developer (e.g. type annotations),Cython
can deliver performances similar to that of a compiled language. It's being used intensively inSageMath
. Another emerging player isPythran
, aPython
toC++
compiler for a subset of thePython
language, with a focus on scientific/numerical computing. It takes advantage of type inference features ofC++
as well as multi-cores and SIMD instruction units to deliver high performance without the need for additional work from the developer. In particular, it includes aC++
implementation of a major subset of theNumpy
API, optimized for speed, with support for expression templates that minimize the number of memory transfers needed to compute complex expressions (Numpy
is the fundamental package for scientific computing withPython
). However, unlikeCython
,Pythran
does not support user defined classes, a key feature in systems likeSageMath
.This deliverable is a step toward taking the best of both worlds, and helping bridge the gap between numerical and exact computing. It proposes to incorporate
Pythran
support forNumpy
withinCython
, which consequently provides high performance numerical linear algebra to high level mathematical software developers, especially withinSageMath
.As an illustration, the new
Pythran
backend inCython
achieves a speed-up of about 4 on the following typicalNumpy
based function:The text was updated successfully, but these errors were encountered: