Esempio n. 1
0
def verify_using_ga(g_a, g_b, g_c):
    g_v = ga.duplicate(g_c)
    ga.gemm(False, False, N, N, N, 1, g_a, g_b, 0, g_v)
    c = ga.access(g_c)
    v = ga.access(g_v)
    if c is not None:
        val = int(np.abs(np.sum(c - v)) > 0.0001)
    else:
        val = 0
    val = ga.gop_add(val)
    ga.destroy(g_v)
    return val == 0
Esempio n. 2
0
def verify_using_ga(g_a, g_b, g_c):
    g_v = ga.duplicate(g_c)
    ga.gemm(False,False,N,N,N,1,g_a,g_b,0,g_v)
    c = ga.access(g_c)
    v = ga.access(g_v)
    if c is not None:
        val = int(np.abs(np.sum(c-v))>0.0001)
    else:
        val = 0
    val = ga.gop_add(val)
    ga.destroy(g_v)
    return val == 0
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))
Esempio n. 4
0
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))
Esempio n. 5
0
import mpi4py.MPI  # initialize Message Passing Interface
from ga4py import ga  # initialize Global Arrays

me = ga.nodeid()


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)


# create some arrays
g_a = ga.create(ga.C_DBL, (10, 20, 30), chunk=(-1, 20, -1))
g_b = ga.create(ga.C_DBL, (10, 20, 30), chunk=(10, -1, -1))

if not me:
    print_distribution(g_a)
    print_distribution(g_b)

ga.fill(g_a, 6)
ga.copy(g_a, g_b)

if not me:
    buffer = ga.access(g_b)
    print buffer.shape
    print buffer
Esempio n. 6
0
 def __call__(self, g_a):
     a = ga.access(g_a)
     if a is not None:
         self.ufunc(a, a)
"""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
# note that rhi and chi follow python range conventions i.e. [lo,hi)
(rlo,clo),(rhi,chi) = ga.distribution(g_a)

iteration = 0
start = ga.wtime()
while True:
    iteration += 1
    if iteration % HOW_MANY_STEPS_BEFORE_CONVERGENCE_TEST == 0:
        # check for convergence will occur, so make a copy of the GA
        ga.sync()
        ga.copy(g_a, g_b)
    # the iteration
    if rlo == 0 and rhi == dim:
        # I own the top and bottom rows
        ga.sync()
        my_array = ga.access(g_a)
        my_array[1:-1,1:-1] = (
                my_array[0:-2, 1:-1] +
                my_array[2:, 1:-1] +
                my_array[1:-1,0:-2] +
                my_array[1:-1, 2:]) / 4
        ga.release(g_a)
    elif rlo == 0:
        # I own the top rows, so get top row of next domain
        next_domain_row = ga.get(g_a, (rhi,0), (rhi+1,dim))
        ga.sync()
        my_array = ga.access(g_a)
        combined = np.vstack((my_array,next_domain_row))
        my_array[1:,1:-1] = (
                combined[0:-2, 1:-1] +
                combined[2:, 1:-1] +
Esempio n. 9
0
import mpi4py.MPI # initialize Message Passing Interface
from ga4py import ga # initialize Global Arrays

me = ga.nodeid()

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)

# create some arrays
g_a = ga.create(ga.C_DBL, (10,20,30), chunk=(-1,20,-1))
g_b = ga.create(ga.C_DBL, (10,20,30), chunk=(10,-1,-1))

if not me:
    print_distribution(g_a)
    print_distribution(g_b)

ga.fill(g_a, 6)
ga.copy(g_a,g_b)

if not me:
    buffer = ga.access(g_b)
    print buffer.shape
    print buffer
Esempio n. 10
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
 def __call__(self, g_a):
     a = ga.access(g_a)
     if a is not None:
         self.ufunc(a,a)