Boost logo

Boost Users :

Subject: [Boost-users] externing template instantiations of Boost.Multiprecision numbers
From: Dani Brake (danielthebrake_at_[hidden])
Date: 2017-05-02 21:46:27


Hi Boost,

I happily use Boost.Multiprecision inside a largely templated codebase,
which involves the entirely-templated Eigen as well. My compile times are
high.

To gain insight into why compile time is so ridiculous, I used Templight
<https://github.com/mikael-s-persson/templight> with Clang to query how
many times my templates are instantiated, and how long they take. The
answer was overwhelmingly that Boost.Multiprecision's number class is to
blame, with 8264 instantiations of

bmp::number<bmp::backends::mpft_float_backend<0,allocate_dynamic>,
bmp::expression_template_option::et_on>

5052 of the same with the gmp_int backend, and 2689 for mpz_rational.

I think the cure might be an extern template declaration on these three
types, but where is the correct place to do this? In a header *I* have
written which provides a few extensions / additions I needed? Or do I need
to patch my install of BMP and put it there?

As a follow-up, I have a cycle of instantiations I believe, but do not yet
know, are expression templates. Can I extern a few common instantiations,
and let the compiler do the rest? Any help or techniques are greatly
appreciated. Especially as I (slowly) move toward applying expression
templates to complex multiprecision arithmetic, too.

Thanks a ton,
Dani Brake

University of Notre Dame
Applied and Computational Mathematics and Statistics



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net