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

Check that roadrunner respects the llvm optimization pass options. #898

Open
CiaranWelsh opened this issue Oct 25, 2021 · 4 comments
Open

Comments

@CiaranWelsh
Copy link

The RoadRunner::Config class has a set of options that are intended to control llvm code generation optimizations - that is, which passes are applied sequentially to produce faster llvm IR code. These passes are expensive operations: they take about ~36% of the time in a simpe "build and simulate" program:

    bool opt = false;
    Config::setValue(Config::LOADSBMLOPTIONS_OPTIMIZE_CFG_SIMPLIFICATION, opt);
    Config::setValue(Config::LOADSBMLOPTIONS_OPTIMIZE_DEAD_CODE_ELIMINATION, opt);
    Config::setValue(Config::LOADSBMLOPTIONS_OPTIMIZE_GVN, opt);
    Config::setValue(Config::LOADSBMLOPTIONS_OPTIMIZE_INSTRUCTION_COMBINING, opt);
    Config::setValue(Config::LOADSBMLOPTIONS_OPTIMIZE_INSTRUCTION_SIMPLIFIER, opt);
    Config::setValue(Config::LOADSBMLOPTIONS_OPTIMIZE_CFG_SIMPLIFICATION, opt);
    RoadRunner roadRunner(OpenLinearFlux().str());
    roadRunner.simulate(0, 100, 101);

Turning these optimizations off should speed the process of model generation, which is what we want when we are dealing with lots of models. However, running the profiler tool again with these optimizations turned off produces very similar (the same?) results leading me to think that these options are not really doing anything. Therefore, we should check to see whether roadrunner actually respects these options.

@matthiaskoenig
Copy link
Collaborator

Just to comment on the benchmarking. You have to use benchmark models which require a lot of work to simulate, i.e. at least in the range of model loading. I saw your benchmarks of speedup 3x for parallelization for simple stochastic simulations of S1 -> S2; J0 = k0*S1. Such models will not do for benchmarking, because the model simulation is not really expensive. You need large models with complex math to see optimization results. I assume you did the same here. If you don't have anything complex in the model and very easy simulations you will not notice much/any improvements.

@matthiaskoenig
Copy link
Collaborator

Forgot: You will really need a real benchmarking suite to also avoid regressions in speed. Trying to optimize with toy models without seeing the impact on a larger set of real-world models is very dangerous.

@CiaranWelsh
Copy link
Author

Yep - these are valid points. These little models are only really designed for unit testing. I tried again with the Brown 2004 model. That is, build and simulate the brown 2004 model in a loop 1000 times, but adding a unique species each time to prevent roadrunner from caching the model. In this case, we do observe around a 15-30 second speed up when turning off the additional llvm IR optimization passes, which makes sense to me.

However, I do still wonder if there is still something not quite right because even when these optimization flags are set to off, the profiler indicates that a significant amount of the time is spent in the llvm::legacy::PassManager - suggesting these flags aren't doing what I think they should be doing.

Agreed with your benchmarking point. This is something I will get around to in the near future as I'll be comparing different llvm backend configurations.

@hsauro
Copy link

hsauro commented Oct 28, 2021 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants