예제 #1
0
    def __init__(self):
        self.world = get_comm_world()
        self.world_ranks = list(range(self.world.size))

        # make engine and client comm
        self.client_rank = 0
        self.engine_ranks = [i for i in self.world_ranks if i !=
                             self.client_rank]

        # make engines intracomm (Context._base_comm):
        Engine.INTERCOMM = initial_comm_setup()
        assert self.world.rank != self.client_rank
        while True:
            msg = Engine.INTERCOMM.recv(source=self.client_rank)
            val = self.parse_msg(msg)
            if val == 'kill':
                break
        Engine.INTERCOMM.Free()
예제 #2
0
    def __init__(self):
        self.world = get_comm_world()
        self.world_ranks = list(range(self.world.size))

        # make engine and client comm
        self.client_rank = 0
        self.engine_ranks = [
            i for i in self.world_ranks if i != self.client_rank
        ]

        # make engines intracomm (Context._base_comm):
        Engine.INTERCOMM = initial_comm_setup()
        assert self.world.rank != self.client_rank
        while True:
            msg = Engine.INTERCOMM.recv(source=self.client_rank)
            val = self.parse_msg(msg)
            if val == 'kill':
                break
        Engine.INTERCOMM.Free()
예제 #3
0
def Context(*args, **kwargs):

    kind = kwargs.pop('kind', '')

    if not kind:
        kind = 'ipython' if is_solo_mpi_process() else 'mpi'

    if kind.lower().startswith('mpi'):

        CW = get_comm_world()
        myrank = CW.rank
        if myrank:
            _fire_off_engines(myrank)
            import sys
            sys.exit()
        else:
            return MPIContext(*args, **kwargs)

    elif kind.lower().startswith('ipython'):
        return IPythonContext(*args, **kwargs)

    else:
        raise ContextCreationError("%s is not a valid Context selector string." % kind)
예제 #4
0
def Context(*args, **kwargs):

    kind = kwargs.pop('kind', '')

    if not kind:
        kind = 'ipython' if is_solo_mpi_process() else 'mpi'

    if kind.lower().startswith('mpi'):

        CW = get_comm_world()
        myrank = CW.rank
        if myrank:
            _fire_off_engines(myrank)
            import sys
            sys.exit()
        else:
            return MPIContext(*args, **kwargs)

    elif kind.lower().startswith('ipython'):
        return IPythonContext(*args, **kwargs)

    else:
        raise ContextCreationError(
            "%s is not a valid Context selector string." % kind)