Mail Archives: djgpp/1997/08/11/00:34:03
Georg Kolling wrote:
> /* VESA mode 640*480 already set, virtual width = 800 */
> ...
> _farsetsel (LFBsel); /* sets fs */
> time = rawclock ();
> for (co = 0; co < 100000000; co++)
> ppix ();
> time = rawclock () - time;
> ...
>
> I can compile and run this program, i can move the pixel by moving the
> mouse, i'm getting good performance (393 clockticks, about 4,6 mio.
> pixel per second) on a Pentium 100...BUT...
> if i compile with -O1, -O2 or -O3, the loop doesn't work! I can still
> move the pixel, but the loop never gets to an end (i inserted a little
> 'break' routine that stops when i press a mouse button; the result: co
> (which is unsigned long) had always a value of about 400 (random), no
> matter how many pixels it had actually put or how long the program was
> already running)
i am no expert on this so i may not be putting this exactly in the right
terms.
the optimizer probably realizes that you do not use the value of co in
the loop, and possibly never in the function (can't tell.) hence it
probably implements the loop in some other way (since it is supposed to
execute a fixed number of times) eliminating the constant
increment/test. did you look at the assembly output with optimization?
did you actually wait for 100,000,000 iterations? at the end of the
loop, co should contain the correct value 100,000,001 if the rest of the
function refers to it.
--
Sinan
*******************************************************************
A. Sinan Unur WWWWWW
|--O+O
mailto:sinan DOT unur AT cornell DOT edu C ^
http://www.people.cornell.edu/pages/asu1/ \ ~/
Unsolicited e-mail is _not_ welcome, and will be billed for.
*******************************************************************
- Raw text -