Shared memory access control mechanism for processes created by MPI

守給你的承諾、 提交于 2020-01-11 04:15:30

问题


I have a shared memory used by multiple processes, these processes are created using MPI.

Now I need a mechanism to control the access of this shared memory.

I know that named semaphore and flock mechanisms can be used to do this but just wanted to know if MPI provides any special locking mechanism for shared memory usage ?

I am working on C under Linux.


回答1:


MPI actually does provide support for shared memory now (as of version 3.0). You might try looking at the One-sided communication chapter (http://www.mpi-forum.org/docs/mpi-3.0/mpi30-report.pdf) starting with MPI_WIN_ALLOCATE_SHARED (11.2.3). To use this, you'll have to make sure you have an implementation that supports it. I know that the most recent versions of both MPICH and Open MPI work.




回答2:


No, MPI doesn't provide any support for shared memory. In fact, MPI would not want to support shared memory. The reason is that a program written with MPI is supposed to scale to a large number of processors, and a large number of processors never have shared memory.

However, it may happen, and often does, that groups of small number of processors (in that set of large number of processors) do have shared memory. To utilize that shared memory however, OpenMP is used.

OpenMP is very simple. I strongly suggest you learn it.



来源:https://stackoverflow.com/questions/17081802/shared-memory-access-control-mechanism-for-processes-created-by-mpi

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!