Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Computer Network & Security Expert

Programming Based on Message Passing

As we know, the programming model based on message passing uses high level programming languages like C/C++ along with a number of message passing libraries like PVM and MPI. Here, given an example program of message passing.

Example 1: Addition of array elements using two processors.

In this problem, we have to search the sum of all the elements of an array A of size n. We shall separate n elements into two groups of roughly equal size. The first [n/2] elements are added by the first processor, P0, and last [n/2] elements the by second processor, P1. The two sums then are added to get the final result. The program is given below:

Program for P0

#include

#define n 100

int main(int argc, char **argv) {

int A[n];

int sum0 =0, sum1=0,sum; MPI_Init(&argc, &argv);

for( int i=0;i

scanf("%d", &A[i]);

MPI_Send( &n/2, n/2, MPI_INT,1, 0, MPI_COMM_WORLD);

for(i=1; i

sum0+=A[i];

sum1=MPI_Recv(&n/2, n/2, MPI_INT,1, 0, MPI_COMM_WORLD);

sum=sum0+sum1; printf("%d",sum); MPI_Finalize();

}

Program for P1,

int func( int B[int n])

{

MPI_Recv(&n/2, n/2, MPI_INT,0, 0, MPI_COMM_WORLD);

int sum1=0 ;

for (i=0; i

sum1+=B[i];

MPI_Send( 0, n/2, MPI_INT,0, 0, MPI_COMM_WORLD);

}

Computer Network & Security, Computer Science

  • Category:- Computer Network & Security
  • Reference No.:- M9525799

Have any Question?


Related Questions in Computer Network & Security

Question in regards to encryption does the public key and

Question : In regards to encryption, does the public key and private key come from the sender or does the receiver already have the private and is given the public key by the sender? The response must be typed, single sp ...

Objectivespart 1 researching network attacks- research

Objectives Part 1: Researching Network Attacks - Research network attacks that have occurred. - Select a network attack and develop a report for presentation to the class. Part 2: Researching Network Security Audit Tools ...

Suppose there is no inflation and an insurance company

Suppose there is no inflation and an insurance company offers a contract that would pay $500,000 with certainty 50 years from now. What is the most that this contract would be worth today if: 1. The rate of interest is 7 ...

The software company niksoft is selling a new defense

The software company NikSoft is selling a new defense against DDoS attacks. Their software looks at the source IP address on all incoming packets, and if it finds any IP address that accounts for more than 1% of traffic ...

Sip encodingwhy does the session initiation protocol sip

SIP, ENCODING Why does the session initiation protocol SIP allow the sender and receiver to choose two different multimedia encoding schemes? Describe a scenario where it makes sense to use different protocols for sender ...

Advanced network design assessment - human factors in

Advanced Network Design Assessment - Human factors in network analysis and design Purpose of the assessment - This assignment is designed to assess students' knowledge and skills related to the following learning outcome ...

Part - athe assignmentwrite a critique review of the

Part - A The assignment Write a critique / review of the following paper: Mark Pollitt Eoghan Casey David-Olivier Jaquet-Chiffelle Pavel Gladyshev, "A Framework for Harmonizing Forensic Science Practices and Digital/Mult ...

Advanced wireless networks assignment -wlan design project

Advanced Wireless Networks Assignment - WLAN Design Project - Description: You need to form a group of at most four students, and select one of the case studies provided in Assessment module on VU Collaborate. In this pr ...

Assignment descriptionproject scope a typical network

Assignment Description Project Scope: A typical network layout diagram of a firm is given below for illustrative purposes only. The service requirements are enclosed. Figure. Network layout of a firm Service requirements ...

Backgroundyou have obtained a contract position at a small

Background: You have obtained a contract position at a small marketing and advertising firm called the Colour Ability Corporation (CAC). Your contract responsibilities are to help them plan their emerging networking and ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As