Meta Template Programming with MPL - Compiler Bug or is the code really so evil slow?
Hi,
I've written a little Meta Template Program which should calculate the
first 3 perfect numbers. ( range 1 - 500 )
The code is compilable if you use the range 1 - 30 really fast and works
correctly. But I've tried to compile the code but I can't get it finished.
Someone tried it on a Machine with 40 GB RAM and it now compiles for
more than 12 hours and uses more than 7.1 GB RAM ( the compilation )
I've tried it by myself with g++ 3.4.x and g++ 4.0.x and with VC++ 7.1
The code works on all tested compilers if the range would be 1 - 30 but
If the range is 1 - 500 VC++ says:
d:\boost\vc71\include\boost-1_33_1\boost\mpl\aux_\preprocessed\plain\apply_wrap.hpp(48):
fatal error C1204: compiler limit: internal structure overflow.
( This seems to be a known bug in VC++
http://support.microsoft.com/default.aspx?scid=kb;en-us;883655 )
and g++ compiles and compiles and uses more and more RAM.
Is the code really so evil slow or is it a compiler Bug in g++?
Maybe anyone has an answer.
BR
evilissimo
#include
Vinzenz 'evilissimo' Feenstra writes:
I've written a little Meta Template Program which should calculate the first 3 perfect numbers. ( range 1 - 500 )
The code is compilable if you use the range 1 - 30 really fast and works correctly. But I've tried to compile the code but I can't get it finished.
Someone tried it on a Machine with 40 GB RAM and it now compiles for more than 12 hours and uses more than 7.1 GB RAM ( the compilation )
I've tried it by myself with g++ 3.4.x and g++ 4.0.x and with VC++ 7.1
The code works on all tested compilers if the range would be 1 - 30 but If the range is 1 - 500 VC++ says:
d:\boost\vc71\include\boost-1_33_1\boost\mpl\aux_\preprocessed\plain\apply_wrap.hpp(48): fatal error C1204: compiler limit: internal structure overflow.
( This seems to be a known bug in VC++ http://support.microsoft.com/default.aspx?scid=kb;en-us;883655 )
and g++ compiles and compiles and uses more and more RAM.
Is the code really so evil slow or is it a compiler Bug in g++?
The former: your algorithm is basically O(n^2). For n=500, that's a lot of work for the compiler. -- Aleksey Gurtovoy MetaCommunications Engineering
Hey Aleksey, Thank you for the answer. James already said that before and we've figured out that it would take many days to finish the compilation. ;) Fortunately this was only an experimental test after reading a few chapters of your ( and Davids) book, I've just buyed. I am really interessted in this kind of programming, at least in theory until I know if I could use this once in some code. I appreciate the excersises in the book since they help me to dig into the subject with some practice. It is sometimes hard to figure out own excercises for such a topic *g*. Thanks for such a good book about this topic. I really like it :) BR Vinzenz Aleksey Gurtovoy schrieb:
Vinzenz 'evilissimo' Feenstra writes:
I've written a little Meta Template Program which should calculate the first 3 perfect numbers. ( range 1 - 500 )
The code is compilable if you use the range 1 - 30 really fast and works correctly. But I've tried to compile the code but I can't get it finished.
Someone tried it on a Machine with 40 GB RAM and it now compiles for more than 12 hours and uses more than 7.1 GB RAM ( the compilation )
I've tried it by myself with g++ 3.4.x and g++ 4.0.x and with VC++ 7.1
The code works on all tested compilers if the range would be 1 - 30 but If the range is 1 - 500 VC++ says:
d:\boost\vc71\include\boost-1_33_1\boost\mpl\aux_\preprocessed\plain\apply_wrap.hpp(48): fatal error C1204: compiler limit: internal structure overflow.
( This seems to be a known bug in VC++ http://support.microsoft.com/default.aspx?scid=kb;en-us;883655 )
and g++ compiles and compiles and uses more and more RAM.
Is the code really so evil slow or is it a compiler Bug in g++?
The former: your algorithm is basically O(n^2). For n=500, that's a lot of work for the compiler.
participants (3)
-
Aleksey Gurtovoy
-
evilissimo
-
Vinzenz 'evilissimo' Feenstra