How to run C++ programs on maya

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/hello_serial-cpp/hello-serial.cpp

We can compile with GCC’s C++ compiler.

[araim1@maya-usr1 hello_serial-cpp]$ g++ hello-serial.cpp -o hello-serial
[araim1@maya-usr1 hello_serial-cpp]$
[araim1@maya-usr1 hello_serial-cpp]$ ./hello-serial
Hello World!
[araim1@maya-usr1 hello_serial-cpp]$

Or we can use the Intel C++ compiler.

[jongraf1@maya-usr1 hello_serial-cpp]$ icpc hello-serial.cpp -o hello-serial
[jongraf1@maya-usr1 hello_serial-cpp]$ ./hello-serial
Hello World!
[jongraf1@maya-usr1 hello_serial-cpp]

Parallel Example

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


Download: ..code/hello_parallel-cpp/hello_parallel.cpp

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

[araim1@maya-usr1 hello_parallel-cpp]$ mpicxx hello_parallel.cpp -o hello_parallel
[araim1@maya-usr1 hello_parallel-cpp]$

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.