コード例 #1
0
ファイル: hellomod.py プロジェクト: olenz/pmi
import pmi
pmi.import_('hellomod')

from mpi4py import MPI

def hello_parallel(name):
    return 'Hello %s, this is MPI task %d!' \
           % (name, MPI.COMM_WORLD.rank)

def hello(name):
    return pmi.invoke('hellomod.hello_parallel', name)
コード例 #2
0
ファイル: mandelbrot_pmi.py プロジェクト: stuehn/pmi
import pmi

pmi.import_("mandelbrot_pmi")

from mpi4py import MPI
import numpy as np
import time


def mandelbrot_func(x, y, maxit):
    """Computes the value of the mandelbrot set at x and y, using
    maxit iterations as a maximum."""
    c = x + y * 1j
    z = 0 + 0j
    it = 0
    while abs(z) < 2.0 and it < maxit:
        z = z ** 2 + c
        it += 1
    return it


def mandelbrot_parallel((x1, y1), (x2, y2), (w, h), maxit):
    """Computes the local lines of the mandelbrot set between (x1, y1)
    and (x2, y2), using maximally maxit iterations for each point."""
    before = time.time()

    ##################################################
    # initial communication
    comm = MPI.COMM_WORLD
    size = np.intc(comm.size)
    rank = np.intc(comm.rank)