[Opengeoscience-developers] Websockets and MPI
Aashish Chaudhary
aashish.chaudhary at kitware.com
Wed Feb 27 13:39:59 EST 2013
Found the problem (and pasted one file wrong)
On Wed, Feb 27, 2013 at 1:38 PM, Aashish Chaudhary <
aashish.chaudhary at kitware.com> wrote:
> yes,
>
> *pi.py*
> from mpi4py import MPI
> import numpy
>
> comm = MPI.Comm.Get_parent()
> size = comm.Get_size()
> rank = comm.Get_rank()
>
> N = numpy.array(0, dtype='i')
> comm.Bcast([N, MPI.INT], root=0)
> h = 1.0 / N; s = 0.0
> for i in range(rank, N, size):
> x = h * (i + 0.5)
> s += 4.0 / (1.0 + x**2)
> PI = numpy.array(s * h, dtype='d')
> comm.Reduce([PI, MPI.DOUBLE], None,
> op=MPI.SUM, root=0)
>
> comm.Disconnect()
>
> *cpi.py*
> #!/usr/bin/env python
> from mpi4py import MPI
> import numpy
>
> comm = MPI.Comm.Get_parent()
> size = comm.Get_size()
> rank = comm.Get_rank()
>
> N = numpy.array(0, dtype='i')
> comm.Bcast([N, MPI.INT], root=0)
> h = 1.0 / N; s = 0.0
> for i in range(rank, N, size):
> x = h * (i + 0.5)
> s += 4.0 / (1.0 + x**2)
> PI = numpy.array(s * h, dtype='d')
> comm.Reduce([PI, MPI.DOUBLE], None,
> op=MPI.SUM, root=0)
>
> comm.Disconnect()
>
>
>
>
> On Wed, Feb 27, 2013 at 1:29 PM, Ben Burnett <benjam.arlyn at gmail.com>wrote:
>
>> When you ran the example, did you create two python files, one for the
>> master (e.g. pi.py), one for the worker (cpi.py), and then run the master
>> file?
>>
>>
>> On Wed, Feb 27, 2013 at 1:23 PM, Aashish Chaudhary <
>> aashish.chaudhary at kitware.com> wrote:
>>
>>> That's what I did to verify..here is the error I got:
>>>
>>> Traceback (most recent call last):
>>> File "test.py", line 5, in <module>
>>> size = comm.Get_size()
>>> File "Comm.pyx", line 68, in mpi4py.MPI.Comm.Get_size
>>> (src/mpi4py.MPI.c:57940)
>>> mpi4py.MPI.Exception: Invalid communicator, error stack:
>>> MPI_Comm_size(111): MPI_Comm_size(MPI_COMM_NULL, size=0x7fffeda7bd3c)
>>> failed
>>> MPI_Comm_size(69).: Null communicator
>>>
>>>
>>> On Wed, Feb 27, 2013 at 1:14 PM, Ben Burnett <benjam.arlyn at gmail.com>wrote:
>>>
>>>> The Pi example came from
>>>> http://mpi4py.scipy.org/docs/usrman/tutorial.html, I just modified it
>>>> to run in a websocket handler on cherrypy.
>>>>
>>>> It looks like it's failing to spawn the processes using MPI. Do you get
>>>> any exceptions in the log?
>>>>
>>>> You could try first running the Pi example from the above website in
>>>> python to make sure MPI is working on your machine.
>>>>
>>>>
>>>> On Wed, Feb 27, 2013 at 12:46 PM, Aashish Chaudhary <
>>>> aashish.chaudhary at kitware.com> wrote:
>>>>
>>>>> @Ben,
>>>>>
>>>>> The char exampled worked like charm, but the PI example didn't. I
>>>>> don't see the value of PI. Did you write that code or its from the ws4py
>>>>> test / example?
>>>>>
>>>>> Thanks
>>>>>
>>>>>
>>>>> 1 [27/Feb/2013:12:44:38] ENGINE Listening for SIGHUP.
>>>>> 2 [27/Feb/2013:12:44:38] ENGINE Listening for SIGTERM.
>>>>> 3 [27/Feb/2013:12:44:38] ENGINE Listening for SIGUSR1.
>>>>> 4 [27/Feb/2013:12:44:38] ENGINE Bus STARTING
>>>>> 5 [27/Feb/2013:12:44:38] ENGINE Forking once.
>>>>> 6 [27/Feb/2013:12:44:38] ENGINE Forking twice.
>>>>> 7 [27/Feb/2013:12:44:38] ENGINE Daemonized to PID: 24810
>>>>> 8 [27/Feb/2013:12:44:38] Starting WebSocket processing
>>>>> 9 [27/Feb/2013:12:44:38] ENGINE PID 24810 written to
>>>>> '/home/aashish/workspace/build/deploy/ogs.pid'.
>>>>> 10 [27/Feb/2013:12:44:38] ENGINE Started monitor thread
>>>>> '_TimeoutMonitor'.
>>>>> 11 [27/Feb/2013:12:44:38] ENGINE Started monitor thread
>>>>> 'Autoreloader'.
>>>>> 12 [27/Feb/2013:12:44:38] ENGINE Serving on 127.0.0.1:8080
>>>>> 13 [27/Feb/2013:12:44:38] ENGINE Bus STARTED
>>>>> 14 [27/Feb/2013:12:44:41] Handler created:
>>>>> <websocket_pi.PiWebSocketHandler object at 0x275f410>
>>>>> 15 [27/Feb/2013:12:44:41] Managing WebSocket connection from
>>>>> 127.0.0.1:56898
>>>>> 16 [27/Feb/2013:12:44:46] something
>>>>> 17 [27/Feb/2013:12:44:46] Recieved message 101
>>>>> 18 [27/Feb/2013:12:44:46] Dir /home/aashish/workspace/build/deploy
>>>>> 19 [27/Feb/2013:12:44:46] Path
>>>>> /home/aashish/workspace/build/deploy/cpi.py
>>>>>
>>>>> On Wed, Feb 27, 2013 at 12:15 PM, Aashish Chaudhary <
>>>>> aashish.chaudhary at kitware.com> wrote:
>>>>>
>>>>>> Nice..I will have a look at it today.
>>>>>>
>>>>>> On Wed, Feb 27, 2013 at 12:10 PM, Ben Burnett <benjam.arlyn at gmail.com
>>>>>> > wrote:
>>>>>>
>>>>>>> I just pushed the branch websockets-mpi, and added a wiki page with
>>>>>>> some notes on it
>>>>>>> https://github.com/OpenGeoscience/opengeoscience/wiki/Testing-Websockets-and-MPI
>>>>>>> _______________________________________________
>>>>>>> Opengeoscience-developers mailing list
>>>>>>> Opengeoscience-developers at public.kitware.com
>>>>>>>
>>>>>>> http://public.kitware.com/cgi-bin/mailman/listinfo/opengeoscience-developers
>>>>>>>
>>>>>>>
>>>>>>
>>>>>>
>>>>>> --
>>>>>> | Aashish Chaudhary
>>>>>> | R&D Engineer
>>>>>> | Kitware Inc.
>>>>>> | www.kitware.com
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> | Aashish Chaudhary
>>>>> | R&D Engineer
>>>>> | Kitware Inc.
>>>>> | www.kitware.com
>>>>>
>>>>
>>>>
>>>
>>>
>>> --
>>> | Aashish Chaudhary
>>> | R&D Engineer
>>> | Kitware Inc.
>>> | www.kitware.com
>>>
>>
>>
>
>
> --
> | Aashish Chaudhary
> | R&D Engineer
> | Kitware Inc.
> | www.kitware.com
>
--
| Aashish Chaudhary
| R&D Engineer
| Kitware Inc.
| www.kitware.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/opengeoscience-developers/attachments/20130227/5b75ca10/attachment.html>
More information about the Opengeoscience-developers
mailing list