2020-02-15 20:01:48 +00:00
|
|
|
//$WW,1$You may wonder why I use "&" instead of "%".
|
|
|
|
|
2020-02-20 23:40:10 +00:00
|
|
|
#define SAMPLE_SIZE 100000000
|
2020-02-15 20:01:48 +00:00
|
|
|
|
|
|
|
U0 TimeIns()
|
|
|
|
{
|
2020-02-20 23:40:10 +00:00
|
|
|
I64 start1,end1,start2,end2,overhead_time,test_time;
|
|
|
|
I64 reg i,reg tmp;
|
|
|
|
|
|
|
|
CPURep;
|
|
|
|
|
|
|
|
//Measure Loop Overhead
|
2020-03-19 20:59:53 +00:00
|
|
|
start1=TSCGet;
|
2020-02-20 23:40:10 +00:00
|
|
|
for (i=0;i<SAMPLE_SIZE;i++) {
|
|
|
|
}
|
2020-03-19 20:59:53 +00:00
|
|
|
end1=TSCGet;
|
2020-02-20 23:40:10 +00:00
|
|
|
overhead_time=end1-start1;
|
|
|
|
|
|
|
|
//Measure remainder...
|
2020-03-19 20:59:53 +00:00
|
|
|
start2=TSCGet;
|
2020-02-20 23:40:10 +00:00
|
|
|
for (i=0;i<SAMPLE_SIZE;i++)
|
|
|
|
tmp=i%0x400;
|
2020-03-19 20:59:53 +00:00
|
|
|
end2=TSCGet;
|
2020-02-20 23:40:10 +00:00
|
|
|
test_time=end2-start2;
|
|
|
|
"Remainder Version #1 Cycles\t: %10.5f\n",
|
|
|
|
ToF64(test_time-overhead_time)/SAMPLE_SIZE;
|
|
|
|
|
|
|
|
//Measure remainder...
|
2020-03-19 20:59:53 +00:00
|
|
|
start2=TSCGet;
|
2020-02-20 23:40:10 +00:00
|
|
|
for (i=0;i<SAMPLE_SIZE;i++)
|
|
|
|
tmp=i&0x3FF;
|
2020-03-19 20:59:53 +00:00
|
|
|
end2=TSCGet;
|
2020-02-20 23:40:10 +00:00
|
|
|
test_time=end2-start2;
|
|
|
|
"Remainder Version #2 Cycles\t: %10.5f\n",
|
|
|
|
ToF64(test_time-overhead_time)/SAMPLE_SIZE;
|
2020-02-15 20:01:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
TimeIns;
|
|
|
|
|
2020-02-20 23:40:10 +00:00
|
|
|
/* Program Output$HL,0$$WW+H,1$$FD,1$
|
2020-02-15 20:01:48 +00:00
|
|
|
8 Cores 2.660GHz
|
2020-02-20 23:40:10 +00:00
|
|
|
Remainder Version #1 Cycles : 26.85345
|
|
|
|
Remainder Version #2 Cycles : -0.00800
|
2020-02-15 20:01:48 +00:00
|
|
|
$HL,1$*/
|