<div dir="ltr"><div><div>Hi,<br><br></div>I am a beginner and just try to use remote memory access, and I wrote a simple program to test it:<br><br>#include "mpi.h"<br>#include <stdio.h><br>#define SIZE 8<br>
<br>int main(int argc, char *argv[])<br>{<br> int numtasks, rank, source=0, dest, tag=1, i;<br> float a[64] =<br> {<br> 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0,<br>
1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0,<br> 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0,<br> 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0,<br>
};<br> float b[SIZE];<br><br> MPI_Status stat;<br><br> MPI_Init(&argc,&argv);<br> MPI_Comm_rank(MPI_COMM_WORLD, &rank);<br> MPI_Comm_size(MPI_COMM_WORLD, &numtasks);<br>
<br> MPI_Win win;<br><br> // check processor rank<br> char processor_name[MPI_MAX_PROCESSOR_NAME];<br> int name_len;<br> MPI_Get_processor_name(processor_name, &name_len);<br> printf("-- processor %s, rank %d out of %d processors\n", processor_name, rank, numtasks);<br>
<br> MPI_Barrier(MPI_COMM_WORLD);<br><br> if (numtasks == 4) {<br> if (rank == 0) {<br> printf("create window \n");<br> MPI_Win_create(a, 8*sizeof(float), sizeof(float), MPI_INFO_NULL, MPI_COMM_WORLD, &win);<br>
<br> }<br> else {<br> MPI_Win_create(MPI_BOTTOM, 0, sizeof(float), MPI_INFO_NULL, MPI_COMM_WORLD, &win);<br> }<br><br> MPI_Win_fence(0, win);<br>
<br> if (rank == 1){<br> MPI_Get(b, SIZE, MPI_FLOAT, 0, 8, SIZE, MPI_FLOAT, win);<br><br> MPI_Win_fence(0, win);<br> }<br><br> printf("rank= %d b= %3.1f %3.1f %3.1f %3.1f %3.1f %3.1f %3.1f %3.1f\n", rank,b[0],b[1],b[2],b[3],b[4],b[5],b[6],b[7]);<br>
}<br> else<br> printf("Must specify %d processors. Terminating.\n",SIZE);<br><br> MPI_Win_free(&win);<br> MPI_Finalize();<br>}<br><br></div><div>However the terminal gives some odd results:<br>
rank= 0 b= 0.0 0.0 0.0 0.0 0.0 0.0 -71847793475452928.0 0.0<br>rank= 2 b= 0.0 0.0 0.0 0.0 0.0 0.0 222086852849451401216.0 0.0<br>rank= 3 b= 0.0 0.0 0.0 0.0 0.0 0.0 -74882.4 0.0<br>rank= 1 b= 9.0 10.0 11.0 12.0 13.0 14.0 15.0 16.0<br>
</div><div>the rank 1 is correct results, but others should be all zero.<br></div><div>terminal also give some comments: "Assertion failed in file src/mpid/ch3/src/ch3u_rma_sync.c at line 5061: win_ptr->my_counter >= 0<br>
internal ABORT - process 0"<br></div><div><br></div><div>another question is if I use remote memory access. all process which does not create window for share must add additional line: MPI_Win_create(MPI_BOTTOM, 0, data_type, MPI_INFO_NULL, MPI_COMM_WORLD, &win); correct?<br>
<br></div><div>Thanks a lot!<br></div><div><br></div><div><div><div>-- <br>Best Regards,<div>Sufeng Niu</div><div>ECASP lab, ECE department, Illinois Institute of Technology</div><div>Tel: 312-731-7219</div>
</div></div></div></div>