Day 5
05/12/2009 01:40
I've figured out what I need to do and how to do it, so creating a connection field proxy won't be too hard now. However, I encountered a new problem:
Until this point I was working only with blocking communication methods of mpi4py, ignoring the non-blocking ones. From the mpi4py manual:
Blocking Communications
MPI provides basic send and receive functions that are blocking. These functions block the caller until the data buffers involved in the communication can be safely reused by the application program.
In MPI for Python, the Send(), Recv() and Sendrecv() methods of communicator objects provide support
for blocking point-to-point communications within Intracomm and Intercomm instances. These methods can communicate memory buffers. The variants send(), recv() and sendrecv() can communicate general
Python objects.
Nonblocking Communications
On many systems, performance can be significantly increased by overlapping communication and computation. This is particularly true on systems where communication can be executed autonomously by an intelligent, dedi-cated communication controller.
MPI provides nonblocking send and receive functions. They allow the possible overlap of communication and computation. Non-blocking communication always come in two parts: posting functions, which begin the re-quested operation; and test-for-completion functions, which allow to discover whether the requested operation has completed.
In MPI for Python, the Isend() and Irecv() methods of the Comm class initiate a send and receive oper-
ation respectively. These methods return a Request instance, uniquely identifying the started operation. Its
completion can be managed using the Test(), Wait(), and Cancel() methods of the Request class. The
management of Request objects and associated memory buffers involved in communication requires a careful, rather low-level coordination. Users must ensure that objects exposing their memory buffers are not accessed at the Python level while they are involved in nonblocking message-passing operations.
Often a communication with the same argument list is repeatedly executed within an inner loop. In such cases, communication can be further optimized by using persistent communication, a particular case of nonblocking communication allowing the reduction of the overhead between processes and communication controllers. Furthermore , this kind of optimization can also alleviate the extra call overheads associated to interpreted, dynamic languages like Python.
In MPI for Python, the Send_init() and Recv_init() methods of the Comm class create a persistent request
for a send and receive operation respectively. These methods return an instance of the Prequest class, a subclass of the Request class. The actual communication can be effectively started using the Start() method, and its completion can be managed as previously described.
That's all fine, but the problem with recv() (blocking receive) is that if it has been called but nothing is sent to it yet (for example, another process spends some time computing the data it's about to send), the waiting process will eat up as much CPU resources as it can until it receives the data, which is a very bad thing if you're thinking optimisation.
Seems like now I have to look closer at non-blocking communication or something else, which is fine except for there are no tutorials for that provided with the mpi4py manual, API contains almost no useful info at all and googling for examples gave 0 results. Seems like there isn't a single person in the whole wide world is using mpi4py apart from me!!! Damn it.
However, it feels nice to be pioneering it=))
No comments:
Post a Comment