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
Fparser app #366
Fparser app #366
Conversation
This is meant to be useful for debugging problems with fparser strings, and right now it seems useful for debugging problems with fparser...
Results of testing de5cbc2 using libmesh_PR_test recipe: Passed on: linux-gnu View the results here: https://www.moosebuild.com/view_job/6106 |
That fparser line works fine with a --disable-fparser-optimizer build. |
Results of testing de5cbc2 using libmesh_PR_test_dbg recipe: Passed on: linux-gnu View the results here: https://www.moosebuild.com/view_job/6107 |
Huh? |
Would you care to comment on some of the fparser optimizer debugging methods you've developed over time? |
I had to look at Maybe I should add an interface to |
How hard would it be to add JIT support to ParsedFunction? I'm currently between a rock and a hard place; runs with --disable-fparser-optimizer are intolerably slow for our app, runs with the default configuration give grossly wrong results under some conditions. |
This doesn't look like an easy-to-bisect regression, either - I get the same failure when backporting this PR onto f58d4a4... |
Adding jit support would be as easy as adding a compile() member that invokes the jitcompile method on the contained fparser object. But I guess I don't understand what the regression is yet. |
The command I listed above should obviously return 1, and if you make slight simplifications (get rid of the abs() call or the inversion) it does; instead it returns 10. |
Ok, I realized that in the mean time and I'm building a little test program to look at the bytecode before and after optimization. I have a suspicion that it may be related to optimizer rules regarding 'guaranteed positivity' (which is set by the abs function). Let me check. |
Nice.... this is what my thingie spits out:
The FPOptimizer is waaay overeager here and optimizes the program down to a constant. I will investigate further. |
On Wed, Oct 1, 2014 at 1:06 PM, Daniel Schwen notifications@github.com
Cool, this is really good software. John |
You can construct similar cases with the |
@roystgnr may also get a kick out of idaholab/moose#1923 |
No luck switching to JIT. Here's the code generated: #define _USE_MATH_DEFINES
#include <cmath>
extern "C" double f_c3da290ffb3d00003aa5165348aa0c85a6852fc8(const double *params, const double *immed, const double eps) {
double r, s[2];
s[0] = params[0];
s[0] = std::abs(s[0]);
s[0] = 1.0/s[0];
s[1] = immed[0];
s[0] = s[0] < (s[1] - eps);
if (s[0] < 0.5) goto l12;
s[0] = params[0];
return s[0]; }
l12:
s[0] = immed[1];
return s[0]; } Which obviously causes the compiler to scream and run away from the screwy braces. |
Oh, yep. I see exactly where this bug is in the code. One sec... |
In my experience "One sec" usually equates to one bug fixed, one new bug Hold onto your butts! On Wed, Oct 1, 2014 at 2:50 PM, Daniel Schwen notifications@github.com
|
On Wed, Oct 1, 2014 at 3:10 PM, Cody Permann notifications@github.com
Heheh. It was a one character change, hopefully it doesn't break anything John |
It was a pretty obvious mistake (that should have been spotted during code review, I mean.. come on guys! ;-) ) |
On Wed, Oct 1, 2014 at 3:13 PM, Daniel Schwen notifications@github.com
I blame poor test coverage. John |
We ought to use this app to make a big "fparser test script" eventually. First we'd want to expose decisions like whether to call Optimize() and/or JITCompile() at run-time rather than at configure-time (or as in my current JIT test builds, at "roy just changes parsed_function.h and sees if it works"-time). |
Seems more like a CPPUNIT test to me. |
@dschwen, another JIT bug with a 1 char fix: you've got atan2 calls getting converted to atan calls. |
Thx, @roystgnr will fix that in a minute. |
Coming back to the original issue. I think I'm zeroing in. The culprit is a faulty result boundary calculation. FParser seems to think that the minimum possible value for |
This has been invaluable for boiling down problems with fparser strings.
I'm about to see if it's also useful for hunting down a bug (regression?) in fparser itself - try running "fparser_parse-dbg 'b := 1/abs(x); if(b<=1000,b,10)' 1"...