|
Boost : |
From: Phil Richards (news_at_[hidden])
Date: 2004-01-20 13:44:32
On Sun, 18 Jan 2004 00:19:44 -0600, Aleksey Gurtovoy wrote:
[with respect to my performance problems using the MPL]
> Sounds like something is wrong. Let's figure it out.
[what I should be looking for]
> O(n*n) algorithms :).
Well, as far as I can tell there are none :-(
> The code you've posted seems pretty innocent. I'd need a compliable test
> case which reproduces the problem to be able to say more.
Ok, here's a stripped down version that demonstrates the problem. Compile
with -DLEVEL=# for #=0..6. The results I get with gcc 3.3.2 on my 900MHz
Athlon (yes, I know, it's time for an upgrade) are as follows (to first
approximation).
LEVEL Time (seconds)
0 0.6
1 0.6
2 0.6
3 1.4 (1 fold)
4 2.0 (2 folds)
5 2.6 (3 folds)
6 3.0 (4 folds)
Each instantiation of a "fold" causes a depressingly large increase in
compile time - I've split it down a little, and the zip_view has a bit of
an impact, but the guilty party really looks like it is a result of what
fold is doing to the compiler. I've tried replacing the apply result with
a "typedef base type;" with no real difference. I flipped the vector7
over into a list and no difference.
--- snip snip ---
#include <boost/mpl/zip_view.hpp>
#include <boost/mpl/fold.hpp>
#include <boost/mpl/vector.hpp>
struct base {};
struct op {
template<typename ResultSoFar, typename Value>
struct apply {
struct type {};
};
};
struct dummy1 {};
struct dummy2 {};
int
main(int, char **)
{
#if LEVEL > 0
using namespace boost::mpl;
#if LEVEL > 1
typedef vector7<dummy1, dummy1, dummy1, dummy1, dummy1, dummy1, dummy1>
V1;
typedef vector7<dummy2, dummy2, dummy2, dummy2, dummy2, dummy2, dummy2>
V2;
V1 v1; (void)v1;
V2 v2; (void)v2;
#if LEVEL > 2
fold< zip_view< vector2<V1, V2> >, base, op >::type f1; (void)f1;
#if LEVEL > 3
fold< zip_view< vector2<V2, V1> >, base, op >::type f2; (void)f2;
#if LEVEL > 4
fold< zip_view< vector2<V1, V1> >, base, op >::type f3; (void)f3;
#if LEVEL > 5
fold< zip_view< vector2<V2, V2> >, base, op >::type f4; (void)f4;
#endif
#endif
#endif
#endif
#endif
#endif
return 0;
}
--- pins pins ---
phil
-- change name before "@" to "phil" for email
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk