示例#1
0
import bsp
import numpy
import math

# get the 2D coordinates
nProcs = bsp.procCount()
myProcID = bsp.myProcID()
n1Dim = int(math.floor(math.sqrt(nProcs)))
i0 = 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
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
示例#2
0
import bsp
import numpy
import math

# get the 2D coordinates
nProcs = bsp.procCount()
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!!')
示例#3
0
import bsp
import numpy
import math

# get the 2D coordinates
nProcs = bsp.procCount()
myProcID = bsp.myProcID()
n1Dim = int(math.floor(math.sqrt(nProcs)))
i0 = 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
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
示例#4
0
文件: t1.py 项目: solker2015/Py3BSP
import bsp
import gc
#gc.set_debug(gc.DEBUG_STATS|gc.DEBUG_LEAK) 
bsp.createArray('ind.lower1','u4',[2,2])
bsp.createArray('ind.upper1','u2',[2,2])
bsp.createArray('ind.lower2','i4',[2])
bsp.createArray('ind.upper2','i4',[2])
bsp.createArray('ind.lower3','i4',[3])
bsp.createArray('ind.upper3','i4',[3])
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
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))
示例#5
0
#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
        bsp.updateFrom('iLocalBatch','=','iLocalBatch',inds1,0)
        bsp.async('to master')
示例#6
0
import bsp
import gc
#gc.set_debug(gc.DEBUG_STATS|gc.DEBUG_LEAK)
bsp.createArray('ind.lower1', 'u4', [2, 2])
bsp.createArray('ind.upper1', 'u2', [2, 2])
bsp.createArray('ind.lower2', 'i4', [2])
bsp.createArray('ind.upper2', 'i4', [2])
bsp.createArray('ind.lower3', 'i4', [3])
bsp.createArray('ind.upper3', 'i4', [3])
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
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
示例#7
0
文件: simple01.py 项目: Solkers/PyBSP
import bsp
import numpy
import math

# get the 2D coordinates
nProcs = bsp.procCount()
myProcID = bsp.myProcID()
n1Dim = int(math.floor(math.sqrt(nProcs)))
i0 = 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 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
示例#8
0
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
        bsp.updateFrom('iLocalBatch', '=', 'iLocalBatch', inds1, 0)
        bsp. async ('to master')