Python Threads + MPI
rountree at cs.uga.edu
Tue Oct 19 01:47:07 CEST 2004
I'd like to use a Python MPI wrapper (pypar, pyMPI, or ScientificPython) but
I can't get threading to work. I'd like individual threads responsible for
MPI_Send and MPI_Recv. Things tend to either work perfectly or hang,
depending on ordering and sleep times.
My best guess is that the signal waking up the C-level MPI_Recv gets snagged
by another thread, which promptly ignores it. (This theory is based
entirely on a single sentence culled from the thread module documentation:
"Threads interact strangely with interrupts".
I've also tried surrounding the C call to MPI_Recv with
Py_BEGIN_ALLOW_THREADS and Py_END_ALLOW_THREADS, to no avail.
I guess this boils down to: can I put C blocking socket calls in their own
Python threads and expect them to work? If so, how?
import Scientific.MPI as MPI
import threading as T
count = 0
print "Starting send of", count
MPI.world.send( "x"+str(count)+"x", 0, count )
print "Finished send of", count
count = 0
print "Starting recv"
x = MPI.world.receiveString()
print "Received", x
count += 1
r = Recver()
s = Sender()
More information about the Python-list