Skip to content
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

Rewrite macros using staged functions #271

Merged
merged 4 commits into from
Oct 17, 2014
Merged

Rewrite macros using staged functions #271

merged 4 commits into from
Oct 17, 2014

Conversation

mlubin
Copy link
Member

@mlubin mlubin commented Sep 25, 2014

Major revamp of expression parsing macros using staged functions (requires Julia 0.4).
Primary new feature is that this lets us handle commutivity (#99) without sacrificing performance, and also we'll get faster quadratic expression building.

Before:

$ julia speed.jl 
PMEDIAN BUILD MIN=0.311928322  MED=0.330600015
PMEDIAN WRITE MIN=1.731297123  MED=1.751828376
CONT5 BUILD   MIN=0.179188774  MED=0.216120392
CONT5 WRITE   MIN=1.45397678  MED=1.47033628

After:

$ julia0.4 speed.jl 
PMEDIAN BUILD MIN=0.329470738  MED=0.332986915
PMEDIAN WRITE MIN=5.201167811  MED=5.25195727
CONT5 BUILD   MIN=0.232650668  MED=0.237446502
CONT5 WRITE   MIN=3.984346782  MED=3.994990259

So 5% slowdown for PMEDIAN build time, and 30% slowdown in CONT5 build time. This is a reasonable trade off for the extra flexibility, I think. I can do a bit more tweaking to see if I can get extra speed ups, and we can expect improvements in compiler optimizations for staged functions. Slow down in write time is unrelated, should investigate separately what's causing this in Julia 0.4.

Generated code is a bit more type stable now, since new intermediate variables are created for the output of each subexpression.

TODO:

  • Improved handling to speed up quadratic expressions (requires quadratic benchmarks)
  • General speed tweaks
  • Julia 0.3 compatibility
  • Compatibility with extensions

@joehuchette
Copy link
Contributor

:) by the quadratic handling stuff do you mean doing the expression tree search to detect quadratic vs. linear expressions?

@mlubin
Copy link
Member Author

mlubin commented Sep 25, 2014

No, just adding a case in addToExpression_reorder that separates the two quadratic terms from the coefficients, right now I'm being lazy by multiplying one of the quadratic terms with all of the coefficients first.

@IainNZ
Copy link
Collaborator

IainNZ commented Sep 25, 2014

Brave new world :) Feels so much more right than the old approach

@mlubin
Copy link
Member Author

mlubin commented Sep 25, 2014

I still kinda like that you could read a model and know which terms are coefficients and which are variables, but that doesn't generalize very well to nonlinear expressions. Should we have some sort of a style guide?

@mlubin
Copy link
Member Author

mlubin commented Oct 12, 2014

Rebased, compatible with 0.3 now. @IainNZ, does this break macros for JuMPeR?

@mlubin mlubin changed the title WIP: Rewrite macros using staged functions Rewrite macros using staged functions Oct 13, 2014
@mlubin
Copy link
Member Author

mlubin commented Oct 17, 2014

@IainNZ, just tested JuMPeR with this and tests pass. Safe to merge?

@IainNZ
Copy link
Collaborator

IainNZ commented Oct 17, 2014

Yep, go for it.

mlubin added a commit that referenced this pull request Oct 17, 2014
Rewrite macros using staged functions
@mlubin mlubin merged commit 0225dc5 into master Oct 17, 2014
@mlubin mlubin deleted the staged_experiments branch October 17, 2014 19:55
@tkelman
Copy link
Contributor

tkelman commented Oct 17, 2014

The Maros-Meszaros test set is probably the standard benchmark for QP's. If there isn't a Julia QPS reader yet (?), they're available as mat files here https://github.com/YimingYAN/QP-Test-Problems (I did the exact same thing a few years ago - used a mex interface to CoinUtils to read them into Matlab). Or maybe not too hard to parse from the originals http://www.cuter.rl.ac.uk/Problems/marmes.shtml

These are a subset of CUTEr of course. Wonder where the Julia CUTEr/CUTEst interface got to.

@mlubin mlubin mentioned this pull request Jan 5, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants