Community
cancel
Showing results for 
Search instead for 
Did you mean: 
minjuprinces
Beginner
50 Views

performance problem

Hello.

I've been using intel c++ compiler from long ago.

I tested below code tocheck compiler performance than microsoft visual c++.

=====================================================================

int num_steps = 1000000000;

int _tmain(int argc, _TCHAR* argv[])

{

int i;

double x, step, sum;

DWORD start_time, end_time;

x = sum = 0.0;

step = 1.0 / (double)num_steps;

start_time = timeGetTime();

for(i = 0; i < num_steps; i++)

{

x = (i + 0.5) * step;

sum += 4.0 / (1.0 + x * x);

}

end_time = timeGetTime();

printf("PI = %.8f (Elapsed Time = %d)\\n", step * sum, end_time - start_time);

return 0;

}

the result is that elpsed time is 16, 562ms and microsoft visual c++ is 6910ms.
why this problem happend?
i saw that intel c++ compiler much faster than microsoft compiler in some case.
thanks a lot.

0 Kudos
4 Replies
TimP
Black Belt
50 Views

You didn't specify the options you gave the compilers, nor whether you use the 32- or 64-bit compilers, nor even which specific versions, which are crucial information.
For Intel 32-bit compilers prior to 11.0, you would require the option /QxW to engage optimization for such code. The best you could do with 32-bit MSVC would be /arch:SSE2 /fp:fast .
If you want optimization with default options on ia32, it's time to upgrade.
Also, it would be helpful if you would provide source code which can be compiled and tested. I'm not making much progress guessing what you have omitted. Although I might be able to make a similar C program, do we know whether it will reflect your intentions?
With minimum changes I can think of to turn it into working C code:
cl:
PI = 3.14159265 (Elapsed Time = 14656)
icl:
PI = 3.14159265 (Elapsed Time = 7312)
Kittur_G_Intel
Employee
50 Views

Hi,

Could you please provide a test case that can help recreate the issue with the compiler version you're testing with? Also, I agree with Tim, an upgrade would make sense. In addition, if you can give more details on all of the options you've used, the arch details etc., that would be helpful too...


-regards,
Kittur

Kittur_G_Intel
Employee
50 Views

Hi,
Just a friendly reminder on providing the test case you may have with the options you used to compile. The recreation of the same with the sample snippet you have wasn't successful (forgot to mention that in my earlier post). Appreciate if you can do attach the code - or you can create a private thread and attach too if you want it that way?
-thanks,
Kittur
Kittur_G_Intel
Employee
50 Views

Hi, just a friendly reminder. Could you please attach the reproducer if you can? Appreciate much.
-regards,
Kittur

Reply