<div dir="ltr">Hi,<div><br></div><div>I have multithreaded MPI program (MPI_THREAD_MULTIPLE mode) with RMA calls.This is a simplified example:</div><div><br></div><div>#include <stdio.h><br>#include <mpi.h><br>#include <pthread.h><br><br>MPI_Win win;<br>pthread_mutex_t lock;<br><br>void *thread(void *arg)<br>{<br>    MPI_Win_lock_all(0, win);<br>    MPI_Win_unlock_all(win);<br>    return NULL;<br>}<br><br>int main(int argc, char *argv[])<br>{<br>    MPI_Init_thread(&argc, &argv, MPI_THREAD_MULTIPLE, NULL);<br>    pthread_mutex_init(&lock, NULL);<br><br>    int *buf = NULL;<br>    const int bufsize = 1;<br>    MPI_Alloc_mem(bufsize, MPI_INFO_NULL, &buf);<br>    MPI_Win_create(buf, 1, 1, MPI_INFO_NULL, MPI_COMM_WORLD, &win);<br><br>    pthread_t tid;<br>    pthread_create(&tid, NULL, thread, NULL);<br><br>    MPI_Win_lock_all(0, win);<br>    MPI_Win_unlock_all(win);<br><br>    pthread_join(tid, NULL);<br><br>    MPI_Win_free(&win);<br><br>    MPI_Finalize();<br><br>    return 0;<br>}<br></div><div><br></div><div>If I run such program, it crashes with an error message:</div><div><br></div><div>Fatal error in PMPI_Win_lock_all: Wrong synchronization of RMA calls , error stack:<br>PMPI_Win_lock_all(149).: MPI_Win_lock_all(assert=0, win=0xa0000000) failed<br>MPID_Win_lock_all(1522): Wrong synchronization of RMA calls<br></div><div><br></div><div>If I replace MPI_Win_lock_all with MPI_Win_lock the problem remains:</div><div><br></div><div>Fatal error in PMPI_Win_lock: Wrong synchronization of RMA calls , error stack:<br>PMPI_Win_lock(157).: MPI_Win_lock(lock_type=234, rank=0, assert=0, win=0xa0000000) failed<br>MPID_Win_lock(1163): Wrong synchronization of RMA calls<br></div><div><br></div><div>(this message is repeated many times)</div><div><br></div><div>If I protect RMA operations with a mutex, the problem disappears.<br></div><div><br></div><div>MPICH version 3.3. Similar problem is also in MVAPICH2 2.3.1.</div><div><br></div><div>Are the RMA operations not thread safe at the moment? Could you tell me how to deal with this problem?<br></div><div><br></div></div>