ó
 nTMc           @   sE  d  Z  d e f d „  ƒ  YZ d d l Z e j j d ƒ rµd d. d „  ƒ  YZ d d/ d	 „  ƒ  YZ e ƒ  Z d
 e _	 d e _
 d d0 d „  ƒ  YZ d e f d „  ƒ  YZ d e f d „  ƒ  YZ d e f d „  ƒ  YZ d e f d „  ƒ  YZ d e f d „  ƒ  YZ d e f d „  ƒ  YZ d e f d „  ƒ  YZ d e f d „  ƒ  YZ d e f d „  ƒ  YZ d  e f d! „  ƒ  YZ d" e f d# „  ƒ  YZ d$ e f d% „  ƒ  YZ d& e f d' „  ƒ  YZ d Z n‰ y1 d d( l Td d) l m Z m Z e e ƒ [ WnU e k
 r=d d l j Z  d Z d* d1 d+ „  ƒ  YZ! d, d2 d- „  ƒ  YZ" e! ƒ  Z n X[ d S(3   sq  
Python interface to the Message Passing Interface (MPI)

This module contains a Python interface to the Message Passing
Interface (MPI), and standardized library for message-passing parallel
computing. Please read an introduction to MPI before using this
module; some terms in the documentation do not make much sense unless
you understand the principles of MPI.

This module contains an object, 'world', which represents the
default communicator in MPI. This communicator can be used directly
for sending and receiving data, or other communicators can be
derived from it.

A number of global constants are also defined (L{max}, L{min}, L{prod},
L{sum}, L{land}, L{lor}, L{lxor}, L{band}, L{bor}, L{bxor}, L{maxloc}),
and L{minloc}). They are used to specify the desired operator in calls to
the 'reduce' and 'allreduce' methods of the communicator objects.

