Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8696329
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T01:15:09+00:00 2026-06-13T01:15:09+00:00

In the following codes: if (rank==0) master(); else slave(); … void master() { int

  • 0

In the following codes:

if (rank==0) master();
else slave();

...

void master()
{
int i=0;
}

...

void slave()
{
int i=1;
MPI_BCAST(&i,1,MPI_INT,0,COMM);
}

Will the slave node broadcast “i(==0)” in the master node and set the “i” values in all slave nodes to be 0?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T01:15:10+00:00Added an answer on June 13, 2026 at 1:15 am

    It’s a little unclear from what you’ve posted that you have the semantics right — all processes in the communicator have to call MPI_BCAST, it’s one of MPI’s collective operations. Your program would then behave as if the process designated the root in the call to MPI_BCAST sends the message to all the other processes in the designated communicator which, in turn, receive the message.

    Your snippet suggests that you think that the call to MPI_BCAST would be successful if called only on what you call the ‘slave’ process(es), which would be incorrect.

    Your syntax for the call is, however, correct.

    EDIT in response to comment

    I believe that all processes have to execute the piece of code which calls MPI_BCAST. If, as you suggest, the pseudo-code is like this:

    if (myrank == master) then
       do_master_stuff ...
       call mpi_bcast(...)
    end if
    
    if (myrank /= master) then
       call mpi_bcast(...)
       do_worker_stuff ...
    end if
    

    then the call will fail; it’s likely that your program will stall until the job management or operating system notices and chucks it out. There is no mechanism within MPI for ‘matching’ calls to MPI_BCAST (or any of the other collective communications routines) across scopes.

    Your pseudo-code ought to be like this

    if (myrank == master) then
       do_master_stuff ...
    end if
    
    if (myrank /= master) then
       do_worker_stuff ...
    end if
    
    ! all together now
    call mpi_bcast(...)
    

    or whatever variant your program requires

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Please Check the following codes & please tell me about the error(s) I have
I can use the following codes to trim a string: -(void) aMethod { //
I know that using the following codes will make each column have unique values,
I have the following codes <div class=row-fluid> <div class=span6><img src = <?php echo $photo
I have used the following codes: bar([c f], 0.1,'stacked'); and bar( [c , f
I am trying the following codes to suffle the elements of an ArrayList -
I have this following codes: @implementation MyImageView @synthesize image; //image is a UIImage -
i have the following codes in SQL XML . I need to insert a
I am using the following codes, to replace a JLabel each 0.5 seconds, with
I run the following codes separately as my prompt unsuccessfully in .zshrc. This suggests

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.