Beispiel #1
0
bsp.globalize(0,(n1Dim,n1Dim),'arr.a1')

# create an index-set for the request
bsp.createArray('ind.lower1','u8',[2,2])
bsp.createArray('ind.upper1','u8',[2,2])
lower1=bsp.asNumpy('ind.lower1')
upper1=bsp.asNumpy('ind.upper1')
lower1[0][0] = 5
lower1[0][1] = 5
upper1[0][0] = 14
upper1[0][1] = 14
lower1[1][0] = 2
lower1[1][1] = 0
upper1[1][0] = 11
upper1[1][1] = 9
inds1=bsp.createRegionSet(('ind.lower1','ind.upper1'))
#inds1=bsp.createPointSet('ind.lower1')

# create a local array to get the requested data
bsp.createArray('arr.a2','f8',[2,10,10])

# request elements to the local array from the global array
bsp.requestTo('arr.a2','arr.a1@global',inds1)
bsp.sync('just for fun!!')

if myProcID == 0:
    a2 = bsp.asNumpy('arr.a2')
    print a2


Beispiel #2
0
# create an index-set for the request
bsp.createArray('ind.lower1', 'u8', [2, 2])
bsp.createArray('ind.upper1', 'u8', [2, 2])
lower1 = bsp.asNumpy('ind.lower1')
upper1 = bsp.asNumpy('ind.upper1')
lower1[0][0] = 5
lower1[0][1] = 5
upper1[0][0] = 14
upper1[0][1] = 14
lower1[1][0] = 2
lower1[1][1] = 0
upper1[1][0] = 11
upper1[1][1] = 9
inds1 = bsp.createRegionSet(('ind.lower1', 'ind.upper1'))
#inds1=bsp.createPointSet('ind.lower1')

# create a local array to store the update data
bsp.createArray('arr.a2', 'f8', [2, 10, 10])
a2 = bsp.asNumpy('arr.a2')
for i in range(2):
    for j in range(10):
        for k in range(10):
            a2[i][j][k] = 1.0

# request elements to the local array from the global array
bsp.updateFrom('arr.a2', '+', 'arr.a1@global', inds1)
bsp.sync('just for fun!!')

if myProcID == 0:
    print a1
Beispiel #3
0
import bsp
import numpy as np
#bsp.toggleVerbose()
nProcs = bsp.procCount()
myProcID = bsp.myProcID()
nBatches = 1000
if myProcID == 0:
    for i in range(1, nProcs):
        bsp.addWorker(i)
    bsp.setScheduler(10,5,8)
    bsp.createArray('iLocalBatch','i4',[nProcs])
    bsp.share('iLocalBatch')
    bsp.sync('NOTHING')
    for r in range(nBatches):
        batch = bsp.async('to master', r == nBatches - 1 or (r + 1) % 100 == 0)
        rLocal = []
        for i in batch:
            rLocal.append(bsp.asNumpy('iLocalBatch')[i])
        print('%i: '%r,batch,rLocal)

        bsp.fromObject(r, 'iBatch')
        for i in batch:
            bsp.toProc(i, 'iBatch')
        bsp.async('from master')
else:
    bsp.createArray('iLocalBatch','i4',[1])
    bsp.share('iLocalBatch')
    bsp.sync('NOTHING')
    inds1=bsp.createPointSet([myProcID])
    for s in range(nBatches):
        bsp.asNumpy('iLocalBatch')[0] = s
Beispiel #4
0
s1 = [1, (2, 3, 4), [5, (5, 6)], {7: [1, 2], 8: 9}]
s2 = (3, 5, '123', 'hello world!')
bsp.fromObject(s1, 'obj.s1')
bsp.fromObject(s2, 'obj.s2')

a1 = numpy.ndarray([2, 3, 3], dtype='f8')
a2 = numpy.ndarray([10])
for i in range(3):
    for j in range(3):
        a1[0][i][j] = i + j
        a1[1][i][j] = i - j
for k in range(10):
    a2[k] = math.cos(k)
bsp.fromNumpy(a1, 'num.a1')
bsp.fromNumpy(a2, 'num.a2')

bsp.toProc(partnerID, 'obj.s1')
bsp.toProc(partnerID, 'obj.s2')
bsp.toProc(partnerID, 'num.a1')
bsp.toProc(partnerID, 'num.a2')

bsp.sync('hello', mSync)
t1 = bsp.toObject(bsp.fromProc(partnerID)['obj.s1'])
print 't1 = ', t1
t2 = bsp.toObject(bsp.fromProc(partnerID)['obj.s2'])
print 't2 = ', t2
b1 = bsp.toNumpy(bsp.fromProc(partnerID)['num.a1'])
b2 = bsp.toNumpy(bsp.fromProc(partnerID)['num.a2'])
print 'b1 = ', b1
print 'b2 = ', b2
Beispiel #5
0
s2 = (3,5,'123','hello world!')
bsp.fromObject(s1,'obj.s1')
bsp.fromObject(s2,'obj.s2')

a1 = numpy.ndarray([2,3,3],dtype='f8')
a2 = numpy.ndarray([10])
for i in range(3):
    for j in range(3):
        a1[0][i][j] = i+j
        a1[1][i][j] = i-j
for k in range(10):
    a2[k] = math.cos(k)
bsp.fromNumpy(a1,'num.a1')
bsp.fromNumpy(a2,'num.a2')

bsp.toProc(partnerID,'obj.s1')
bsp.toProc(partnerID,'obj.s2')
bsp.toProc(partnerID,'num.a1')
bsp.toProc(partnerID,'num.a2')

bsp.sync('hello',mSync)
t1=bsp.toObject(bsp.fromProc(partnerID)['obj.s1'])
print('t1 = ', t1)
t2=bsp.toObject(bsp.fromProc(partnerID)['obj.s2'])
print('t2 = ', t2)
b1=bsp.toNumpy(bsp.fromProc(partnerID)['num.a1'])
b2=bsp.toNumpy(bsp.fromProc(partnerID)['num.a2'])
print('b1 = ', b1)
print('b2 = ', b2)

Beispiel #6
0
import bsp
import numpy as np
#bsp.toggleVerbose()
nProcs = bsp.procCount()
myProcID = bsp.myProcID()
nBatches = 1000
if myProcID == 0:
    for i in range(1, nProcs):
        bsp.addWorker(i)
    bsp.setScheduler(10, 5, 8)
    bsp.createArray('iLocalBatch', 'i4', [nProcs])
    bsp.share('iLocalBatch')
    bsp.sync('NOTHING')
    for r in range(nBatches):
        batch = bsp. async ('to master', r == nBatches - 1
                            or (r + 1) % 100 == 0)
        rLocal = []
        for i in batch:
            rLocal.append(bsp.asNumpy('iLocalBatch')[i])
        print('%i: ' % r, batch, rLocal)

        bsp.fromObject(r, 'iBatch')
        for i in batch:
            bsp.toProc(i, 'iBatch')
        bsp. async ('from master')
else:
    bsp.createArray('iLocalBatch', 'i4', [1])
    bsp.share('iLocalBatch')
    bsp.sync('NOTHING')
    inds1 = bsp.createPointSet([myProcID])
    for s in range(nBatches):