LZN's Blog CodePlayer

Start to play with C++ in Linux

2020-05-29
LZN

Now we spin-up for the next journey! We try to compile the first C++ program in the linux environment.

First we review the Big Three command line to invoke compilers:

  GNU INTEL PGI
FORTRAN gfortran ifort pgfortran
C gcc icc pgcc
C++ g++ icpc pgc++

Now we try a very simple program, do a loooong loop and see the CPU lapsed time!

#include <iostream>
#include <time.h>
 
using namespace std;
 
int main()
{
    for (int i = 0; i < 1000000000; i++)
    {
        i++;
    }
    cout << "Totle Time : " << (double)clock() /CLOCKS_PER_SEC<< "s" << endl;
    return 0;
}
  • G++: 1.53s
  • ICPC: 0s

Interesting! Here you see the optimization of the Intel compilers!

Updated 2020-05-29


Similar Posts

Comments