1 / 7

Running on GCB part1

Running on GCB part1. By: Camilo Silva. Simple steps to run MPI. Use putty or the terminal SSH to gcb.fiu.edu Loggin by providing your username and password. You are in!. You should have a screen similar to this one:. Time to program!. /*

lani-wade
Download Presentation

Running on GCB part1

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Running on GCBpart1 By: Camilo Silva

  2. Simple steps to run MPI • Use putty or the terminal • SSH to gcb.fiu.edu • Loggin by providing your username and password

  3. You are in! • You should have a screen similar to this one:

  4. Time to program! /* "Hello World" example for 2 processors. Initially, both processors have status "I am alone!". Each sends out a "Hello World" to the other. Upon receiving each other's message, the status changes to what is received. */ #include "mpi.h" #include <stdio.h> int main(int argc, char** argv) { int MyProc, tag=0; char msg[12]="Hello World"; char msg_recpt[12]="I am alone!"; MPI_Status status; MPI_Init(&argc, &argv); MPI_Comm_rank(MPI_COMM_WORLD, &MyProc); printf("Process# %d started \n", MyProc); MPI_Barrier(MPI_COMM_WORLD); if (MyProc== 0) { printf("Proc#0: %s \n", msg_recpt) ; printf("Sendingmessage to Proc #1: %s \n", msg) ; MPI_Send(&msg, 12, MPI_CHAR, 1, tag, MPI_COMM_WORLD); MPI_Recv(&msg_recpt, 12, MPI_CHAR, 1, tag, MPI_COMM_WORLD, &status); printf("Receivedmessage from Proc #1: %s \n", msg_recpt) ; } else { printf("Proc#1: %s \n", msg_recpt) ; MPI_Recv(&msg_recpt, 12, MPI_CHAR, 0, tag, MPI_COMM_WORLD, &status); printf("Receivedmessage from Proc #0: %s \n", msg_recpt) ; printf("Sendingmessage to Proc #0: %s \n", msg) ; MPI_Send(&msg, 12, MPI_CHAR, 0, tag, MPI_COMM_WORLD); } MPI_Finalize(); } Using vi, pico, or nano, or your favorite text editor code the following program:

  5. What next? • Submit the following command in the terminal: PATH=/opt/mpich/gnu/bin:$PATH • That line will add mpich to your path

  6. One last step… • Before compiling and running you must sent the following command: • [username~]$lamboot –v Then, compile the program: • mpicc –o hello hello.c Finally run it: • mpirun –v –np 2 hello Check the man for details of the functions and parameters

  7. Results:

More Related