第一个数据集执行时间增加的原因是什么?汇编指令是相同的。
当DN_FLUSH标志未开启时,第一个数据集需要63毫秒,第二个数据集需要15毫秒。当DN_FLUSH标志开启时,第一个数据集需要15毫秒,第二个数据集需要约0毫秒。
因此,在两种情况下,第一个数据集的执行时间都要长得多。
有没有办法减少执行时间,使其接近于第二个数据集?
我正在使用C++ Visual Studio 2005,/arch:SSE2 /fp:fast在Intel Core 2 Duo T7700 @ 2.4Ghz Windows XP Pro上运行。
当DN_FLUSH标志未开启时,第一个数据集需要63毫秒,第二个数据集需要15毫秒。当DN_FLUSH标志开启时,第一个数据集需要15毫秒,第二个数据集需要约0毫秒。
因此,在两种情况下,第一个数据集的执行时间都要长得多。
有没有办法减少执行时间,使其接近于第二个数据集?
我正在使用C++ Visual Studio 2005,/arch:SSE2 /fp:fast在Intel Core 2 Duo T7700 @ 2.4Ghz Windows XP Pro上运行。
#define NUMLOOPS 1000000
// Denormal values flushed to zero by hardware on ALPHA and x86
// processors with SSE2 support. Ignored on other x86 platforms
// Setting this decreases execution time from 63 milliseconds to 16 millisecond
// _controlfp(_DN_FLUSH, _MCW_DN);
float denormal = 1.0e-38;
float denormalTwo = 1.0e-39;
float denormalThree = 1;
tickStart = GetTickCount();
// Run First Calculation Loop
for (loops=0; loops < NUMLOOPS; loops++)
{
denormalThree = denormal - denormalTwo;
}
// Get execution time
duration = GetTickCount()-tickStart;
printf("Duration = %dms\n", duration);
float normal = 1.0e-10;
float normalTwo = 1.0e-2;
float normalThree = 1;
tickStart = GetTickCount();
// Run Second Calculation Loop
for (loops=0; loops < NUMLOOPS; loops++)
{
normalThree = normal - normalTwo;
}
// Get execution time
duration = GetTickCount()-tickStart;
printf("Duration = %dms\n", duration);