Generating optimized code for template instanciations

Is there a way to make the Cling command line compile template instanciations with optimizations? For example given the definition:

template<typename T>
void f() {
    // some algorithm

Entering in the command line:

root [0] f<int>()

Should compile f with -O2 (or another level) of optimization and execute it.


Which version of ROOT do you use?

So far we have not done any work on switching opt levels at runtime. This might be simpler in the master than in the 6.02 branch, though.

What’s your motivation?

Cheers, Axel.

ROOT version 6.02/04

I’m running algorithms with large data sets (point sets) from ROOT, which are defined in a library built using template metaprogramming. So the problem is that unless i call a template function that is defined explicitly in the library (extern template class PointCloud in header and template class PointCloud in a module of the library), the algorithms run slowly.
Does gSystem->SetAclicMode have this effect?


No - I’d say you have two options:

  • have us implement optimizations for the JIT; that’s possible but fairly intrusive for a patch release of a production version; I’d prefer to not do that in 6.02.
  • compile your code with ACLiC and call an entry function that in turn calls into the the template magic world.

Would the latter do?

I’ll think about what we can do in the master!

Cheers, Axel.