Hi, Glob2 got vectorized when using g++- 4.0.1 and the following command line options on x86: -ftree-vectorize -march=pentium4 -O3 -ftree-vectorizer-verbose=1
Result of autovectorization: Cmd line to produce this output was: grep "LOOP VECTORIZED\|vectorized .* loops" g2dump | grep -v "vectorized 0 loops" where g2dump is generated by: make >& /tmp/g2dump with tcsh in glob2's directory /usr/lib/gcc/i486-linux-gnu/4.0.1/../../../../include/c++/4.0.1/bits/valarray_array.h:127: note: LOOP VECTORIZED. GraphicContext.cpp:273: note: vectorized 1 loops in function. GraphicContext.cpp:556: note: LOOP VECTORIZED. GraphicContext.cpp:524: note: vectorized 1 loops in function. GraphicContext.cpp:707: note: LOOP VECTORIZED. GraphicContext.cpp:670: note: vectorized 1 loops in function. /usr/lib/gcc/i486-linux-gnu/4.0.1/../../../../include/c++/4.0.1/bits/stl_algobase.h:542: note: LOOP VECTORIZED. StreamBackend.cpp:40: note: vectorized 1 loops in function. AINumbi.cpp:50: note: LOOP VECTORIZED. AINumbi.cpp:41: note: vectorized 1 loops in function. AICastor.cpp:135: note: LOOP VECTORIZED. AICastor.cpp:122: note: vectorized 1 loops in function. AICastor.cpp:1903: note: LOOP VECTORIZED. AICastor.cpp:1899: note: vectorized 1 loops in function. AICastor.cpp:135: note: LOOP VECTORIZED. AICastor.cpp:149: note: vectorized 1 loops in function. AICastor.cpp:135: note: LOOP VECTORIZED. AICastor.cpp:149: note: vectorized 1 loops in function. AICastor.cpp:135: note: LOOP VECTORIZED. AICastor.cpp:158: note: vectorized 1 loops in function. AICastor.cpp:135: note: LOOP VECTORIZED. AICastor.cpp:158: note: vectorized 1 loops in function. AICastor.cpp:1903: note: LOOP VECTORIZED. AICastor.cpp:1903: note: LOOP VECTORIZED. AICastor.cpp:403: note: vectorized 2 loops in function. Building.cpp:263: note: LOOP VECTORIZED. Building.cpp:157: note: vectorized 1 loops in function. Building.cpp:95: note: LOOP VECTORIZED. Building.cpp:138: note: LOOP VECTORIZED. Building.cpp:46: note: vectorized 2 loops in function. Building.cpp:95: note: LOOP VECTORIZED. Building.cpp:138: note: LOOP VECTORIZED. Building.cpp:46: note: vectorized 2 loops in function. Engine.cpp:51: note: LOOP VECTORIZED. Engine.cpp:48: note: vectorized 1 loops in function. Engine.cpp:51: note: LOOP VECTORIZED. Engine.cpp:48: note: vectorized 1 loops in function. GUIMapPreview.cpp:152: note: LOOP VECTORIZED. GUIMapPreview.cpp:63: note: vectorized 1 loops in function. /usr/lib/gcc/i486-linux-gnu/4.0.1/../../../../include/c++/4.0.1/bits/stl_algobase.h:542: note: LOOP VECTORIZED. Game.cpp:1150: note: vectorized 1 loops in function. Game.cpp:135: note: LOOP VECTORIZED. Game.cpp:97: note: vectorized 1 loops in function. GameGUI.cpp:239: note: LOOP VECTORIZED. GameGUI.cpp:174: note: vectorized 1 loops in function. NetGame.cpp:176: note: LOOP VECTORIZED. NetGame.cpp:179: note: LOOP VECTORIZED. NetGame.cpp:167: note: vectorized 2 loops in function. NetGame.cpp:176: note: LOOP VECTORIZED. NetGame.cpp:179: note: LOOP VECTORIZED. NetGame.cpp:111: note: LOOP VECTORIZED. NetGame.cpp:120: note: LOOP VECTORIZED. NetGame.cpp:160: note: LOOP VECTORIZED. NetGame.cpp:99: note: vectorized 5 loops in function. NetGame.cpp:1435: note: LOOP VECTORIZED. NetGame.cpp:1448: note: LOOP VECTORIZED. NetGame.cpp:1333: note: vectorized 2 loops in function. NetGame.cpp:68: note: LOOP VECTORIZED. NetGame.cpp:176: note: LOOP VECTORIZED. NetGame.cpp:179: note: LOOP VECTORIZED. NetGame.cpp:35: note: vectorized 3 loops in function. NetGame.cpp:68: note: LOOP VECTORIZED. NetGame.cpp:176: note: LOOP VECTORIZED. NetGame.cpp:179: note: LOOP VECTORIZED. NetGame.cpp:35: note: vectorized 3 loops in function. SessionConnection.cpp:25: note: LOOP VECTORIZED. SessionConnection.cpp:22: note: vectorized 1 loops in function. SessionConnection.cpp:25: note: LOOP VECTORIZED. SessionConnection.cpp:22: note: vectorized 1 loops in function. Team.cpp:175: note: LOOP VECTORIZED. Team.cpp:178: note: LOOP VECTORIZED. Team.cpp:173: note: vectorized 2 loops in function. Team.cpp:175: note: LOOP VECTORIZED. Team.cpp:178: note: LOOP VECTORIZED. Team.cpp:143: note: vectorized 2 loops in function. Team.cpp:175: note: LOOP VECTORIZED. Team.cpp:178: note: LOOP VECTORIZED. Team.cpp:143: note: vectorized 2 loops in function. Team.cpp:175: note: LOOP VECTORIZED. Team.cpp:178: note: LOOP VECTORIZED. Team.cpp:153: note: vectorized 2 loops in function. Team.cpp:175: note: LOOP VECTORIZED. Team.cpp:178: note: LOOP VECTORIZED. Team.cpp:153: note: vectorized 2 loops in function. UnitType.cpp:25: note: LOOP VECTORIZED. UnitType.cpp:23: note: vectorized 1 loops in function. UnitType.cpp:93: note: LOOP VECTORIZED. UnitType.cpp:91: note: vectorized 1 loops in function. UnitType.cpp:107: note: LOOP VECTORIZED. UnitType.cpp:105: note: vectorized 1 loops in function. UnitType.cpp:25: note: LOOP VECTORIZED. UnitType.cpp:36: note: vectorized 1 loops in function. MultiplayersHost.cpp:240: note: LOOP VECTORIZED. MultiplayersHost.cpp:238: note: vectorized 1 loops in function. MultiplayersHost.cpp:240: note: LOOP VECTORIZED. MultiplayersHost.cpp:632: note: vectorized 1 loops in function. MultiplayersHost.cpp:240: note: LOOP VECTORIZED. MultiplayersHost.cpp:381: note: vectorized 1 loops in function. MultiplayersHost.cpp:240: note: LOOP VECTORIZED. MultiplayersHost.cpp:1323: note: vectorized 1 loops in function. MultiplayersHost.cpp:240: note: LOOP VECTORIZED. MultiplayersHost.cpp:868: note: vectorized 1 loops in function. MultiplayersHost.cpp:240: note: LOOP VECTORIZED. MultiplayersHost.cpp:35: note: vectorized 1 loops in function. MultiplayersHost.cpp:240: note: LOOP VECTORIZED. MultiplayersHost.cpp:35: note: vectorized 1 loops in function. MultiplayersCrossConnectable.cpp:382: note: LOOP VECTORIZED. MultiplayersCrossConnectable.cpp:354: note: LOOP VECTORIZED. MultiplayersCrossConnectable.cpp:330: note: LOOP VECTORIZED. MultiplayersCrossConnectable.cpp:304: note: vectorized 3 loops in function. MapGenerationDescriptor.cpp:42: note: LOOP VECTORIZED. MapGenerationDescriptor.cpp:27: note: vectorized 1 loops in function. MapGenerationDescriptor.cpp:42: note: LOOP VECTORIZED. MapGenerationDescriptor.cpp:27: note: vectorized 1 loops in function. EndGameScreen.cpp:183: note: LOOP VECTORIZED. EndGameScreen.cpp:107: note: vectorized 1 loops in function. EndGameScreen.cpp:183: note: LOOP VECTORIZED. EndGameScreen.cpp:107: note: vectorized 1 loops in function. /usr/lib/gcc/i486-linux-gnu/4.0.1/../../../../include/c++/4.0.1/bits/valarray_array.h:127: note: LOOP VECTORIZED. BitArray.cpp:88: note: vectorized 1 loops in function. /usr/lib/gcc/i486-linux-gnu/4.0.1/../../../../include/c++/4.0.1/bits/valarray_array.h:127: note: LOOP VECTORIZED. /usr/lib/gcc/i486-linux-gnu/4.0.1/../../../../include/c++/4.0.1/bits/valarray_array.h:127: note: LOOP VECTORIZED. BitArray.cpp:42: note: vectorized 2 loops in function. Statistics: The number of loops vectorized has been counted by: grep "LOOP VECTORIZED" g2dump | wc -l The number of loop not vectorized has been counted by: grep "vectorized 0 loops" g2dump | wc -l 72 loops vectorized 879 loops that could not have been vectorized for some reason Analysis As you can see, there is a lot of loops that could be, but have not been vectorized because of missalignements and so on. g++ gives very detailed explanations why loops have not been vectorized (providing a debug level -ftree-vectorizer-verbose greater than one or the use of -fdump-tree-vect to dump all vectorized infos in SOURCEFILE.vect). So there is plenty of room for optimisation there, I suggest anyway to wait for g++ 4.1 and test on different plateforms before modifying any code to optimise the autovectorization. Conclusion Right now g++ 4 is able to autovectorized array filling with constant value and array copy, if alignement matches. It doesn't seem to be yet able to vectorize loops where complex operations take place (i.e. image blitting with alpha blending), but the structure is in place and we can expect much better result with g++ 4.1. Anyway, the autovectorizer output can help you to optimize your programs. Have fun, Steph P.S. Compilation went faster than with g++-3.X, but I don't have numbers -- http://nct.ysagoon.com _______________________________________________ glob2-devel mailing list [email protected] http://lists.nongnu.org/mailman/listinfo/glob2-devel
