I tend to agree, the processing hit is very minimal. When you get into nested loops it may be somthing you want to consiter to hard code part of it.
With 3D games the video card is often the bottle neck, I have a 1.2 Gig processor, and a 9700 pro. I get higher frame rates then my friends with new 2.4-2.8 gig machines with a geforce 4.
Avoiding for loops
quote:
Original post by abdulla
Personally what i do is write a metaprogram to unroll the loop, some compilers refuse to do unrolling of loops (due to mixed results) unless you specify a compiler flag, and since you don''t really want all loops unrolled, just certain ones, i found that the best solution for me.
You [the programmer] don''t know what loops should be unrolled, in order to strike a balance between branch costs and cache thrashing. The compiler knows much more about the target architecture than you, and is in a considerably better position to decide which loops should be unrolled.
I challenge you to name a single major compiler written in the last few years that doesn''t automatically unroll loops when set to maximum optimization mode.
How appropriate. You fight like a cow.
quote:
Original post by Sneftel
You [the programmer] don''t know what loops should be unrolled, in order to strike a balance between branch costs and cache thrashing. The compiler knows much more about the target architecture than you, and is in a considerably better position to decide which loops should be unrolled.
Unless he writes optimizing compilers...
Death of one is a tragedy, death of a million is just a statistic.

If at first you don't succeed, redefine success.
quote:
Original post by python_regious
Unless he writes optimizing compilers...
If you had taken the time to look at his posting history, it would be obvious that he doesn''t.
How appropriate. You fight like a cow.
quote:
Original post by GamerSg
RPG''s, Action, strategy and all genres of games were made on Genesis, SNES which were 6mhz and 3mhz respectively. If that hardware could handle the games, todays mordern processors should not have any problem.
Yes, Genesis and SNES ran at very low clock speeds and got the job done very well, *BUT* they were dedicated to only videogame oriented processes. The CPU in your computer is sharing time for multiple processes that for the most part are not related to your game (real-time virus scan, Windows GUI, hardware monitor, even the OS itself among other things). Sure if we could all have a dedicated 3 GHz processor to specifically run all our games and nothing else there''d be no problem with framerates or polygon resolution. The sad fact is that we don''t. So we as programmers have to find every possible way to optimize our code (regardless of the compiler) so as to get the most bang for our buck. If I have unroll every static sized loop or write a little assembly code to make sure I''m getting what I want in machine code, I''ll do it to make the game run faster. Granted this is horrible in the way of source code updating (during development), so I only do it after all features are in.
---
K-1 Productions: Come visit us here.
---K-1 Productions: Come visit us here.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement