Saturday 15 February 2014

c++ - why i am not able to use MPI_Scatter() in the scope of a particular process? -


I know that there is no concept / meaning of global variable while working with OpenMPi and therefore when a specific thread is a Variable, values ​​of variables will still be set as default in other processes, I know the functionality of MPI_Scatter ().

When I use something like this,

  1 if (rank == 0) {// call MPI_Scatter () MPI_Scatter (data, 8, MPI_FLOAT , Pdata, 4, MPI_FLOAT, 0, MPI_COMM_WORLD); }   

With this code, each process (4) is considered to get 8 float numbers in the array pdata. But whatever is happening is only the root process (which is the one which has MPI_Scatter) and the other is still the initial value in pdata.

  2. If (rank == 0) {// to make a buffer which can be used in MPI_Scatter which will be said outside the sample (i, 0,16) {data [i] = i; }} MPI_Scatter (data, 8, MPI_FLOAT, pdata, 4, MPI_FLOAT, 0, MPI_COMM_WORLD); [/ Code>  

Since the data [] is a global variable, the value should not be accessible from other processes. However, in this case I am able to complete it correctly.

The interpretation of these two points will be very useful in terms of memory structure.

In your first example, call all > MPI_Scatter should call "as advertised." In your code, only the root process is calling it.

No comments:

Post a Comment