def main(args): f1 = charm.createFuture() f2 = charm.createFuture() Group(Test, args=[f1, f2]) assert f1.get() == charm.numPes() assert f2.get() == charm.numPes() charm.exit()
def main(args): testProxy = Array(Test, charm.numPes() * CHARES_PER_PE) sum_f = charm.createFuture() min_f = charm.createFuture() max_f = charm.createFuture() testProxy.getStats((sum_f, min_f, max_f)) print("[Main] Sum: " + str(sum_f.get()) + ", Min: " + str(min_f.get()) + ", Max: " + str(max_f.get())) print("[Main] All done.") charm.exit()
def main(args): f1 = charm.createFuture() f2 = charm.createFuture() Group(Test, args=[f1]) Array(Test, charm.numPes() * 4, args=[f2]) np.testing.assert_allclose(f1.get(), np.arange(10, dtype='float64') * charm.numPes()) np.testing.assert_allclose( f2.get(), np.arange(10, dtype='float64') * charm.numPes() * 4) charm.exit()
def main(args): if charm.numPes() < 5: print("\nRun this example with at least 5 PEs\n") charm.exit() pool = Chare(Master, onPE=0) # create one Master called 'pool' on PE 0 f1 = charm.createFuture() f2 = charm.createFuture() tasks1 = [1, 2, 3, 4, 5] tasks2 = [1, 3, 5, 7, 9] pool.map_async(f, 2, tasks1, f1) pool.map_async(f, 2, tasks2, f2) print("Final results are", f1.get(), f2.get()) # wait on futures charm.exit()
def main(args): # create Group of Hello objects (one object exists and runs on each core) hellos = Group(Hello) # call method 'SayHi' of all group members, wait for method to be invoked on all f = charm.createFuture() hellos.SayHi(f) f.get() charm.exit()
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): numChares = min(charm.numPes() * CHARES_PER_PE, 64) testProxy = Array(Test, numChares) f = charm.createFuture(senders=numChares) testProxy.getData(f) data = f.get() print("[Main] Received data: " + str(data)) assert sorted(data) == list(range(numChares)), "Multi-futures failed!" print("[Main] All done.") charm.exit()
def __init__(self, args): self.recvdReductions = 0 self.expectedReductions = 5 ro.nDims = 1 ro.ARRAY_SIZE = [10] * 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 gather example on " + str(CkNumPes()) + " processors for " + str(self.nElements) + " elements, array dims=" + str(ro.ARRAY_SIZE)) ro.mainProxy = self.thisProxy ro.arrProxy = Array(Test, ro.ARRAY_SIZE) ro.grpProxy = Group(TestGroup) ro.arrProxy.doGather() ro.grpProxy.doGather() red_future = charm.createFuture() ro.arrProxy.doGather(red_future) self.done_gather_single(red_future.get())
def main(args): # put sim parameters in readonlies container. objects stored in this container are # broadcasted to all other processes, and can be accessed using same container in remote process if len(args) == 3: ro.arrayDims = (int(args[1]), int(args[2])) else: ro.arrayDims = (6, 3) # default: 2D chare array of 6x3 cells ro.cellSize = (SIM_BOX_SIZE / ro.arrayDims[0], SIM_BOX_SIZE / ro.arrayDims[1]) # create 2D Cell chare array and start simulation simDone = charm.createFuture() cells = Array(Cell, ro.arrayDims, args=[simDone]) # array creation happens asynchronously t0 = time.time() cells.run() # wait for simulation to complete simDone.get() print("Particle simulation done, elapsed time=", round(time.time() - t0, 3), "secs") charm.exit()
def main(args): g = Group(Worker) random.seed(45782) ids = [] for i in range(MAX_VALS): #for _ in range(PHASE_NUM): #ids.append(i) ids.append(i) random.shuffle(ids) done = charm.createFuture() g.start(done, ret=True).get() t0 = time.time() for id in ids: #g.recv_id(id) for _ in range(PHASE_NUM): g.recv_id(id) done.get() print("Elapsed=", time.time() - t0) charm.exit()