Exemple #1
0
def MC_int(c, s, dist):
    x = np.empty([s], dtype=np.double, dist=dist)
    y = np.empty([s], dtype=np.double, dist=dist)
    sum=0.0
    np.timer_reset()
    np.evalflush()
    start=time.time()
    for i in range(c):
        np.ufunc_random(x,x)
        np.ufunc_random(y,y)
        np.square(x,x)
        np.square(y,y)
        np.add(x,y,x)
        z = np.less_equal(x, 1)
        sum += np.add.reduce(z)*4.0/s
    sum = sum / c
    np.evalflush()
    stop=time.time()
    print 'Pi: ', sum, ' with ', s,' samples in sec: ', stop-start,
    if dist:
        print "(Dist) notes: %s"%sys.argv[4]
    else:
        print "(Non-Dist) notes: %s"%sys.argv[4]
Exemple #2
0
def MC_int(c, s, dist):
    x = np.empty([s], dtype=np.double, dist=dist)
    y = np.empty([s], dtype=np.double, dist=dist)
    sum = 0.0
    np.timer_reset()
    np.evalflush()
    start = time.time()
    for i in range(c):
        np.ufunc_random(x, x)
        np.ufunc_random(y, y)
        np.square(x, x)
        np.square(y, y)
        np.add(x, y, x)
        z = np.less_equal(x, 1)
        sum += np.add.reduce(z) * 4.0 / s
    sum = sum / c
    np.evalflush()
    stop = time.time()
    print 'Pi: ', sum, ' with ', s, ' samples in sec: ', stop - start,
    if dist:
        print "(Dist) notes: %s" % sys.argv[4]
    else:
        print "(Non-Dist) notes: %s" % sys.argv[4]
Exemple #3
0
BOUND = np.zeros((nx,ny,nz), dtype=float, dist=DIST)
BOUNDi = np.zeros((nx,ny,nz), dtype=float, dist=DIST)
BOUNDi += 1#ones
if not NO_OBST:
    for i in xrange(nx):
        for j in xrange(ny):
            for k in xrange(nz):
                if ((i-4)**2+(j-5)**2+(k-6)**2) < 6:
                    BOUND[i,j,k] += 1.0
                    BOUNDi[i,j,k] += 0.0

BOUND[:,0,:] += 1.0
BOUNDi[:,0,:] *= 0.0

np.timer_reset()
np.evalflush()
t1 = time.time()
while ts<ITER:
    ##Propagate / Streaming step
    T[:] = F
    #nearest-neighbours
    F[1,:,:,0]   = T[1,:,:,-1]
    F[1,:,:,1:]  = T[1,:,:,:-1]
    F[2,:,:,:-1] = T[2,:,:,1:]
    F[2,:,:,-1]  = T[2,:,:,0]
    F[3,:,0,:]   = T[3,:,-1,:]
    F[3,:,1:,:]  = T[3,:,:-1,:]
    F[4,:,:-1,:] = T[4,:,1:,:]
    F[4,:,-1,:]  = T[4,:,0,:]
    F[5,0,:,:]   = T[5,-1,:,:]
    F[5,1:,:,:]  = T[5,:-1,:,:]
Exemple #4
0
            seed = int(a)
        elif o in ("-f", "--file"):
            script_list.append(a)
        elif o in ("-e", "--exclude"):
            exclude_list.append(a)
        else:
            assert False, "unhandled option"

    if len(script_list) == 0:
        script_list = os.listdir(\
                      os.path.dirname(os.path.abspath(__file__)))

    if np.RANK == 0:
        print "*"*100
        print "*"*31, "Testing Distributed Numerical Python", "*"*31
    np.evalflush(barrier=True)
    for i in xrange(len(script_list)):
        f = script_list[i]
        if f.startswith("test_") and f.endswith("py")\
           and f not in exclude_list:
            m = f[:-3]#Remove ".py"
            m = __import__(m)
            np.datalayout(None)
            np.evalflush(barrier=True)
            if np.RANK == 0:
                print "*"*100
                print "Testing %s"%f
            np.evalflush(barrier=True)
            err = False
            msg = ""
            r1 = 0; r2 = 0