# 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
# create the local parts of the global array bsp.createArray('arr.a1','f8',[10,10]) a1=bsp.asNumpy('arr.a1') for i in range(10): for j in range(10): a1[i][j] = i0+i1+i+j # globalize the local array bsp.globalize(0,(n1Dim,n1Dim),'arr.a1') # create an index-set for the request inds1=bsp.createRegionSet(([[5,5],[2,0]],[[14,14],[11,9]])); # 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
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
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