psum example fails: mismatch between mpi4py 1.1.0 and ipython 0.10 documentation

Bug #450025 reported by J.Thomas
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
IPython
Fix Committed
Undecided
Brian Granger

Bug Description

mpi4py version: 1.1.0 -- this is the relevant package
ipython version: 0.10 -- actually a problem with the documentation
python version: 2.6.3 -- likely any version of python

I am unable to run the MPI "psum" example appearing in the documentation for ipython version 0.10. The psum code can be found on page 81. Here is the (very short) function definition, as it appears in the document (ipython-0.10.pdf):

    from mpi4py import MPI
    import numpy as np
    def psum(a):
        s = np.sum(a)
        return MPI.COMM_WORLD.Allreduce(s,MPI.SUM)

The example continues on page 82, where the user is invited to enter

    In [8]: px s = psum(a)

and it is at this point that ipython begins to complain

    ERROR: An unexpected error occurred while tokenizing input
    The following traceback may be corrupted or invalid
    The error message is: ('EOF in multi-line statement', (9, 0))
    ...

mercifully ending at last with

    CompositeError: one or more exceptions from call to method: execute
    [0:execute]: TypeError: message: expecting a list or tuple
    ...

The problem is that the Allreduce function invoked in psum.py does not have the proper signature for mpi4py1.1.0, which looks like this:

    In [23]: help(MPI.COMM_WORLD.Allreduce)
    Allreduce(...)
        Comm.Allreduce(self, sendbuf, recvbuf, Op op=SUM)

To make matters worse, (as far as I can tell) the positional arguments can not be ignored -- both are required. And even worse yet, these positional arguments need to be lists. Here is a version of psum.py that does work with mpi1.1.0

    from mpi4py import MPI
    import numpy as np
    def pdum(a):
        s = np.sum(a)
        rcvBuf = np.array(0.0,'d')
          MPI.COMM_WORLD.Allreduce([s, MPI.DOUBLE],
            [rcvBuf, MPI.DOUBLE],
            op=MPI.SUM)
        return rcvBuf

There are likely other incantations that will work -- this is just the closest to the given code that I could come up with. One thing is certain: the example as supplied will not work with mpi4py1.1.0.

Revision history for this message
Brian Granger (ellisonbg) wrote : Re: [Bug 450025] [NEW] psum example fails: mismatch between mpi4py 1.1.0 and ipython 0.10 documentation
Download full text (4.9 KiB)

Thanks,

I will fix this example. I haven't updated my mpi4py installations to
1.1.0.

Cheers,

Brian

On Mon, Oct 12, 2009 at 7:20 PM, J.Thomas <email address hidden> wrote:

> Public bug reported:
>
>
> mpi4py version: 1.1.0 -- this is the relevant package
> ipython version: 0.10 -- actually a problem with the documentation
> python version: 2.6.3 -- likely any version of python
>
> I am unable to run the MPI "psum" example appearing in the documentation
> for ipython version 0.10. The psum code can be found on page 81. Here
> is the (very short) function definition, as it appears in the document
> (ipython-0.10.pdf):
>
> from mpi4py import MPI
> import numpy as np
> def psum(a):
> s = np.sum(a)
> return MPI.COMM_WORLD.Allreduce(s,MPI.SUM)
>
> The example continues on page 82, where the user is invited to enter
>
> In [8]: px s = psum(a)
>
> and it is at this point that ipython begins to complain
>
> ERROR: An unexpected error occurred while tokenizing input
> The following traceback may be corrupted or invalid
> The error message is: ('EOF in multi-line statement', (9, 0))
> ...
>
> mercifully ending at last with
>
> CompositeError: one or more exceptions from call to method: execute
> [0:execute]: TypeError: message: expecting a list or tuple
> ...
>
>
> The problem is that the Allreduce function invoked in psum.py does not have
> the proper signature for mpi4py1.1.0, which looks like this:
>
> In [23]: help(MPI.COMM_WORLD.Allreduce)
> Allreduce(...)
> Comm.Allreduce(self, sendbuf, recvbuf, Op op=SUM)
>
> To make matters worse, (as far as I can tell) the positional arguments
> can not be ignored -- both are required. And even worse yet, these
> positional arguments need to be lists. Here is a version of psum.py
> that does work with mpi1.1.0
>
> from mpi4py import MPI
> import numpy as np
> def pdum(a):
> s = np.sum(a)
> rcvBuf = np.array(0.0,'d')
> MPI.COMM_WORLD.Allreduce([s, MPI.DOUBLE],
> [rcvBuf, MPI.DOUBLE],
> op=MPI.SUM)
> return rcvBuf
>
> There are likely other incantations that will work -- this is just the
> closest to the given code that I could come up with. One thing is
> certain: the example as supplied will not work with mpi4py1.1.0.
>
> ** Affects: ipython
> Importance: Undecided
> Status: New
>
> --
> psum example fails: mismatch between mpi4py 1.1.0 and ipython 0.10
> documentation
> https://bugs.launchpad.net/bugs/450025
> You received this bug notification because you are a member of IPython
> Developers, which is subscribed to IPython.
>
> Status in IPython - Enhanced Interactive Python: New
>
> Bug description:
>
> mpi4py version: 1.1.0 -- this is the relevant package
> ipython version: 0.10 -- actually a problem with the documentation
> python version: 2.6.3 -- likely any version of python
>
> I am unable to run the MPI "psum" example appearing in the documentation
> for ipython version 0.10. The psum code can be found on page 81. Here is
> the (very short) function definition, as it appears in the document
> (ipython-0.10.pdf):
>
> from mpi4py i...

Read more...

Revision history for this message
J.Thomas (hi-johng) wrote :

Thanks, Brian -- and all the developers -- for the hard work
and (apparently) late hours that go into making this such
a worthwhile product.

+jtg+

Changed in ipython:
status: New → Fix Committed
assignee: nobody → Brian Granger (ellisonbg)
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.