The following test has been performed to compare optimization performance of Intel Fortran, Intel C++, and Microsoft C++ compilers. In summary, Intel compilers have significantly outperformed Microsoft compiler. Please see the results table below:
|
Intel Fortran
|
Intel C++
|
Microsoft C++
|
Test 1
|
2.173 sec
|
2.178 sec
|
9.627 sec
|
Test 2
|
0.09 sec
|
0.091 sec
|
0.204 sec
|
Test 1 computed an integral over SIN function from 0 to 2*Pi, using the trapezoidal rule and 100,000,000 steps. Test 2 computed an integral over a slope function with the slope of 1 from 0 to 2*Pi, using the trapezoidal rule and 100,000,000 steps. As we see in the results table above, Intel compiler has much better optimized the SIN function, outperforming Microsoft compiler almost by the factor of 5. In the second test, where only loops and basic mathematical operations have been used, Intel compiler has outperformed the Microsoft compiler by the factor of 2. No parallelization has been used in these tests.
Test Descriptions
Test environment:
- Microsoft Windows Vista x32
- Intel Core 2 CPU 6600 @ 2.4 GHz
- 2Gb RAM
Compiler versions:
- Intel Fortran - Visual Fortran 11.1.065 [IA-32]
- Intel C++ - C++ 11.1.065 [IA-32]
- Microsoft C++ - Visual Studio 2008
Compiler settings:
- Intel Fortran - Visual Fortran 11.1.065 [IA-32]

- Intel C++ - C++ 11.1.065 [IA-32]

- Microsoft C++ - Visual Studio 2008

Test Program 1 (Fortran):
06 | real(8), parameter :: xStart = 0 |
07 | real(8), parameter :: xEnd = 3.141592653589793239 |
08 | real(8), parameter :: nSteps = 100000000 |
11 | real(8) allArea, stepArea |
14 | integer clock_start, clock_end, clock_rate |
17 | CALL SYSTEM_CLOCK(COUNT_RATE=clock_rate) ! Find the rate |
18 | CALL SYSTEM_CLOCK(COUNT=clock_start) ! Start timing |
21 | xStep = real(2 * xEnd - xStart) / real(nSteps) |
25 | stepArea = xStep * (DSIN((step - 1) * xStep) + DSIN(step * xStep)) / 2.0 |
26 | allArea = allArea + stepArea |
29 | CALL SYSTEM_CLOCK(COUNT=clock_end) ! Stop timing |
30 | ! Calculate the elapsed time in seconds: |
31 | elapsed_time = real(clock_end-clock_start)/real(clock_rate) |
34 | print *, elapsed_time, " sec" |
36 | end program FortranTest1 |
Test Program 1 (C++):
08 | int _tmain( int argc, _TCHAR* argv[]) |
10 | const double xStart = 0; |
11 | const double xEnd = 3.141592653589793239; |
12 | const int nSteps = 100000000; |
15 | double allArea = 0, stepArea = 0; |
18 | xStep = (2.0 * xEnd - xStart) / ( double )nSteps; |
21 | clock_t start = clock (); |
23 | for (step=1; step <= nSteps; step++) |
25 | stepArea = xStep * ( sin ((step - 1) * xStep) + sin (step * xStep)) / 2.0; |
26 | allArea = allArea + stepArea; |
29 | double diff = ( clock () - start ) / ( double )CLOCKS_PER_SEC; |
31 | cout << allArea << endl; |
Test Program 2 (Fortran):
06 | real(8), parameter :: xStart = 0 |
07 | real(8), parameter :: xEnd = 3.141592653589793239 |
08 | real(8), parameter :: nSteps = 100000000 |
09 | real(8), parameter :: tilt = 1.0 |
12 | real(8) allArea, stepArea, xStepDiv2TimesTilt |
15 | integer clock_start, clock_end, clock_rate |
18 | CALL SYSTEM_CLOCK(COUNT_RATE=clock_rate) ! Find the rate |
19 | CALL SYSTEM_CLOCK(COUNT=clock_start) ! Start timing |
22 | xStep = real(2 * xEnd - xStart) / real(nSteps) |
24 | xStepDiv2TimesTilt = tilt * xStep / 2.0; |
28 | stepArea = xStepDiv2TimesTilt * (xPos + xPos - xStep) |
29 | allArea = allArea + stepArea |
32 | CALL SYSTEM_CLOCK(COUNT=clock_end) ! Stop timing |
33 | ! Calculate the elapsed time in seconds: |
34 | elapsed_time = real(clock_end-clock_start)/real(clock_rate) |
37 | print *, elapsed_time, " sec" |
39 | end program FortranTest1 |
Test Program 2 (C++):
01 | int _tmain( int argc, _TCHAR* argv[]) |
03 | const double xStart = 0; |
04 | const double xEnd = 3.141592653589793239; |
05 | const int nSteps = 100000000; |
06 | const double tilt = 1; |
09 | double allArea = 0, stepArea = 0; |
12 | xStep = (2.0 * xEnd - xStart) / ( double )nSteps; |
14 | double xStepDiv2TimesTilt = tilt * xStep / 2.0; |
16 | clock_t start = clock (); |
20 | const double xPos = step * xStep; |
21 | stepArea = xStepDiv2TimesTilt * (xPos + xPos - xStep); |
25 | double diff = ( clock () - start ) / ( double )CLOCKS_PER_SEC; |
27 | cout << allArea << endl; |
|