示例#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))
示例#2
0
import math

nProcs = bsp.procCount()
myProcID = bsp.myProcID()
partnerID = 1 ^ myProcID
mSync = numpy.ndarray([nProcs, nProcs], dtype=bool)
for row in range(nProcs):
    for col in range(nProcs):
        if col == 1 ^ row:
            mSync[row][col] = True
        else:
            mSync[row][col] = False

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')
示例#3
0
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
        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:
示例#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
示例#5
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
示例#6
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))
示例#7
0
import math

nProcs = bsp.procCount()
myProcID = bsp.myProcID()
partnerID = 1^myProcID
mSync = numpy.ndarray([nProcs,nProcs],dtype=bool)
for row in range(nProcs):
    for col in range(nProcs):
        if col == 1^row:
            mSync[row][col] = True
        else:
            mSync[row][col] = False

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')
示例#8
0
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
        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: