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): grpProxy = Group(Test) for i in range(charm.numPes()): data = grpProxy[i].getData(ret=True).get() assert data == i**2, "Blocking call in main failed." print("Test " + str(i) + " sent data: " + str(data)) 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): 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): # create one instance of MyChare on every processor my_group = Group(MyChare) # create 3 instances of MyChare, distributed among all cores by the runtime my_array = Array(MyChare, 3) # create 2 x 2 instances of MyChare, indexed using 2D index and distributed # among all cores by the runtime my_2d_array = Array(MyChare, (2, 2))
def main(args): array_map = Group(MyMap) for nDims in range(1,7): if nDims <= 3: dim_size = 4 else: dim_size = 2 if nDims < 6: Array(MyChare, [dim_size]*nDims, args=[False], map=array_map) else: dyn_array = Array(MyChare, ndims=nDims, map=array_map) for idx in itertools.product(range(dim_size), repeat=nDims): dyn_array.ckInsert(idx, args=[True]) dyn_array.ckDoneInserting()
def __init__(self, args): self.expectedReductions = 7 self.recvdReductions = 0 ro.nDims = 1 ro.ARRAY_SIZE = [10] * ro.nDims # 1-D array with 10 elements 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 reduction example on " + str(CkNumPes()) + " processors for " + str(nElements) + " elements, array dims=" + str(ro.ARRAY_SIZE)) ro.mainProxy = self.thisProxy ro.arrProxy = Array(Test, ro.ARRAY_SIZE) ro.groupProxy = Group(TestGroup) ro.arrProxy.doReduction()
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): a = Array(Test, charm.numPes()) sleepTimes = [random.uniform(0.5, 1.5) for i in range(charm.numPes())] # for some reason, work() runs on PE 0 before sending the broadcast msgs out # to the other PEs, so I set wait time to 0 on PE 0 sleepTimes[0] = 0.0 t0 = time.time() a.work(sleepTimes, ret=True).get() # wait for broadcast to complete wait_time = time.time() - t0 assert(wait_time >= max(sleepTimes)) print(wait_time, max(sleepTimes)) g = Group(Test) sleepTimes = [random.uniform(0.5, 1.5) for i in range(charm.numPes())] sleepTimes[0] = 0.0 t0 = time.time() g.work(sleepTimes, ret=True).get() # wait for broadcast to complete wait_time = time.time() - t0 assert(wait_time >= max(sleepTimes)) print(wait_time, max(sleepTimes)) 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()
def main(args): print("Running Hello on " + str(charm.numPes()) + " processors") Group(Hello)[0].SayHi(HelloList(17))
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 main(args): my_group = Group(MyChare) my_group.work(3)
def __init__(self, args): Group(Test).work(self.thisProxy) Array(Test, 20).work(self.thisProxy) self.countReductions = self.count = 0
def __init__(self, args): if CkNumPes() < 3: charm.abort("Run program with at least 3 PEs") Group(Test).run()
def __init__(self): # create a Worker in every processor self.workers = Group(Worker) self.free_procs = set(range(1, charm.numPes())) self.next_job_id = 0 self.jobs = {}
def main(args): ro.numChares = min(charm.numPes() * 8, 32) ro.testGroup = Group(Test2) Array(Test, ro.numChares)
def __init__(self, args): Group(Test).work(self.thisProxy) Array(Test, charm.numPes() * CHARES_PER_PE).work(self.thisProxy) self.countReductions = self.count = 0
def __init__(self, args): print("Running Hello on " + str(charm.numPes()) + " processors") grpProxy = Group(Hello) grpProxy[0].SayHi(17) ro.mainProxy = self.thisProxy
def __init__(self, args): # create Group of Hello objects (one object exists and runs on each core) hellos = Group(Hello) # call method 'SayHello' of all group members, passing proxy to myself hellos.SayHi(self.thisProxy)
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): # every chare sends to every other so don't want a ton of chares ro.numChares = min(charm.numPes() * 8, 32) ro.testGroup = Group(Test2) Array(Test, ro.numChares)
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): ro.controllers = Group(Controller) ro.array = Array(Test, charm.numPes() * 4)
def __init__(self, args): ro.mainProxy = self.thisProxy hellos = Group(hello.Hello) ro.byes = Group(goodbye.Goodbye) hellos.SayHi()