def __init__(self, args): if len(args) <= 1: args = [None, 2, 3] # default: 2 dimensions of size 3 elif len(args) != 3: charm.abort( "Usage : python array_hello.py [<num_dimensions> <array_size>]" ) ro.nDims = int(args[1]) ro.ARRAY_SIZE = [int(args[2])] * ro.nDims ro.firstIdx = [0] * ro.nDims ro.lastIdx = tuple([x - 1 for x in ro.ARRAY_SIZE]) self.nElements = 1 for x in ro.ARRAY_SIZE: self.nElements *= x print("Running Hello on " + str(CkNumPes()) + " processors for " + str(self.nElements) + " elements") ro.mainProxy = self.thisProxy self.arrProxy = Array(Hello, ndims=ro.nDims) print("Created array proxy") indices = list( itertools.product(range(ro.ARRAY_SIZE[0]), repeat=ro.nDims)) assert len(indices) == self.nElements for i in indices: self.arrProxy.ckInsert(i) self.arrProxy.ckDoneInserting() self.arrProxy[ro.firstIdx].SayHi(17)
def main(args): if (len(args) != 3) and (len(args) != 7): print(args[0] + " [array_size] [block_size]") print( "OR " + args[0] + " [array_size_X] [array_size_Y] [array_size_Z] [block_size_X] [block_size_Y] [block_size_Z]" ) charm.abort("Incorrect program arguments") if len(args) == 3: ro.arrayDimX = ro.arrayDimY = ro.arrayDimZ = int(args[1]) ro.blockDimX = ro.blockDimY = ro.blockDimZ = int(args[2]) elif len(args) == 7: ro.arrayDimX, ro.arrayDimY, ro.arrayDimZ = [ int(arg) for arg in args[1:4] ] ro.blockDimX, ro.blockDimY, ro.blockDimZ = [ int(arg) for arg in args[4:7] ] if (ro.arrayDimX < ro.blockDimX) or (ro.arrayDimX % ro.blockDimX != 0): charm.abort("array_size_X % block_size_X != 0!") if (ro.arrayDimY < ro.blockDimY) or (ro.arrayDimY % ro.blockDimY != 0): charm.abort("array_size_Y % block_size_Y != 0!") if (ro.arrayDimZ < ro.blockDimZ) or (ro.arrayDimZ % ro.blockDimZ != 0): charm.abort("array_size_Z % block_size_Z != 0!") ro.num_chare_x = ro.arrayDimX // ro.blockDimX ro.num_chare_y = ro.arrayDimY // ro.blockDimY ro.num_chare_z = ro.arrayDimZ // ro.blockDimZ print("\nSTENCIL COMPUTATION WITH BARRIERS\n") print("Running Stencil on " + str(charm.numPes()) + " processors with " + str((ro.num_chare_x, ro.num_chare_y, ro.num_chare_z)) + " chares") print("Array Dimensions: " + str((ro.arrayDimX, ro.arrayDimY, ro.arrayDimZ))) print("Block Dimensions: " + str((ro.blockDimX, ro.blockDimY, ro.blockDimZ))) nb_precomps = Group(NumbaPrecompiler) charm.awaitCreation(nb_precomps) # wait until Numba functions are compiled sim_done = charm.createFuture() array = Array(Stencil, (ro.num_chare_x, ro.num_chare_y, ro.num_chare_z), args=[sim_done]) charm.awaitCreation(array) print("Starting simulation") initTime = time.time() array.start() sim_done.get() # wait until simulation completes totalTime = time.time() - initTime print(MAX_ITER, "iterations completed, total time=", round(totalTime, 3), "secs, time per iteration (ms) =", round(totalTime / MAX_ITER * 1000, 3)) charm.printStats() charm.exit()
def main(args): if len(args) <= 1: args = [None, 3, 2] # default: 3 dimensions of size 2 each elif len(args) != 3: charm.abort( "Usage : python array_hello.py [<num_dimensions> <array_size>]") ro.nDims = int(args[1]) ro.ARRAY_SIZE = [int(args[2])] * ro.nDims ro.firstIdx = [0] * ro.nDims ro.lastIdx = tuple([x - 1 for x in ro.ARRAY_SIZE]) nElements = 1 for x in ro.ARRAY_SIZE: nElements *= x print("Running Hello on " + str(CkNumPes()) + " processors for " + str(nElements) + " elements, array dims=" + str(ro.ARRAY_SIZE)) arrProxy = Array(Hello, ro.ARRAY_SIZE) arrProxy[ro.firstIdx].SayHi(17)
def processGhosts(self, direction, height, width, gh): blockDimX, blockDimY, blockDimZ = ro.blockDimX, ro.blockDimY, ro.blockDimZ def index2(a, b, c): return (a + b * (blockDimX + 2) + c * (blockDimX + 2) * (blockDimY + 2)) if direction == LEFT: for k in range(width): for j in range(height): self.temperature[index2(0, j + 1, k + 1)] = gh[k * height + j] elif direction == RIGHT: for k in range(width): for j in range(height): self.temperature[index2(blockDimX + 1, j + 1, k + 1)] = gh[k * height + j] elif direction == BOTTOM: for k in range(width): for i in range(height): self.temperature[index2(i + 1, 0, k + 1)] = gh[k * height + i] elif direction == TOP: for k in range(width): for i in range(height): self.temperature[index2(i + 1, blockDimY + 1, k + 1)] = gh[k * height + i] elif direction == FRONT: for j in range(width): for i in range(height): self.temperature[index2(i + 1, j + 1, 0)] = gh[j * height + i] elif direction == BACK: for j in range(width): for i in range(height): self.temperature[index2(i + 1, j + 1, blockDimZ + 1)] = gh[j * height + i] else: charm.abort("ERROR\n")
def __init__(self, args): if (len(args) != 3) and (len(args) != 7): print(args[0] + " [array_size] [block_size]") print( "OR " + args[0] + " [array_size_X] [array_size_Y] [array_size_Z] [block_size_X] [block_size_Y] [block_size_Z]" ) charm.abort("Incorrect program arguments") if len(args) == 3: ro.arrayDimX = ro.arrayDimY = ro.arrayDimZ = int(args[1]) ro.blockDimX = ro.blockDimY = ro.blockDimZ = int(args[2]) elif len(args) == 7: ro.arrayDimX, ro.arrayDimY, ro.arrayDimZ = [ int(arg) for arg in args[1:4] ] ro.blockDimX, ro.blockDimY, ro.blockDimZ = [ int(arg) for arg in args[4:7] ] if (ro.arrayDimX < ro.blockDimX) or (ro.arrayDimX % ro.blockDimX != 0): charm.abort("array_size_X % block_size_X != 0!") if (ro.arrayDimY < ro.blockDimY) or (ro.arrayDimY % ro.blockDimY != 0): charm.abort("array_size_Y % block_size_Y != 0!") if (ro.arrayDimZ < ro.blockDimZ) or (ro.arrayDimZ % ro.blockDimZ != 0): charm.abort("array_size_Z % block_size_Z != 0!") ro.num_chare_x = ro.arrayDimX // ro.blockDimX ro.num_chare_y = ro.arrayDimY // ro.blockDimY ro.num_chare_z = ro.arrayDimZ // ro.blockDimZ print("\nSTENCIL COMPUTATION WITH BARRIERS\n") print("Running Stencil on " + str(CkNumPes()) + " processors with " + str((ro.num_chare_x, ro.num_chare_y, ro.num_chare_z)) + " chares") print("Array Dimensions: " + str((ro.arrayDimX, ro.arrayDimY, ro.arrayDimZ))) print("Block Dimensions: " + str((ro.blockDimX, ro.blockDimY, ro.blockDimZ))) # Create new array of worker chares ro.mainProxy = self.thisProxy self.array = Array(Stencil, (ro.num_chare_x, ro.num_chare_y, ro.num_chare_z)) # Start the computation self.array.begin_iteration()
def main(args): if charm.numPes() < 3: charm.abort("Run program with at least 3 PEs") grp_proxy = Group(Test) grp_proxy[0].start()
def main(args): if charm.numPes() < 3: charm.abort("Run program with at least 3 PEs") ro.numParticipants = min(charm.numPes() - 1, 31) Group(Test).run()
def __init__(self, args): if CkNumPes() < 3: charm.abort("Run program with at least 3 PEs") grp_proxy = Group(Test) grp_proxy[0].start()
def main(args): if charm.numPes() == 1: charm.abort("Run program with more than 1 PE") array_proxy = Array(Migrate, CHARES_PER_PE * charm.numPes()) array_proxy.start()
def __init__(self, args): if CkNumPes() < 3: charm.abort("Run program with at least 3 PEs") Group(Test).run()