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
    program FortranTest1

    implicit none

    ! Variables
    real(8), parameter :: xStart = 0
    real(8), parameter :: xEnd = 3.141592653589793239
    real(8), parameter :: nSteps = 100000000 
            
    real(8) xStep
    real(8) allArea, stepArea
    integer step
    
    integer clock_start, clock_end, clock_rate
    real(8) elapsed_time    
   
    CALL SYSTEM_CLOCK(COUNT_RATE=clock_rate) ! Find the rate
    CALL SYSTEM_CLOCK(COUNT=clock_start) ! Start timing       

    ! Body of FortranTest1
    xStep = real(2 * xEnd - xStart) / real(nSteps)    
    allArea = 0
    
    do step=1,nSteps
        stepArea = xStep * (DSIN((step - 1) * xStep) + DSIN(step * xStep)) / 2.0
        allArea = allArea + stepArea      
    enddo   
    
    CALL SYSTEM_CLOCK(COUNT=clock_end) ! Stop timing
    ! Calculate the elapsed time in seconds:
    elapsed_time = real(clock_end-clock_start)/real(clock_rate) 
    
    print *, allArea
    print *, elapsed_time, " sec"    

    end program FortranTest1
 

Test Program 1 (C++): 

Code
#include "stdafx.h"
#include <math.h>
#include <stdio.h>
#include <time.h>
#include <iostream>
using namespace std;

int _tmain(int argc, _TCHAR* argv[])
{
    const double xStart = 0;
    const double xEnd = 3.141592653589793239;
    const int nSteps = 100000000; 
            
    double xStep = 0;
    double allArea = 0, stepArea = 0;
    int step = 0;
      
    xStep = (2.0 * xEnd - xStart) / (double)nSteps;    
    allArea = 0;

	clock_t start = clock(); 
   
    for(step=1; step <= nSteps; step++)
	{
        stepArea = xStep * (sin((step - 1) * xStep) + sin(step * xStep)) / 2.0;
        allArea = allArea + stepArea;     
	}   
    
	double diff = ( clock() - start ) / (double)CLOCKS_PER_SEC;

    cout << allArea << endl;
    cout << diff << endl;

	return 0;
}
 

Test Program 2 (Fortran):

Code
    program FortranTest1

    implicit none

    ! Variables
    real(8), parameter :: xStart = 0
    real(8), parameter :: xEnd = 3.141592653589793239
    real(8), parameter :: nSteps = 100000000 
    real(8), parameter :: tilt = 1.0
            
    real(8) xStep, xPos
    real(8) allArea, stepArea, xStepDiv2TimesTilt
    integer step
    
    integer clock_start, clock_end, clock_rate
    real(8) elapsed_time    
   
    CALL SYSTEM_CLOCK(COUNT_RATE=clock_rate) ! Find the rate
    CALL SYSTEM_CLOCK(COUNT=clock_start) ! Start timing       

    ! Body of FortranTest1
    xStep = real(2 * xEnd - xStart) / real(nSteps)    
    allArea = 0
	xStepDiv2TimesTilt = tilt * xStep / 2.0;    
    
    do step=1,nSteps
        xPos = step * xStep;
		stepArea = xStepDiv2TimesTilt * (xPos + xPos - xStep)
        allArea = allArea + stepArea      
    enddo   
    
    CALL SYSTEM_CLOCK(COUNT=clock_end) ! Stop timing
    ! Calculate the elapsed time in seconds: 
    elapsed_time = real(clock_end-clock_start)/real(clock_rate) 
    
    print *, allArea
    print *, elapsed_time, " sec"    

    end program FortranTest1
 

Test Program 2 (C++):

Code
int _tmain(int argc, _TCHAR* argv[])
{
    const double xStart = 0;
    const double xEnd = 3.141592653589793239;
    const int nSteps = 100000000;
    const double tilt = 1;
            
    double xStep = 0;
    double allArea = 0, stepArea = 0;
    int step = nSteps;
      
    xStep = (2.0 * xEnd - xStart) / (double)nSteps;    
    allArea = 0;
	double xStepDiv2TimesTilt = tilt * xStep / 2.0;

	clock_t start = clock(); 
    
    while(step--) 
	{
        const double xPos = step * xStep;
		stepArea = xStepDiv2TimesTilt * (xPos + xPos - xStep);
        allArea += stepArea;
	}   
    
	double diff = ( clock() - start ) / (double)CLOCKS_PER_SEC;

    cout << allArea << endl;
    cout << diff << endl;

	return 0;
}
 

 

 

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