@undocumented: core*
t   MPIErrorc           B   s   e  Z d  Z RS(   s   
    MPI call failed
    (   t   __name__t
   __module__t   __doc__(    (    (    s4   C:\Python27\Lib\site-packages\Scientific\MPI\core.pyR        s   iÿÿÿÿNt   epydoct   MPICommunicatorc           B   s¤   e  Z d  Z d „  Z d „  Z d „  Z d „  Z d d d „ Z d d d „ Z	 d d d „ Z
 d d d „ Z d	 „  Z d
 „  Z d „  Z d „  Z d „  Z d „  Z RS(   s  
        MPI Communicator

        There is no constructor for MPI Communicator objects. The
        default communicator is given by Scientific.MPI.world, and
        other communicators can only be created by methods on an
        existing communicator object.

        A communicator object has two read-only attributes: 'rank' is
        an integer which indicates the rank of the current process in
        the communicator, and 'size' is an integer equal to the number
        of processes that participate in the communicator.
        c         C   s   d S(   s    
            @returns: a new communicator with the same properties
                      as the original one
            @rtype: L{MPICommunicator}
            N(    (   t   self(    (    s4   C:\Python27\Lib\site-packages\Scientific\MPI\core.pyt	   duplicate<   s    c         C   s   d S(   s`  
            Create a communicator for a subset of the processes
            
            The method should be called by all processes simultaneously. The
            return value will be the new communicator on those
            processes listed in C{ranks} and C{None} for the rest.

            @param ranks: a list of ranks, one for each process that should
                          belong to the new communicator
            @type ranks: C{list} of C{int}
            @returns: a new communicator containing a subset
                      of the processes participating in the original one
            N(    (   R   t   ranks(    (    s4   C:\Python27\Lib\site-packages\Scientific\MPI\core.pyt   subsetD   s    c         C   s   d S(   sÓ  
            Send data to another process (blocking)

            @param data: the data to be sent
            @type data: C{str} or C{Numeric.array}. Array arguments
                        must have contiguous storage. General object arrays
                        are not allowed.
            @param destination: the rank of the destination process
            @type destination: C{int}
            @param tag: Identifier
            @type tag: C{int}
            N(    (   R   t   datat   destinationt   tag(    (    s4   C:\Python27\Lib\site-packages\Scientific\MPI\core.pyt   sendT   s    c         C   s   d S(   s@  
            Send data to another process (non-blocking)

            @param data: the data to be sent
            @type data: C{str} or C{Numeric.array}. Array arguments
                        must have contiguous storage. General object arrays
                        are not allowed.
            @param destination: the rank of the destination process
            @type destination: C{int}
            @param tag: Identifier
            @type tag: C{int}
            @returns: MPI request object (used to wait for completion)
            @rtype: L{MPIRequest}
            N(    (   R   R
   R   R   (    (    s4   C:\Python27\Lib\site-packages\Scientific\MPI\core.pyt   nonblockingSendc   s    c         C   s   d S(   sE  
            Receive data from another process (blocking)

            @param data: either a contiguous array object, or a one-letter
                         typecode (in practice, one would use Numeric.Int,
                         Numeric.Float, etc.). If an array, the data is
                         copied to the array, whic must have the right shape.
                         If a typecode, an array of that type is created
                         and used as the buffer for incoming data.
            @type data: C{Numeric.array} or C{str}
            @param source: the rank of the process from which data is
                           accepted. C{None} means data is accepted from
                           any process.
            @type source: C{int} or C{NoneType}
            @param tag: Identifier that acts as a filter; only messages
                        with a matching tag are received. A value of C{None}
                        means that any tag will match.
            @type tag: C{int} or C{NoneType}
            @returns: a tuple containing four elements:
                      the array containing the data, the source process rank
                      (an C{int}), the message tag (an C{int}), and the
                      number of elements that were received (an C{int}).
            @rtype: C{tuple}
            N(    (   R   R
   t   sourceR   (    (    s4   C:\Python27\Lib\site-packages\Scientific\MPI\core.pyt   receivet   s    c         C   s   d S(   s  
            Receive string data from another process (blocking)

            @param source: the rank of the process from which data is
                           accepted. C{None} means data is accepted from
                           any process.
            @type source: C{int} or C{NoneType}
            @param tag: Identifier that acts as a filter; only messages
                        with a matching tag are received. A value of C{None}
                        means that any tag will match.
            @type tag: C{int} or C{NoneType}
            @returns: a tuple containing three elements:
                      the string containing the data, the source process rank
                      (an C{int}), the message tag (an C{int}).
            @rtype: C{tuple}
            N(    (   R   R   R   (    (    s4   C:\Python27\Lib\site-packages\Scientific\MPI\core.pyt   receiveString   s    c         C   s   d S(   s€  
            Receive data from another process (non-blocking)

            @param data: a contiguous array object to which the incoming
                         data is copied. It must have the right shape.
            @type data: C{Numeric.array}
            @param source: the rank of the process from which data is
                           accepted. C{None} means data is accepted from
                           any process.
            @type source: C{int} or C{NoneType}
            @param tag: Identifier that acts as a filter; only messages
                        with a matching tag are received. A value of C{None}
                        means that any tag will match.
            @type tag: C{int} or C{NoneType}
            @returns: MPI request object (used to wait for completion and
                      obtain the received data)
            @rtype: L{MPIRequest}
            N(    (   R   R
   R   R   (    (    s4   C:\Python27\Lib\site-packages\Scientific\MPI\core.pyt   nonblockingReceive¢   s    c         C   s   d S(   sÔ  
            Check for incoming messages

            @param source: the rank of the process from which messages are
                           accepted. C{None} means data is accepted from
                           any process.
            @type source: C{int} or C{NoneType}
            @param tag: Identifier that acts as a filter; only messages
                        with a matching tag are considered. A value of C{None}
                        means that any tag will match.
            @type tag: C{int} or C{NoneType}
            @returns: C{None} if no messages are available, otherwise
                      a tuple containing the source rank and the tag
            @rtype: C{NoneType} or C{tuple}
            N(    (   R   R   R   (    (    s4   C:\Python27\Lib\site-packages\Scientific\MPI\core.pyt   nonblockingProbe·   s    c         C   s   d S(   sB  
            Send data to all processes

            @param array: an array containing the data to be sent on the
                          sending process and serving as a buffer for the
                          incoming data on all processes. The shape and type
                          of the array must be the same on all processes.
            @type array: Numeric.array
            @param root: the rank of the sending process
            @type root: C{int}
            @note: The data is sent to all processes, including the sending
                   one.
            N(    (   R   t   arrayt   root(    (    s4   C:\Python27\Lib\site-packages\Scientific\MPI\core.pyt	   broadcastÉ   s    c         C   s   d S(   sç  
            Distribute data from each processpr to all other processesors

            @param send: an array of identical shape and type on all processes.
                         It contains on each process the data that is sent.
            @type send: C{Numeric.array}
            @param receive: an array whose type is the same as for the send
                            array and which has an additional dimension
                            (the first one) whose length is the number of
                            processes. After the call, the value
                            of receive[i] is equal to the contents of the
                            array send in process i.
            @type receive: C{Numeric.array}
            N(    (   R   R   R   (    (    s4   C:\Python27\Lib\site-packages\Scientific\MPI\core.pyt   shareÙ   s    c         C   s   d S(   sŒ   
            Wait until all processes in the communicator have
            called the same method, then all processes continue.
            N(    (   R   (    (    s4   C:\Python27\Lib\site-packages\Scientific\MPI\core.pyt   barrierê   s    c         C   s   d S(   s]  
            Abort all processes associated with the communicator.
            For emergency use only.

            @param error_code: error code passed back to the calling
                               program (usually a shell) under most
                               Unix implementations of MPI
            @type error_code: C{int}
            N(    (   R   t
   error_code(    (    s4   C:\Python27\Lib\site-packages\Scientific\MPI\core.pyt   abortñ   s    
c         C   s   d S(   s“  
            Combine data from all processes and send result to one

            @param sendbuffer: an array holding the data that each
                               process contributes
            @type sendbuffer: C{Numeric.array}
            @param receivebuffer: an array acting as a buffer for the
                                  result of the reduction. Used only
                                  by the process whose rank is root
            @type receivebuffer: C{Numeric.array}
            @param operation: one of the operation objects: L{max},
                              L{min}, L{prod}, L{sum}, L{land}, L{lor},
                              L{lxor}, L{band}, L{bor}, L{bxor},
                              L{maxloc} and L{minloc}
            @type operation: MPIOperationObject
            @param root: the rank of the process that received the result
            @type root: C{int}
            N(    (   R   t
   sendbuffert   receivebuffert	   operationR   (    (    s4   C:\Python27\Lib\site-packages\Scientific\MPI\core.pyt   reduceý   s    c         C   s   d S(   sÛ  
            Combine data from all processes and send result to all

            @param sendbuffer: an array holding the data that each
                               process contributes
            @type sendbuffer: C{Numeric.array}
            @param receivebuffer: an array acting as a buffer for the
                                  result of the reduction
            @type receivebuffer: C{Numeric.array}
            @param operation: one of the operation objects: L{max},
                              L{min}, L{prod}, L{sum}, L{land}, L{lor},
                              L{lxor}, L{band}, L{bor}, L{bxor},
                              L{maxloc} and L{minloc}
            @type operation: MPIOperationObject
            N(    (   R   R   R   R   (    (    s4   C:\Python27\Lib\site-packages\Scientific\MPI\core.pyt	   allreduce  s    N(   R   R   R   R   R	   R   R   t   NoneR   R   R   R   R   R   R   R   R   R   (    (    (    s4   C:\Python27\Lib\site-packages\Scientific\MPI\core.pyR   ,   s   									t
   MPIRequestc           B   s    e  Z d  Z d „  Z d „  Z RS(   sÍ   
        MPI Request

        There is no constructor for MPI Request objects.  They are
        returned by nonblocking send and receives, and are used to
        query the status of the message.
        c         C   s   d S(   sÑ  
            Wait till the communication has completed.

            If the operation was a nonblocking send, there is no return value.
            If the operation was a nonblocking receive, the return
            value is a tuple containing four elements: the array
            containing the data, the source process rank (an integer),
            the message tag (an integer), and the number of elements
            that were received (an integer).
            N(    (   R   (    (    s4   C:\Python27\Lib\site-packages\Scientific\MPI\core.pyt   wait-  s    c         C   s   d S(   s  
            Test if communications have completed.

            If the operation was a nonblocking send, it returns 0 if
            the operation has not completed, and 1 if it has.

            If the operation was a nonblocking receive, 0 is returned
            if the operation was not completed, and a tuple containing
            four elements if it was completed.  The four elements are:
            the array containing the data, the source process rank (an
            integer), the message tag (an integer), and the number of
            elements that were received (an integer).

            Once a test has been successful (i.e. the operation has
            completed), it is no longer possible to call wait() or
            test() on the MPI Request object.
            N(    (   R   (    (    s4   C:\Python27\Lib\site-packages\Scientific\MPI\core.pyt   test:  s    (   R   R   R   R"   R#   (    (    (    s4   C:\Python27\Lib\site-packages\Scientific\MPI\core.pyR!   $  s   	i    i   t   MPIOperationObjectc           B   s   e  Z RS(    (   R   R   (    (    (    s4   C:\Python27\Lib\site-packages\Scientific\MPI\core.pyR$   T  s   t   maxc           B   s   e  Z d  Z RS(   s;   The 'maximum' operation in reduce/allreduce communications.(   R   R   R   (    (    (    s4   C:\Python27\Lib\site-packages\Scientific\MPI\core.pyR%   W  s   t   minc           B   s   e  Z d  Z RS(   s;   The 'minimum' operation in reduce/allreduce communications.(   R   R   R   (    (    (    s4   C:\Python27\Lib\site-packages\Scientific\MPI\core.pyR&   [  s   t   prodc           B   s   e  Z d  Z RS(   s;   The 'product' operation in reduce/allreduce communications.(   R   R   R   (    (    (    s4   C:\Python27\Lib\site-packages\Scientific\MPI\core.pyR'   _  s   t   sumc           B   s   e  Z d  Z RS(   s7   The 'sum' operation in reduce/allreduce communications.(   R   R   R   (    (    (    s4   C:\Python27\Lib\site-packages\Scientific\MPI\core.pyR(   c  s   t   landc           B   s   e  Z d  Z RS(   s?   The 'logical and' operation in reduce/allreduce communications.(   R   R   R   (    (    (    s4   C:\Python27\Lib\site-packages\Scientific\MPI\core.pyR)   g  s   t   lorc           B   s   e  Z d  Z RS(   s>   The 'logical or' operation in reduce/allreduce communications.(   R   R   R   (    (    (    s4   C:\Python27\Lib\site-packages\Scientific\MPI\core.pyR*   k  s   t   lxorc           B   s   e  Z d  Z RS(   s%   The 'logical exclusive-or' operation.(   R   R   R   (    (    (    s4   C:\Python27\Lib\site-packages\Scientific\MPI\core.pyR+   o  s   t   bandc           B   s   e  Z d  Z RS(   s?   The 'bitwise and' operation in reduce/allreduce communications.(   R   R   R   (    (    (    s4   C:\Python27\Lib\site-packages\Scientific\MPI\core.pyR,   s  s   t   borc           B   s   e  Z d  Z RS(   s>   The 'bitwise or' operation in reduce/allreduce communications.(   R   R   R   (    (    (    s4   C:\Python27\Lib\site-packages\Scientific\MPI\core.pyR-   w  s   t   bxorc           B   s   e  Z d  Z RS(   s%   The 'bitwise exclusive-or' operation.(   R   R   R   (    (    (    s4   C:\Python27\Lib\site-packages\Scientific\MPI\core.pyR.   {  s   t   maxlocc           B   s   e  Z d  Z RS(   s(   The 'location of the maximum' operation.(   R   R   R   (    (    (    s4   C:\Python27\Lib\site-packages\Scientific\MPI\core.pyR/     s   t   minlocc           B   s   e  Z d  Z RS(   s(   The 'location of the minimum' operation.(   R   R   R   (    (    (    s4   C:\Python27\Lib\site-packages\Scientific\MPI\core.pyR0   ƒ  s   t   replacec           B   s   e  Z d  Z RS(   s"   The 'replace' operation. (MPI 2.0)(   R   R   R   (    (    (    s4   C:\Python27\Lib\site-packages\Scientific\MPI\core.pyR1   ‡  s   (   t   *(   t   _C_APIt   _registerErrorObjectt   DummyCommunicatorc           B   sŒ   e  Z d  „  Z d „  Z d „  Z d „  Z d d d „ Z d d d „ Z d d d „ Z	 d d d „ Z
 d „  Z d	 „  Z d
 „  Z d „  Z RS(   c         C   s   d |  _  d |  _ g  |  _ d  S(   Ni   i    (   t   sizet   rankt   messages(   R   (    (    s4   C:\Python27\Lib\site-packages\Scientific\MPI\core.pyt   __init__œ  s    		c         C   s   t  ƒ  S(   N(   R5   (   R   (    (    s4   C:\Python27\Lib\site-packages\Scientific\MPI\core.pyR   ¡  s    c         C   sJ   | d k r t  d ƒ ‚ n  |  j j | t j | d d ƒj ƒ  f ƒ d  S(   Ni    s   invalid MPI destinationt   copyi   (   R    R8   t   appendt   NumericR   t   ravel(   R   R
   R   R   (    (    s4   C:\Python27\Lib\site-packages\Scientific\MPI\core.pyR   ¤  s    c         C   s   |  j  | | | ƒ t d  ƒ S(   N(   R   t   DummyRequestR    (   R   R
   R   R   (    (    s4   C:\Python27\Lib\site-packages\Scientific\MPI\core.pyR   ©  s    c         C   s¢   | d k r' | d  k r' t d ƒ ‚ n  xh t t |  j ƒ ƒ D]Q } |  j | \ } } | d  k sn | | k r= |  j | =| d | t | ƒ f Sq= Wt d ƒ ‚ d  S(   Ni    s   invalid MPI sources   no message received(   R    R    t   ranget   lenR8   (   R   R   R   R   t   it   data_tagR
   (    (    s4   C:\Python27\Lib\site-packages\Scientific\MPI\core.pyR   ­  s    
c         C   s1   |  j  | | ƒ \ } } } } | j ƒ  | | f S(   N(   R   t   tostring(   R   R   R   R   t   length(    (    s4   C:\Python27\Lib\site-packages\Scientific\MPI\core.pyR   ·  s    c         C   s   t  |  j | | | ƒ ƒ S(   N(   R>   R   (   R   R   R   R   (    (    s4   C:\Python27\Lib\site-packages\Scientific\MPI\core.pyR   »  s    c         C   s}   | d k r$ | d  k r$ t d ‚ n  xR t t |  j ƒ ƒ D]; } |  j | \ } } | d  k sk | | k r: d | f Sq: Wd  S(   Ni    s   invalid MPI source(   R    R    R?   R@   R8   (   R   R   R   RA   RB   R
   (    (    s4   C:\Python27\Lib\site-packages\Scientific\MPI\core.pyR   ¾  s    c         C   s   | d k r t  d ƒ ‚ n  | S(   Ni    s   invalid MPI rank(   R    (   R   R   R   (    (    s4   C:\Python27\Lib\site-packages\Scientific\MPI\core.pyR   Ç  s    c         C   s   | | d <d  S(   Ni    (    (   R   R   R   (    (    s4   C:\Python27\Lib\site-packages\Scientific\MPI\core.pyR   Ì  s    c         C   s   d  S(   N(    (   R   (    (    s4   C:\Python27\Lib\site-packages\Scientific\MPI\core.pyR   Ï  s    c         C   s   t  d ƒ ‚ d  S(   NR   (   R    (   R   (    (    s4   C:\Python27\Lib\site-packages\Scientific\MPI\core.pyR   Ò  s    N(   R   R   R9   R   R   R   R    R   R   R   R   R   R   R   R   (    (    (    s4   C:\Python27\Lib\site-packages\Scientific\MPI\core.pyR5   š  s   				
				R>   c           B   s   e  Z d  „  Z d „  Z RS(   c         C   s   | |  _  d  S(   N(   t   arg(   R   RE   (    (    s4   C:\Python27\Lib\site-packages\Scientific\MPI\core.pyR9   ×  s    c         C   s   |  j  S(   N(   RE   (   R   (    (    s4   C:\Python27\Lib\site-packages\Scientific\MPI\core.pyR"   Ú  s    (   R   R   R9   R"   (    (    (    s4   C:\Python27\Lib\site-packages\Scientific\MPI\core.pyR>   Õ  s   	(    (    (    (    (    (#   R   t   EnvironmentErrorR    t   syst   modulest   has_keyR   R!   t   worldR7   R6   R$   R%   R&   R'   R(   R)   R*   R+   R,   R-   R.   R/   R0   R1   R    R3   t   Scientific_mpiR4   t   ImportErrort   Scientific.Nt   NR<   R5   R>   (    (    (    s4   C:\Python27\Lib\site-packages\Scientific\MPI\core.pyt   <module>   sF   ø*				

;