K
K
Kirill Batalin2016-05-15 14:59:50
C++ / C#
Kirill Batalin, 2016-05-15 14:59:50

MPI: How to notify a process about new messages?

There are many processes. Each process has a list of tasks. Each process has 2 threads.
The first thread computes tasks. If the tasks are over, it requests new ones from other processes.
The second thread waits for requests from other processes. If a request comes in, and there are extra tasks, then it gives them to another process.
On the machine where this system will run, mpi can only work with the MPI_THREAD_SERIALIZED flag (the programmer promises that threads will not call MPI functions at the same time). Therefore, the question arose: How to implement waiting for messages in the second thread? If I understand correctly, then blocking operations like mpi_recv are not suitable, since the first thread also needs to use the mpi functions. The non-blocking receive mpi_irecv is also not suitable, because the receive can start at any time (and at that moment the first thread can use the mpi functions).
How to implement waiting for messages in the second thread?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Arseniy Efremov, 2016-05-15
@arusef

You can simply capture the mutex for the duration of the data reception. However, based on common sense, your "multithreading" will come down to the fact that the threads will work in turn. Only one thread can be used, because MPI, in principle, implies the selection of processes for the number of computing cores in the system, and the presence of a second thread will only slow down the work. In this case, your process can receive task data in a non-blocking manner into some buffer, where after the task is completed, it will check for new tasks.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question