Beispiel #1
0
import bsp
#bsp.toggleVerbose()
nProcs = bsp.procCount()
myProcID = bsp.myProcID()
if myProcID != 0:
    bsp.fromObject(myProcID, 'procID')
    bsp.toProc(0, 'procID')
    bsp. async ('one async')
elif myProcID == 0:
    for round in range(nProcs - 1):
        procSet = bsp. async ('one async')
        for procID in procSet:
            iProc = bsp.toObject(bsp.fromProc(procID)['procID'])
            print('%d, %d, %d' % (nProcs, procID, iProc))
Beispiel #2
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
        bsp.updateFrom('iLocalBatch','=','iLocalBatch',inds1,0)
        bsp.async('to master')
        bsp.async('from master')
        r = bsp.toObject(bsp.fromProc(0)['iBatch'])
        if r == nBatches - 1:
            break
Beispiel #3
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 #4
0
import bsp
import os
#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)
    for r in range(nBatches):
        batch = bsp. async ('to master', r == nBatches - 1
                            or (r + 1) % 100 == 0)
        print('%i: ' % r, batch)

        bsp.fromObject(r, 'iBatch')
        for i in batch:
            bsp.toProc(i, 'iBatch')
        bsp. async ('from master')
else:
    for s in range(nBatches):
        bsp.fromObject(s, 'iLocalBatch')
        bsp.toProc(0, 'iLocalBatch')
        bsp. async ('to master')
        bsp. async ('from master')
        r = bsp.toObject(bsp.fromProc(0)['iBatch'])
        if r == nBatches - 1:
            break
Beispiel #5
0
import bsp
#bsp.toggleVerbose()
nProcs = bsp.procCount()
myProcID = bsp.myProcID()
if myProcID != 0:
    bsp.fromObject(myProcID, 'procID')
    bsp.toProc(0, 'procID')
    bsp.async('one async')
elif myProcID == 0:
    for round in range(nProcs - 1):
        procSet = bsp.async('one async')
        for procID in procSet:
            iProc = bsp.toObject(bsp.fromProc(procID)['procID'])
            print('%d, %d, %d'%(nProcs, procID, iProc))
Beispiel #6
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)