mpi - How to improve this programme to work master also -


in mpi programme works slave nodes. how modify work master also. because working of master improve performance of system.

int a,b,c, slaveid,recvid,root, rank,size;  mpi_init(&argc, &argv);  mpi_comm_rank(mpi_comm_world, &rank); mpi_comm_size(mpi_comm_world, &size);  /*-------------------------- master ------------------------------*/  if(rank == 0){      n =10;        for(slaveid=1; slaveid<size; slaveid++){         mpi_send(&n, 1, mpi_int, slaveid, 1, mpi_comm_world);     }      for(recvid=1; recvid<size; recvid++){         mpi_recv(&a, 1, mpi_int, recvid, 2, mpi_comm_world, &status);      printf(" id = %d , send = %d\n",recvid,a);     } }  /*-------------------------- slave ------------------------------*/  if(rank>0){      mpi_recv(&b, 1, mpi_int, 0, 1, mpi_comm_world, &status);      c = b*3;      mpi_send(&c, 1, mpi_int, 0, 2, mpi_comm_world);  }  mpi_finalize(); 

}

within block delimited

if(rank == 0){  } 

insert, @ appropriate location, line

work_like_a_slave(argument1, argument2,...) 

the appropriate location between loop sends messages , loop receives messages master isn't entirely idle while slaves toil.

whether has measurable impact on performance depends on number of factors question doesn't provide enough information on base guess; factors such as: how many slaves there , therefore how busy master sending , receiving messages, how work each process compared messaging does, etc.

be prepared, if numbers work against you, measurable impact negative, pressing master service slow down computation.


Comments

Popular posts from this blog

php - Why I am getting the Error "Commands out of sync; you can't run this command now" -

linux - Does gcc have any options to add version info in ELF binary file? -

java - Are there any classes that implement javax.persistence.Parameter<T>? -