Muhammad Ali Lab 3.docx

  • Uploaded by: Muhammad Ali
  • 0
  • 0
  • May 2020
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View Muhammad Ali Lab 3.docx as PDF for free.

More details

  • Words: 160
  • Pages: 3
MUHAMMAD ALI LAB 3

02-235162-021

PARALLEL PROGRAMMING

TASK 1: Execute and study the above sample code and display the output. Code: #include ; #include <mpi.h>; using namespace std; int main(int argc, char** argv) { int mynode, totalnodes; MPI_Init(&argc, &argv);

MPI_Comm_size(MPI_COMM_WORLD, &totalnodes); MPI_Comm_rank(MPI_COMM_WORLD, &mynode); cout << "Hello world from process " << mynode; cout << " of " << totalnodes << endl; MPI_Finalize(); std::getchar(); } OUTPUT:

TASK2:

MUHAMMAD ALI LAB 3

02-235162-021

PARALLEL PROGRAMMING

Write a program find whether a process is an even process or an odd process. Code: #include ; #include <mpi.h>; using namespace std; int main(int argc, char** argv) { int mynode, totalnodes; MPI_Init(&argc, &argv);

MPI_Comm_size(MPI_COMM_WORLD, &totalnodes); MPI_Comm_rank(MPI_COMM_WORLD, &mynode); cout << "Hello world from process " << mynode; cout << " of " << totalnodes << endl; if (mynode %2 == 0) { cout << "process is even"; } else { cout << "processor is odd"; } MPI_Finalize(); std::getchar(); } OUTPUT:

MUHAMMAD ALI LAB 3

02-235162-021

PARALLEL PROGRAMMING

Related Documents

Muhammad Ali
November 2019 32
Muhammad Ali
November 2019 27
Muhammad Ali
July 2020 19

More Documents from "Muhammad Ali"