Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The purpose of this project is to practice MPI_Bcast. Complete the following C program using MPI to accomplish the following: 1. Process0 generate a random

The purpose of this project is to practice MPI_Bcast.

Complete the following C program using MPI to accomplish the following:

1. Process0 generate a random number for variable n in the range 10 to 99 inclusive and broadcast to all other processes.

2. All the processes use the built-in function: malloc to allocate n consecutive locations for the array variable: receive_vector.

3. Process0 generates n random integers in the range 0 to 99 inclusive and stores them into its own array: receive_vector.

4. Process0 broadcast the content of its array: receive_vector to the receive_vector of all other processes.

5. All the processes obtain and display the sum of the numbers of their own array: receive_vector.

The following is a sample dialog of my program:

mehdi@ubuntu:~/cs610$ mpicc -g -Wall a.c

mehdi@ubuntu:~/cs610$ mpiexec -n 10 ./a.out

In process 0 the sum is: 4593

In process 4 the sum is: 4593

In process 5 the sum is: 4593

In process 8 the sum is: 4593

In process 9 the sum is: 4593

In process 2 the sum is: 4593

In process 1 the sum is: 4593

In process 3 the sum is: 4593

In process 6 the sum is: 4593

In process 7 the sum is: 4593

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Advanced Accounting

Authors: Paul M. Fischer, William J. Tayler, Rita H. Cheng

11th edition

538480289, 978-0538480284

Students also viewed these Accounting questions