This is the code of FDIV loop:
fa=(float)random(1,2);
fb=(float)random(1,1000);
fb=0; // this line must be suppressed
fg=0;
le=random(1,2);
elapsed=micros();
for (lc=le; lc<(le+30000); lc++)
{
fb=fb/fa;
}
elapsed=micros()-elapsed;
If fb is initialized to 0, then all operations are 0./fa, so this initialization must be suppressed, and also in the DDIV loop.
The use of variables fg and dg is useless, and may be suppressed.
The operation in for is a overcharge.
Proposed code for FDIV:
fa=(float)random(1,2);
fb=(float)random(1,1000);
le=random(1,2);
lg=le+30000;
elapsed=micros();
for (lc=le; lc<lg); lc++) //this syntax avoid compiler semplifications?
{
fb=fb/fa;
}
elapsed=micros()-elapsed;
// compute MIPS and display
The int loop may be a ISUM
ia=random(1,2);
ib=random(1,1000);
le=random(1,2);
lg=le+30000;
elapsed=micros();
for (lc=le; lc<lg; lc++) //this syntax avoid compiler semplifications?
{
ib=ib+ia;
}
elapsed=micros()-elapsed;
// compute MIPS and display