Com(p)fy
Skip Navigation Links >> Community >> Technology Forums >> Compfy >> Compilers >> Performance >> Comparing optimization performance of Intel Fortran, Intel C++, and Microsoft C++ compilers
Contents
Skip Navigation Links.
ExpandFolder
Web Development ( Posts: 5 Last: 5/22/2010 )
CollapseFolder
Compilers ( Posts: 1 Last: 6/20/2010 )
ExpandFolder
 
Comparing optimization performance of Intel Fortran, Intel C++, and Microsoft C++ compilers
6/20/2010 9:16:18 PM Last modified: 6/20/2010 10:08:23 PM
Greg
Joined: 4/17/2010
Posts: 6

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):

Code
01program FortranTest1
02 
03implicit none
04 
05! Variables
06real(8), parameter :: xStart = 0
07real(8), parameter :: xEnd = 3.141592653589793239
08real(8), parameter :: nSteps = 100000000
09         
10real(8) xStep
11real(8) allArea, stepArea
12integer step
13 
14integer clock_start, clock_end, clock_rate
15real(8) elapsed_time   
16 
17CALL SYSTEM_CLOCK(COUNT_RATE=clock_rate) ! Find the rate
18CALL SYSTEM_CLOCK(COUNT=clock_start) ! Start timing      
19 
20! Body of FortranTest1
21xStep = real(2 * xEnd - xStart) / real(nSteps)   
22allArea = 0
23 
24do step=1,nSteps
25    stepArea = xStep * (DSIN((step - 1) * xStep) + DSIN(step * xStep)) / 2.0
26    allArea = allArea + stepArea     
27enddo  
28 
29CALL SYSTEM_CLOCK(COUNT=clock_end) ! Stop timing
30! Calculate the elapsed time in seconds:
31elapsed_time = real(clock_end-clock_start)/real(clock_rate)
32 
33print *, allArea
34print *, elapsed_time, " sec"   
35 
36end program FortranTest1
 

Test Program 1 (C++): 

Code
01#include "stdafx.h"
02#include <math.h>
03#include <stdio.h>
04#include <time.h>
05#include <iostream>
06using namespace std;
07 
08int _tmain(int argc, _TCHAR* argv[])
09{
10    const double xStart = 0;
11    const double xEnd = 3.141592653589793239;
12    const int nSteps = 100000000;
13             
14    double xStep = 0;
15    double allArea = 0, stepArea = 0;
16    int step = 0;
17       
18    xStep = (2.0 * xEnd - xStart) / (double)nSteps;   
19    allArea = 0;
20 
21    clock_t start = clock();
22    
23    for(step=1; step <= nSteps; step++)
24    {
25        stepArea = xStep * (sin((step - 1) * xStep) + sin(step * xStep)) / 2.0;
26        allArea = allArea + stepArea;    
27    }  
28     
29    double diff = ( clock() - start ) / (double)CLOCKS_PER_SEC;
30 
31    cout << allArea << endl;
32    cout << diff << endl;
33 
34    return 0;
35}
 

Test Program 2 (Fortran):

Code
01program FortranTest1
02 
03implicit none
04 
05! Variables
06real(8), parameter :: xStart = 0
07real(8), parameter :: xEnd = 3.141592653589793239
08real(8), parameter :: nSteps = 100000000
09real(8), parameter :: tilt = 1.0
10         
11real(8) xStep, xPos
12real(8) allArea, stepArea, xStepDiv2TimesTilt
13integer step
14 
15integer clock_start, clock_end, clock_rate
16real(8) elapsed_time   
17 
18CALL SYSTEM_CLOCK(COUNT_RATE=clock_rate) ! Find the rate
19CALL SYSTEM_CLOCK(COUNT=clock_start) ! Start timing      
20 
21! Body of FortranTest1
22xStep = real(2 * xEnd - xStart) / real(nSteps)   
23allArea = 0
24xStepDiv2TimesTilt = tilt * xStep / 2.0;   
25 
26do step=1,nSteps
27    xPos = step * xStep;
28    stepArea = xStepDiv2TimesTilt * (xPos + xPos - xStep)
29    allArea = allArea + stepArea     
30enddo  
31 
32CALL SYSTEM_CLOCK(COUNT=clock_end) ! Stop timing
33! Calculate the elapsed time in seconds:
34elapsed_time = real(clock_end-clock_start)/real(clock_rate)
35 
36print *, allArea
37print *, elapsed_time, " sec"   
38 
39end program FortranTest1
 

Test Program 2 (C++):

Code
01int _tmain(int argc, _TCHAR* argv[])
02{
03    const double xStart = 0;
04    const double xEnd = 3.141592653589793239;
05    const int nSteps = 100000000;
06    const double tilt = 1;
07             
08    double xStep = 0;
09    double allArea = 0, stepArea = 0;
10    int step = nSteps;
11       
12    xStep = (2.0 * xEnd - xStart) / (double)nSteps;   
13    allArea = 0;
14    double xStepDiv2TimesTilt = tilt * xStep / 2.0;
15 
16    clock_t start = clock();
17     
18    while(step--)
19    {
20        const double xPos = step * xStep;
21        stepArea = xStepDiv2TimesTilt * (xPos + xPos - xStep);
22        allArea += stepArea;
23    }  
24     
25    double diff = ( clock() - start ) / (double)CLOCKS_PER_SEC;
26 
27    cout << allArea << endl;
28    cout << diff << endl;
29 
30    return 0;
31}
 

 

 

Replies: Page: First Last  Posts/Page:
  Page: First Last  Posts/Page:


Registered users:
8
Users online:
1
Folders total:
18
Posts total:
6
Server timezone (for anonymous users):
(UTC-08:00) Pacific Time (US & Canada)
Powered by Com(p)fy