Explain use of mpi functions with an example, Computer Engineering

Assignment Help:

Q. Explain use of MPI functions with an example?

include

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

int i, tmp, sum, s, r, N, x[100];

MPI_Init(&argc, &argv);

MPI_Comm_size(MPI_COMM_WORLD, &s);

MPI_Comm_rank(MPI_COMM_WORLD, &r);

If(r==0)

 {

  printf( "Enter N:");

  scanf ("%d", &N);

  for (i=1; i

     MPI_Send(&N, 1, MPI_INT,i, i, MPI_COMM_WORLD);

  for (i=r, i

     sum+= x[i];  

 for (i=r, i

 {

   MPI_Recv(&tmp, 1, MPI_INT,i, i,  MPI_COMM_WORLD, &status);

   Sum+=tmp;

}

printf( "%d", sum);

}

else {

          MPI_Recv(&N, 1, MPI_INT,0, i, MPI_COMM_WORLD, &status);

          for (i=r, i

                sum+= x[i];  

          MPI_Send(&sum, 1, MPI_INT, 0, i, MPI_COMM_WORLD);

}

MPI_Finalize( );

}

 


Related Discussions:- Explain use of mpi functions with an example

Operating system, Difference between the symmetric and assymetric multiproc...

Difference between the symmetric and assymetric multiprocessing

Definitions of the procedures cons, Show that we can represent pairs of non...

Show that we can represent pairs of nonnegative integers using only numbers and arithmetic operations if we represent the pair a and b as the integer that is the product 2a3b. Give

Advantages offered by data mining, Advantages offered by Data Mining: 1...

Advantages offered by Data Mining: 1.  Facilitates discovery of knowledge from big, massive data sets. 2.  Can be used within dissimilar application areas by Fraud detection

Basic working of network layer, Q. Basic working of Network layer? Net...

Q. Basic working of Network layer? Network layer: Network layer is responsible for routing a packet within the subnet that is, from source to destination nodes across numerou

What is mqseries channel, Channel means logical communication link. There a...

Channel means logical communication link. There are two parts of channels a) Message channel, b) MQI channel   1) Mesage channel use for communication among QMgr to Q

Describe the instruction set architecture, Q. Describe the instruction set ...

Q. Describe the instruction set architecture? The significant role of the Central Processing Unit (CPU) is to perform calculations, to coordinate all other hardware components,

State the optimal route of node, State the optimal route of node Consid...

State the optimal route of node Consider the node i which has path length K+1, with the directly preceding node on the path being j. The distance to node i is w(j, i) plus the

Optical resolution of scanner, Optical resolution or hardware resolution is...

Optical resolution or hardware resolution is mechanical limit on resolution of Scanner. For scanning the sensor has to advance after every line it scans. Smallness of this advancem

What is master clock signal in control unit, Q. What is Master Clock Signal...

Q. What is Master Clock Signal in Control Unit? The Master Clock Signal: This signal causes micro-operations to be executed in a square. In a single clock cycle either a single

Importance of spectrum to the mobile sector, (a) The statement "Standards ...

(a) The statement "Standards create markets or markets create standards" has been the subject of considerable debate. Discuss the advantages and disadvantages to having multiple

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd