Beispiel #1
0
Multiplication of two square matrices with randomly generated contents.

"""
import mpi4py.MPI
from ga4py import ga

import numpy as np

NDIM = 2
TOTALELEMS = 1007
MAXPROC = 128
NBUF = 4
TOLERANCE = 0.1

me = ga.nodeid()
nprocs = ga.nnodes()

def verify(g_a, g_b, g_c):
    g_chk = ga.duplicate(g_a, "array check")
    if not g_chk: ga.error("duplicate failed")
    ga.sync()

    ga.gemm(False, False, TOTALELEMS, TOTALELEMS, TOTALELEMS, 1.0, g_a, g_b,
            0.0, g_chk);
    ga.sync()

    ga.add(g_c, g_chk, g_chk, 1.0, -1.0)
    rchk = ga.dot(g_chk, g_chk)

    if not me:
        print "Normed difference in matrices: %12.4f" % rchk
def print_distribution(g_a):
    for i in range(ga.nnodes()):
        lo,hi = ga.distribution(g_a, i)
        print "%s lo=%s hi=%s" % (i,lo,hi)
import mpi4py.MPI
from ga4py import ga
import numpy as np

me = ga.nodeid()
nproc = ga.nnodes()

def parallel_task():
    me = ga.pgroup_nodeid()
    nproc = ga.pgroup_nnodes()
    if not me:
        print "This is process 0 on group %s" % ga.pgroup_get_default()
    g_a = ga.create(ga.C_DBL, (3,4,5))
    ga.randomize(g_a)
    if me == 0:
        print np.sum(ga.access(g_a))

midproc = nproc//2
proclist_first = range(0,midproc)
proclist_last  = range(midproc,nproc)
group_id_first = ga.pgroup_create(proclist_first)
group_id_last  = ga.pgroup_create(proclist_last)
if me in proclist_first:
    ga.pgroup_set_default(group_id_first)
    parallel_task()
ga.pgroup_set_default(ga.pgroup_get_world())
ga.sync()
if me in proclist_last:
    ga.pgroup_set_default(group_id_last)
    parallel_task()
ga.pgroup_set_default(ga.pgroup_get_world())
Beispiel #4
0
import mpi4py.MPI  # initialize Message Passing Interface
from ga4py import ga  # initialize Global Arrays

print "hello from %s out of %s" % (ga.nodeid(), ga.nnodes())
import mpi4py.MPI # initialize Message Passing Interface
from ga4py import ga # initialize Global Arrays

print "hello from %s out of %s" % (ga.nodeid(),ga.nnodes())

Beispiel #6
0
def print_distribution(g_a):
    for i in range(ga.nnodes()):
        lo, hi = ga.distribution(g_a, i)
        print "%s lo=%s hi=%s" % (i, lo, hi)
import MDAnalysis as mda
from MDAnalysis.analysis import rms
import time
from shutil import copyfile
import glob, os
from MDAnalysis import Writer
import mpi4py
from mpi4py import MPI
from ga4py import ga
from ga4py import gain

#MPI.Init
ga.initialize()
comm = gain.comm()

size = ga.nnodes()
rank = ga.nodeid()

j = sys.argv[1]

if rank == 0:
    print(mda.__version__)


def block_rmsd(index, topology, trajectory, xref0):
    start00 = time.time()
    clone = mda.Universe(topology, trajectory)
    g = clone.atoms[index]

    bsize = g.universe.trajectory.n_frames
    results = np.zeros([bsize, 2], dtype=float)
Beispiel #8
0
from mpi4py import MPI
from ga4py import ga
from ga4py.gain import print_sync

me = ga.nodeid()
nproc = ga.nnodes()

print_sync((me,nproc))
"""Use ga.access() to sum locally per SMP node."""

import mpi4py.MPI
from ga4py import ga
import numpy as np

world_id = ga.nodeid()
world_nproc = ga.nnodes()
node_id = ga.cluster_nodeid()
node_nproc = ga.cluster_nprocs(node_id)
node_me = ga.cluster_procid(node_id,ga.nodeid())

g_a = ga.create(ga.C_DBL, (3,4,5,6))
if world_id == 0:
    ga.put(g_a, np.arange(3*4*5*6))
ga.sync()

if node_me == 0:
    sum = 0
    for i in range(node_nproc):
        smp_neighbor_world_id = ga.cluster_procid(node_id,i)
        buffer = ga.access(g_a, proc=smp_neighbor_world_id)
        sum += np.sum(buffer)
    print sum
from mpi4py import MPI
from ga4py import ga
import numpy as np
import sys

EPSILON = .0001
HOW_MANY_STEPS_BEFORE_CONVERGENCE_TEST = 2
DEBUG = False

if len(sys.argv) != 2:
    print "supply dimension"
    sys.exit()

dim = int(sys.argv[1])
rank = ga.nodeid()
size = ga.nnodes()

def print_sync(obj):
    for proc in range(size):
        if rank == proc:
            print "%d: %s" % (proc, obj)
        ga.sync()

def convergence_test(g_a, g_b):
    ### PROBLEM: g_b might contain zeros which causes GA to terminate
    # subtract g_b from g_a, results stored in g_b
    ga.add(g_a, g_b, g_b, beta=-1)
    # divide g_b by g_a, results stored in g_b
    ga.elem_divide(g_b, g_a, g_b)
    # find the largets element and compare to epsilon
    value,index = ga.select_elem_max(g_b)
Beispiel #11
0
"""Use ga.access() to sum locally per SMP node."""

import mpi4py.MPI
from ga4py import ga
import numpy as np

world_id = ga.nodeid()
world_nproc = ga.nnodes()
node_id = ga.cluster_nodeid()
node_nproc = ga.cluster_nprocs(node_id)
node_me = ga.cluster_procid(node_id, ga.nodeid())

g_a = ga.create(ga.C_DBL, (3, 4, 5, 6))
if world_id == 0:
    ga.put(g_a, np.arange(3 * 4 * 5 * 6))
ga.sync()

if node_me == 0:
    sum = 0
    for i in range(node_nproc):
        smp_neighbor_world_id = ga.cluster_procid(node_id, i)
        buffer = ga.access(g_a, proc=smp_neighbor_world_id)
        sum += np.sum(buffer)
    print sum