Hello all,
I am a GSoC aspirant and I want to work on the Code Generation module as a project this year.
I had a few questions in mind and needed help regarding them.
1) It is mentioned on the ideas page that the codegen module needs an overhaul. What kind of an overhaul would that be? Is the change needed in the API or friendly functions: codegen and make_routine?
2) I read this discussion and construed that we need to make efforts to include CSE in the codegen module and we are aiming at making an optimizing compiler.
This optimizing compiler should be domain unspecific and work for most general cases. Bjorn Dahlgren suggested that we should be using a templating engine. Is this the work that is needed to be done in this project?
3) I read this blog post by Jason K. Moore where he talked about compiler optimizations like loop unrolling. Is this project is about finding balance between what the code generator should do and what the compiler should do? This blog post is a year old. Has this already been implemented?
4) What is the magnitude and nature of work that is incorporated in this idea?
Is there some ongoing work that I should be aware of?
5) Please suggest some reading sources, so that I am able to take this up.
Thank you,
Tanu Hari Dixit.
--
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/256b3c22-fcee-41c9-8cf4-f545a0e92dbb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Thank you, Jason, for the reply.
I went through the notes put up on the wiki and the optimizations that are required through code generation. I also looked through the pull request #10486.
I had a few questions regarding what needs to be done. I'll be glad if you answer them.
1) exp2 is used in pyne because probably radioactive decay analysis requires a lot of exponentiation. Why would a general code generator generate code with exp2 (unless the user specifies it or we need to calculate powers of 2 or we have guessed somehow that the exponentiation is a large one)?
2)Do we need to make a specialized polynomial evaluator in C/other languages that uses horner? Will we be processing polynomials as strings initially? I found a few references for this----
i) http://www.cs.berkeley.edu/~fateman/papers/polyval.pdf
ii) http://cgpe.gforge.inria.fr/index.php?page=home
iii) https://hal.archives-ouvertes.fr/ensl-00531721/document
Am I in the right direction?
3)I looked at this: https://github.com/SkidanovAlex/interpreter and I tried to understand the fast-matrix exponentiation algorithm. I want to try to implement this. Please provide me with a starting point. In other words, I want to know about a few examples where implementing this would be worthy so that I know where the code should be added.
4)I tried to look into the code of some of the sources (Stuff outside of SymPy) available in the notes on the wiki. I found that pycodeexport uses Mako as the templating engine and PyNE uses jinja2. You mentioned that Aaron might be exploring different ideas (other than templating). What are those?
5)Aaron has added the newly built Assignment and aug_assign and removed datatype and variables (https://github.com/asmeurer/sympy/commit/bd0a5e788fa423f1ebf0ef91455e719a4b65803e) What is the alternative to datatype and variables?
Thank you,
Tanu Hari Dixit.
On Wednesday, March 2, 2016 at 11:55:21 AM UTC+5:30, Tanu Hari Dixit wrote:Hello all,
I am a GSoC aspirant and I want to work on the Code Generation module as a project this year.
I had a few questions in mind and needed help regarding them.
1) It is mentioned on the ideas page that the codegen module needs an overhaul. What kind of an overhaul would that be? Is the change needed in the API or friendly functions: codegen and make_routine?
2) I read this discussion and construed that we need to make efforts to include CSE in the codegen module and we are aiming at making an optimizing compiler.
This optimizing compiler should be domain unspecific and work for most general cases. Bjorn Dahlgren suggested that we should be using a templating engine. Is this the work that is needed to be done in this project?
3) I read this blog post by Jason K. Moore where he talked about compiler optimizations like loop unrolling. Is this project is about finding balance between what the code generator should do and what the compiler should do? This blog post is a year old. Has this already been implemented?
4) What is the magnitude and nature of work that is incorporated in this idea? Is there some ongoing work that I should be aware of?
5) Please suggest some reading sources, so that I am able to take this up.
Thank you,
Tanu Hari Dixit.
--
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/ac891a0e-4a37-4bdc-bc51-79a8beacf9df%40googlegroups.com.
2)The optimizer can implement the following with individual switches:
i)unrolled pow(x, n)
ii)fused add multiply for floating point calculations
iii)intelligent guess about whether to use exp2
iv)horner
v)horner with fused add multiply, maybe?
vi)fast matrix exponentiation that takes in an AST
vii)trignometric simplification
viii)pre-computing constant expressions
ix)using cse with 'basic' optimization.
x)splitting very large expressions into number of Augmented Assignments
xi)fractional power optimization (a=x**(1/2), b=x**(3/2) => a=x**(1/2), b=x*a)
xii)integer power optimization (a=x**8, b=x**10 => t1=x**2, t2=t1**2, a=t2**2, b=a*t1
xiii)Sub-product optimization (a=xyz, b=wyz => t1=yz, a=xt1, b=wt1)
xiv)Sum multiple optimization (a =x-y, b=2y-2x => a=x-y, b=-2a)
The last four are taken from http://www.jnaiam.org/new/uploads/files/16985fffb53018456cf3506db1c5e42b.pdf which is a paper by Allan Wittkopf on code generation in Maple.
I understand that these optimizations need to be tested and might not necessarily provide a speed up in all contexts.
I would like to ask if you have any comments on how you think the optimization pipeline should be (improvements on the naive model I drew on Pinta) and according to you, which of the above optimizations are worth being included ( after being tested ).
2)The optimizer can implement the following with individual switches:
i)unrolled pow(x, n)
ii)fused add multiply for floating point calculations
iii)intelligent guess about whether to use exp2
iv)horner
v)horner with fused add multiply, maybe?
vi)fast matrix exponentiation that takes in an AST
vii)trignometric simplification
viii)pre-computing constant expressions
ix)using cse with 'basic' optimization.
x)splitting very large expressions into number of Augmented Assignments
xi)fractional power optimization (a=x**(1/2), b=x**(3/2) => a=x**(1/2), b=x*a)
xii)integer power optimization (a=x**8, b=x**10 => t1=x**2, t2=t1**2, a=t2**2, b=a*t1
xiii)Sub-product optimization (a=xyz, b=wyz => t1=yz, a=xt1, b=wt1)
xiv)Sum multiple optimization (a =x-y, b=2y-2x => a=x-y, b=-2a)
The last four are taken from http://www.jnaiam.org/new/uploads/files/16985fffb53018456cf3506db1c5e42b.pdf which is a paper by Allan Wittkopf on code generation in Maple.
I understand that these optimizations need to be tested and might not necessarily provide a speed up in all contexts.
I would like to ask if you have any comments on how you think the optimization pipeline should be (improvements on the naive model I drew on Pinta) and according to you, which of the above optimizations are worth being included ( after being tested ).
I would be inclined to think that a lot has happened to the optimizers in compilers since 2007, one would need to replicate some of the experiments on modern hardware/compilers.
As you say, testing this will be crucial. SymPy would need access to some dedicated hardware and I suppose a benchmark suite for SymPy generated code would be almost a must?