I have two questions regarding using mpi shared memory communication
1) If I have a MPI rank which is the only one that writes to a window, is it necessary to employ mpi_win_lock, and mpi_win_unlock? I know that my application would never have others trying to write to that window. They only read the content of the window, and I make sure that they read after a MPI_BARRIER, so the content of the window has been updated.
2) In my application I have one MPI rank, which allocates a shared window that needs to be read by 1:N other MPI ranks.
MPI rank 1 shall only read: rma(1:10)
MPI rank 2 shall only read rma(11:20)
MPI rank N shall only read rma(10*(N-1)+1:10*N)
Currently, all 1 to N ranks are querying the whole shared window, i.e. the size "10*N" with MPI_WIN_SHARED_QUERY.
I am asking if it is possible to apply the MPI_WIN_SHARED_QUERY function such that MPI rank 1 only can access the window from 1:10 and rank 2 from 11:20 etc.
In this way, each rank has a local accessing from 1:10 but they refer to different chunks of the shared window? Is this possible?
Thanks very much!
UPDATE
Based on the below answer seems to do what I want. But it does not work when using MPI_WIN_SHARED_QUERY
However, I dont understand how the local pointers are pointing to different sections of the array automatically. How does it know how do it. The only thing you are doing is doing the c_f_pointer
call with the size being nlocal=5. How does it know that e.g. rma for rank 3 must access 5 places beginning from 16-20. It is really not clear to me, and I am concerned whether it is portable i.e. can I rely on it?