Example #1
0
def time_get(g_a, lo, hi, buf, chunk, jump, local):
    count = 0
    rows = hi[0] - lo[0]
    cols = hi[1] - lo[1]
    shifti = [rows, 0, rows]
    shiftj = [0, cols, cols]
    seconds = time.time()
    # distance between consecutive patches increased by jump
    # to destroy locality of reference
    for ilo in range(lo[0], hi[0] - chunk - jump + 1, chunk + jump):
        ihi = ilo + chunk
        for jlo in range(lo[1], hi[1] - chunk - jump + 1, chunk + jump):
            jhi = jlo + chunk
            count += 1
            if local:
                llo = [ilo, jlo]
                lhi = [ihi, jhi]
                ignore = ga.get(g_a, llo, lhi, buf[ga.zip(llo, lhi)])
            else:
                index = count % 3
                llo = [ilo + shifti[index], jlo + shiftj[index]]
                lhi = [ihi + shifti[index], jhi + shiftj[index]]
                ignore = ga.get(g_a, llo, lhi, buf[ilo:ihi, jlo:jhi])
    seconds = time.time() - seconds
    return seconds / count
Example #2
0
def time_get(g_a, lo, hi, buf, chunk, jump, local):
    count = 0
    rows = hi[0]-lo[0]
    cols = hi[1]-lo[1]
    shifti = [rows, 0, rows]
    shiftj = [0, cols, cols]
    seconds = time.time()
    # distance between consecutive patches increased by jump
    # to destroy locality of reference
    for ilo in range(lo[0], hi[0]-chunk-jump+1, chunk+jump):
        ihi = ilo + chunk
        for jlo in range(lo[1], hi[1]-chunk-jump+1, chunk+jump):
            jhi = jlo + chunk
            count += 1
            if local:
                llo = [ilo,jlo]
                lhi = [ihi,jhi]
                ignore = ga.get(g_a, llo, lhi, buf[ga.zip(llo,lhi)])
            else:
                index = count%3
                llo = [ilo+shifti[index],jlo+shiftj[index]]
                lhi = [ihi+shifti[index],jhi+shiftj[index]]
                ignore = ga.get(g_a, llo, lhi, buf[ilo:ihi,jlo:jhi])
    seconds = time.time() - seconds
    return seconds/count
Example #3
0
def check_put_disjoint(gatype):
    """each node fills in disjoint sections of the array"""
    if 0 == me:
        print '> Checking disjoint put ...',
    g_a = create_global_array(gatype)
    a = create_local_a(gatype)
    inc = (n-1)/20 + 1
    ij = 0
    for i in range(0,n,inc):
        for j in range(0,n,inc):
            check = False
            if MIRROR:
                check = ij % lprocs == iproc
            else:
                check = ij % nproc == me
            if check:
                lo = [i,j]
                hi = [min(i+inc,n), min(j+inc,n)]
                piece = a[ga.zip(lo,hi)]
                ga.put(g_a, piece, lo, hi)
                # the following check is not part of the original test.F
                result = ga.get(g_a, lo, hi)
                if not np.all(result == piece):
                    ga.error("put followed by get failed", 1)
            ga.sync()
            ij += 1
    ga.sync()
    # all nodes check all of a
    b = ga.get(g_a)
    if not np.all(a == b):
        ga.error('put failed, exiting')
    if 0 == me:
        print 'OK'
    ga.destroy(g_a)
Example #4
0
def check_accumulate_disjoint(gatype):
    """Each node accumulates into disjoint sections of the array."""
    if 0 == me:
        print '> Checking disjoint accumulate ...',
    g_a = create_global_array(gatype)
    a = create_local_a(gatype)
    b = np.fromfunction(lambda i,j: i+j+2, (n,n), dtype=ga.dtype(gatype))
    if 0 == me:
        ga.put(g_a, a)
    ga.sync()
    inc = (n-1)/20 + 1
    ij = 0
    for i in range(0,n,inc):
        for j in range(0,n,inc):
            x = 10.0
            lo = [i,j]
            hi = [min(i+inc,n), min(j+inc,n)]
            piece = b[ga.zip(lo,hi)]
            check = False
            if MIRROR:
                check = ij % lprocs == iproc
            else:
                check = ij % nproc == me
            if check:
                ga.acc(g_a, piece, lo, hi, x)
            ga.sync()
            ij += 1
            # each process applies all updates to its local copy
            a[ga.zip(lo,hi)] += x * piece
    ga.sync()
    # all nodes check all of a
    if not np.all(ga.get(g_a) == a):
        ga.error('acc failed')
    if 0 == me:
        print 'OK'
    ga.destroy(g_a)