How to Run C++ Programs on taki

Introduction

Now we’ll see how to run a C++ program on the cluster. Before proceeding, make sure you’ve read the How To Run tutorial first.

Serial Example

Let’s try to compile this simple C++ program:


Download: ..code-2018/taki/hello_serial.cpp/hello-serial.cpp

We can use the Intel C++ compiler.

[reetam1@taki-usr1]$ icpc hello-serial.cpp -o hello-serial-intel
[reetam1@taki-usr1]$ ./hello-serial-intel
Hello World!
[reetam1@taki-usr1]$

Or we can compile with GCC’s C++ compiler.

[reetam1@taki-usr1]$ g++ hello-serial.cpp -o hello-serial-g
[reetam1@taki-usr1]$ ./hello-serial-g
Hello World!
[reetam1@taki-usr1]$

The list of available compilers for C++ can be found on the How to Compile page.

Parallel Example

Now we’ll try to run a slightly more complicated MPI C++ program


Download: ..code-2018/taki/Hello_Parallel.cpp/hello_parallel.cpp

The program can be compiled with the MPI C++ compiliation command:

[reetam1@taki-usr1]$ mpiicpc hello_parallel.cpp -o hello_parallel
[reetam1@taki-usr1]$

Running the hello_parallel program is now exactly the same as running a C MPI program. For more information, see How to run C programs.