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
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 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:
myProcID = bsp.myProcID() n1Dim = int(math.floor(math.sqrt(nProcs))) i0 = int(myProcID / n1Dim) i1 = myProcID % n1Dim # 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 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)
upper1[1][0] = 11; upper1[1][1] = 9 lower2=bsp.asNumpy('ind.lower2') upper2=bsp.asNumpy('ind.upper2') lower3=bsp.asNumpy('ind.lower3') upper3=bsp.asNumpy('ind.upper3') lower2[0] = 5 lower2[1] = 3 upper2[0] = 6 upper2[1] = 7 lower3[0] = 15 lower3[1] = 10 lower3[2] = 6 upper3[0] = 20 upper3[1] = 12 upper3[2] = 12 inds1=bsp.createRegionSet(('ind.lower1','ind.upper1')) print('inds1 indcount = ', bsp.indexCount(inds1), ', regcount = ', bsp.regionCount(inds1)) inds2=bsp.createRegionSet(('ind.lower2','ind.upper2'),('ind.lower3','ind.upper3')) print('inds2 indcount = ', bsp.indexCount(inds2), ', regcount = ', bsp.regionCount(inds2)) inds3=bsp.createPointSet('ind.lower1') print('inds3 indcount = ', bsp.indexCount(inds3), ', regcount = ', bsp.regionCount(inds3)) inds4=bsp.createPointSet('ind.lower2','ind.lower3') print('inds4 indcount = ', bsp.indexCount(inds4), ', regcount = ', bsp.regionCount(inds4)) inds5=bsp.createRegionSet(('ind.lower2','ind.upper3'),('ind.lower3','ind.upper2')) print('inds5 indcount = ', bsp.indexCount(inds5), ', regcount = ', bsp.regionCount(inds5)) inds6=bsp.createRegionSet(([[5,5],[2,0]], [[14,14],[11,9]])) print('inds6 indcount = ', bsp.indexCount(inds6), ', regcount = ', bsp.regionCount(inds6)) inds7=bsp.createRegionSet(([5,3],[6,7]),([15,10,6],[20,12,12])) print('inds7 indcount = ', bsp.indexCount(inds7), ', regcount = ', bsp.regionCount(inds7)) inds8=bsp.createPointSet([[5,5],[2,0]])
myProcID = bsp.myProcID() n1Dim = int(math.floor(math.sqrt(nProcs))) i0 = myProcID / n1Dim i1 = myProcID % n1Dim # create the local parts of the global array a1 = bsp.array('arr.a1', 'f8', [10, 10]) 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]])) #inds1=bsp.createPointSet('ind.lower1') # create a local array to store the update data a2 = bsp.array('arr.a2', 'f8', [2, 10, 10]) 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)
upper1[1][1] = 9 lower2 = bsp.asNumpy('ind.lower2') upper2 = bsp.asNumpy('ind.upper2') lower3 = bsp.asNumpy('ind.lower3') upper3 = bsp.asNumpy('ind.upper3') lower2[0] = 5 lower2[1] = 3 upper2[0] = 6 upper2[1] = 7 lower3[0] = 15 lower3[1] = 10 lower3[2] = 6 upper3[0] = 20 upper3[1] = 12 upper3[2] = 12 inds1 = bsp.createRegionSet(('ind.lower1', 'ind.upper1')) print('inds1 indcount = ', bsp.indexCount(inds1), ', regcount = ', bsp.regionCount(inds1)) inds2 = bsp.createRegionSet(('ind.lower2', 'ind.upper2'), ('ind.lower3', 'ind.upper3')) print('inds2 indcount = ', bsp.indexCount(inds2), ', regcount = ', bsp.regionCount(inds2)) inds3 = bsp.createPointSet('ind.lower1') print('inds3 indcount = ', bsp.indexCount(inds3), ', regcount = ', bsp.regionCount(inds3)) inds4 = bsp.createPointSet('ind.lower2', 'ind.lower3') print('inds4 indcount = ', bsp.indexCount(inds4), ', regcount = ', bsp.regionCount(inds4)) inds5 = bsp.createRegionSet(('ind.lower2', 'ind.upper3'), ('ind.lower3', 'ind.upper2')) print('inds5 indcount = ', bsp.indexCount(inds5), ', regcount = ',