Interested in contributing to Sympy, especially in the area of code generation

93 views
Skip to first unread message

ruggero cyrille

unread,
Jun 20, 2016, 4:29:52 PM6/20/16
to sympy
Hi, I'm a third year undergraduate in computer science in France and I'm looking for a summer project. Since I already used Sympy and appreciated it, I'm interested in contributing to it.

Since I took several courses on compilers, I wanted to get my hand into code generation. I'm interested in writing an LLVM IR backend similar to the C backend. But after reading this thread and this one, I realized that there was already a developper working actively on it, so I wanted to know if my efforts would be useful to the project.

I also wanted to fix some easy to fix issues. But the ones I read in the tracker were already fixed.

I thank you in advance for your advices.

Aaron Meurer

unread,
Jun 20, 2016, 4:41:51 PM6/20/16
to sy...@googlegroups.com
An easy place to start for code generation is to find some functions
that don't currently code generate for some given language backend and
add support for them. Especially for the newer or less used languages
(C and Fortran are the most used), there should be lots of functions
that don't have proper support yet. You could start by looking at the
printers and seeing what functions some language supports and another
doesn't.

Aaron Meurer
> --
> You received this message because you are subscribed to the Google Groups
> "sympy" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to sympy+un...@googlegroups.com.
> To post to this group, send email to sy...@googlegroups.com.
> Visit this group at https://groups.google.com/group/sympy.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/sympy/4c0f948d-5103-48d0-9d68-85d6a7b9f036%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Björn Dahlgren

unread,
Jun 21, 2016, 5:58:18 AM6/21/16
to sympy

On Monday, 20 June 2016 22:29:52 UTC+2, ruggero cyrille wrote:
I'm interested in writing an LLVM IR backend similar to the C backend.

If you are well-versed in LLVM IR an interesting project would be to add JIT capabilities to SymEngine (the high-performance sister-project to SymPy),
the LLVM docs have an example called "kaleidoscope" which is pretty close to what would need to be implemented, I can't speak for the SymEngine devs, but I think they would be interested.
This would give us a very fast "lambdify" implementation.

Other thoughts that come to mind would be a code printer for the specific combination of C++/Boost (boost has lots of special functions and multiprecision support).

Just some ideas, hopefully they can spark some thoughts..

Best,
Björn

Isuru Fernando

unread,
Jun 22, 2016, 7:26:14 AM6/22/16
to sy...@googlegroups.com
Hi,

On Tue, Jun 21, 2016 at 3:28 PM, Björn Dahlgren <bjo...@gmail.com> wrote:

On Monday, 20 June 2016 22:29:52 UTC+2, ruggero cyrille wrote:
I'm interested in writing an LLVM IR backend similar to the C backend.

If you are well-versed in LLVM IR an interesting project would be to add JIT capabilities to SymEngine (the high-performance sister-project to SymPy),
the LLVM docs have an example called "kaleidoscope" which is pretty close to what would need to be implemented, I can't speak for the SymEngine devs, but I think they would be interested.
This would give us a very fast "lambdify" implementation.

We'd definitely be interested. I looked at the Kaleidoscope example and HowToUseJIT and implemented it here, https://github.com/isuruf/symengine/tree/llvm. If anybody is interested, you can take a look at and see if it can be improved. Currently, it's slower than the existing lambdify. I only have a day of experience with LLVM, so I don't know what I'm doing wrong. If you can take a look, that'll be great.

Isuru Fernando

ruggero cyrille

unread,
Jun 22, 2016, 6:02:31 PM6/22/16
to sympy
Thanks for the answers. I looked into the printers. It appears that the C printer doesn't support functions like csc, sec, cot, so I made some changes so that the C printer supports them. Is that too little for a patch, or can I write a pull request?

I'm also going to take a look at symengine. I don't know much about it yet.

Aaron Meurer

unread,
Jun 23, 2016, 1:08:18 PM6/23/16
to sy...@googlegroups.com
It sounds like a good patch. I look forward to the pull request.

Aaron Meurer
> --
> You received this message because you are subscribed to the Google Groups
> "sympy" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to sympy+un...@googlegroups.com.
> To post to this group, send email to sy...@googlegroups.com.
> Visit this group at https://groups.google.com/group/sympy.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/sympy/839050bc-1bfd-4b2e-82b3-c0041d6c23ae%40googlegroups.com.

Björn Dahlgren

unread,
Jul 14, 2016, 6:12:30 PM7/14/16
to sympy

On Wednesday, 22 June 2016 13:26:14 UTC+2, Isuru Fernando wrote:
I looked at the Kaleidoscope example and HowToUseJIT and implemented it here, https://github.com/isuruf/symengine/tree/llvm. If anybody is interested, you can take a look at and see if it can be improved. Currently, it's slower than the existing lambdify. I only have a day of experience with LLVM, so I don't know what I'm doing wrong. If you can take a look, that'll be great.

I'm surprised that it's slower, unfortunately this is outside my comfort zone. Judging by what I've read from Eli Bendersky, someone like him could probably shed some light on the issue, but I don't know him so I'm reluctant to bother him.

Richard Otis

unread,
Jul 17, 2016, 12:46:58 PM7/17/16
to sympy
This may also be interesting to you: "Let's Write an LLVM Specializer in Python" http://dev.stephendiehl.com/numpile/
Reply all
Reply to author
Forward
0 new messages