コード例 #1
0
ファイル: test.py プロジェクト: fred1653/lotsofcoresbook1code
def main():
    if 0 == me:
        if MIRROR:
            print ' Performing tests on Mirrored Arrays'
        print ' GA initialized'

    # note that MA is not used, so no need to initialize it
    # "import ga" registers malloc/free as memory allocators internally

    #if nproc-1 == me:
    if 0 == me:
        print 'using %d process(es) %d custer nodes' % (
                nproc, ga.cluster_nnodes())
        print 'process %d is on node %d with %d processes' % (
                me, ga.cluster_nodeid(), ga.cluster_nprocs(-1))

    # create array to force staggering of memory and uneven distribution
    # of pointers
    dim1 = MEM_INC
    mapc = [0]*nproc
    for i in range(nproc):
        mapc[i] = MEM_INC*i
        dim1 += MEM_INC*i
    g_s = ga.create_handle()
    ga.set_data(g_s, [dim1], ga.C_INT)
    ga.set_array_name(g_s, 's')
    ga.set_irreg_distr(g_s, mapc, [nproc])

    if MIRROR:
        if 0 == me:
            print '\nTESTING MIRRORED ARRAYS\n'

    # check support for single precision arrays
    if 0 == me:
        print '\nCHECKING SINGLE PRECISION\n'
    check_float()

    # check support for double precision arrays
    if 0 == me:
        print '\nCHECKING DOUBLE PRECISION\n'
    check_double()

    # check support for single precision complex arrays
    if 0 == me:
        print '\nCHECKING SINGLE COMPLEX\n'
    check_complex_float()

    # check support for double precision complex arrays
    if 0 == me:
        print '\nCHECKING DOUBLE COMPLEX\n'
    check_complex_double()

    # check support for integer arrays
    if 0 == me:
        print '\nCHECKING INT\n'
    check_int()

    # check support for long integer arrays
    if 0 == me:
        print '\nCHECKING LONG INT\n'
    check_long()

    if 0 == me:
        print '\nCHECKING Wrappers to Message Passing Collective ops\n'
    check_wrappers()

    # check if memory limits are enforced
    #check_mem(ma_heap*ga.nnodes())

    if 0 == me: ga.print_stats()
    if 0 == me: print ' '
    if 0 == me: print 'All tests successful'
コード例 #2
0
ファイル: test.py プロジェクト: fred1653/lotsofcoresbook1code
#!/usr/bin/env python
"""At first it was a duplicate of GA's test.x, but was made more modular since
so much could be reused.  It is more like unit tests since each piece has
build up and tear down."""

import random
import sys

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

me = ga.nodeid()
nproc = ga.nnodes()
nnodes = ga.cluster_nnodes()
inode = ga.cluster_nodeid()
lprocs = ga.cluster_nprocs(inode)
iproc = me % lprocs

n = 256
m = 2*n
maxloop = 100
nloop = min(maxloop,n)
block_size = [32,32]
proc_grid = [2,nproc/2]
MEM_INC = 1000
MIRROR = False
USE_RESTRICTED = False
NEW_API = False
NGA_GATSCAT = False
BLOCK_CYCLIC = False