Beispiel #1
0
def main(args):
    numChares = charm.numPes() * CHARES_PER_PE
    cells = Array(Cell, numChares, args=[numChares])
    charm.awaitCreation(cells)
    f = Future()
    cells.work(f)
    f.get()
    exit()
Beispiel #2
0
def main(args):
    g1 = Group(Test)
    g2 = Group(Test)
    g3 = Group(Test)
    g4 = Group(Test)

    P = charm.numPes()
    a1 = Array(Test, P * 8)
    a2 = Array(Test, P * 10)
    a3 = Array(Test, P * 4)
    a4 = Array(Test, P * 1)

    charm.awaitCreation(g1, g2, g3, g4, a1, a2, a3, a4)

    chares = []  # proxies to all individual chares created
    for collection in (g1, g2, g3, g4):
        for idx in range(P):
            chares.append(collection[idx])

    for collection, numelems in ((a1, P * 8), (a2, P * 10), (a3, P * 4), (a4,
                                                                          P)):
        for idx in range(numelems):
            chares.append(collection[idx])

    print('There are', len(chares), 'chares')

    # establish random channels between chares
    global gchannels
    gchannels = {}
    num_self_channels = 0
    for level in range(NUM_LEVELS):
        gchannels[level] = defaultdict(list)
        for _ in range(NUM_CHANNELS):
            a = random.choice(chares)
            b = random.choice(chares)
            if a == b:
                num_self_channels += 1
            gchannels[level][a].append(b)
            gchannels[level][b].append(a)
    charm.thisProxy.updateGlobals({
        'gchannels': gchannels
    }, awaitable=True).get()

    done_fut = Future(8 *
                      NUM_LEVELS)  # wait for 8 collections to finish 3 levels
    for collection in (g1, g2, g3, g4, a1, a2, a3, a4):
        collection.setup(awaitable=True).get()
    print(NUM_CHANNELS * NUM_LEVELS, 'channels set up,', num_self_channels,
          'self channels')
    for collection in (g1, g2, g3, g4, a1, a2, a3, a4):
        for lvl in range(NUM_LEVELS):
            collection.work(lvl, done_fut)

    msgs = sum(done_fut.get())
    assert msgs == sum(LEVELS_NUM_ITER[:NUM_LEVELS]) * NUM_CHANNELS * 2
    print('total msgs received by chares=', msgs)
    exit()
Beispiel #3
0
def main(args):
    assert charm.numPes() >= 4
    g1 = Group(Hello)
    g2 = Group(proxies_same_name_aux.Hello)
    tester1 = Chare(Test, onPE=2)
    tester2 = Chare(proxies_same_name_aux.Test, onPE=1)
    charm.awaitCreation(g2, g1, tester2, tester1)
    tester1.test(g2, 'check2', awaitable=True).get()
    tester2.test(g1, 'check1', awaitable=True).get()
    exit()
Beispiel #4
0
def main(args):
    threaded = False
    if len(args) > 1 and args[1] == '-t':
        threaded = True
    pings = Array(Ping, 2)
    charm.awaitCreation(pings)
    for _ in range(2):
        done_future = Future()
        pings[0].start(done_future, threaded)
        totalTime = done_future.get()
        print("ping pong time per iter (us)=", totalTime / NITER * 1000000)
    exit()
Beispiel #5
0
def main(args):
    numChares = charm.numPes() * 10
    a = Array(Test, numChares)
    g = Group(Test)
    charm.awaitCreation(a, g)
    f1 = Future()
    f2 = Future()
    a.start(f1)
    g.start(f2)
    f1.get()
    f2.get()
    exit()
Beispiel #6
0
def main(args):
    # Note that chare creation calls are also asynchronous

    # create one instance of MyChare on every processor
    my_group = Group(MyChare)

    # create 3 instances of MyChare, distributed among cores by the runtime
    my_array = Array(MyChare, 3)

    # create 2 x 2 instances of MyChare, indexed using 2D index and distributed
    # among cores by the runtime
    my_2d_array = Array(MyChare, (2, 2))

    # wait for the chare collections to be created
    charm.awaitCreation(my_group, my_array, my_2d_array)
    exit()
Beispiel #7
0
    def __init__(self, args):
        assert charm.numPes() > 1
        numChares = charm.numPes() * CHARES_PER_PE
        self.workers = Array(Worker, numChares, args=[numChares])
        print('WORK_TIME=', WORK_TIME)
        qdGroupReceivers = Group(QDReceiver, args=[self.thisProxy])
        qdArrayReceivers = Array(QDReceiver, charm.numPes(), args=[self.thisProxy])
        charm.awaitCreation(self.workers, qdGroupReceivers, qdArrayReceivers)

        self.testQD(callback=self.thisProxy.recvQD)
        self.testQD(callback=qdGroupReceivers.recvQD)
        self.testQD(callback=qdArrayReceivers.recvQD)
        self.testQD(callback=qdGroupReceivers[1].recvQD)
        self.testQD(callback=qdArrayReceivers[1].recvQD)
        self.testQD(callback=Future())
        self.testQD(callback=None)

        exit()
Beispiel #8
0
def main(args):
    g1 = Group(Test)
    g2 = Group(Test)

    numArrayChares = charm.numPes() * 8
    a1 = Array(Test, numArrayChares)
    a2 = Array(Test, numArrayChares)

    charm.awaitCreation(g1, g2, a1, a2)

    wait_alldone = [charm.Future() for _ in range(4)]
    i = 0
    for collection in (g1, g2):
        collection.run(charm.numPes(), wait_alldone[i])
        i += 1

    for collection in (a1, a2):
        collection.run(numArrayChares, wait_alldone[i])
        i += 1

    for done in wait_alldone:
        done.get()
    print('DONE')
    exit()
Beispiel #9
0
def main(args):
    g = Group(A)
    a = Array(B, charm.numPes(), args=[g])
    charm.awaitCreation(a)
    exit()
Beispiel #10
0
def main(args):
    global blockDimX, blockDimY, num_chare_x, num_chare_y
    if len(args) != 3 and len(args) != 5:
        print('\nUsage:\t', args[0], 'array_size block_size')
        print('\t', args[0],
              'array_size_X array_size_Y block_size_X block_size_Y')
        exit()

    if len(args) == 3:
        arrayDimX = arrayDimY = int(args[1])
        blockDimX = blockDimY = int(args[2])
    elif len(args) == 5:
        arrayDimX, arrayDimY = [int(arg) for arg in args[1:3]]
        blockDimX, blockDimY = [int(arg) for arg in args[3:5]]

    assert (arrayDimX >= blockDimX) and (arrayDimX % blockDimX == 0)
    assert (arrayDimY >= blockDimY) and (arrayDimY % blockDimY == 0)
    num_chare_x = arrayDimX // blockDimX
    num_chare_y = arrayDimY // blockDimY

    # set the following global variables on every PE, wait for the call to complete
    charm.thisProxy.updateGlobals(
        {
            'blockDimX': blockDimX,
            'blockDimY': blockDimY,
            'num_chare_x': num_chare_x,
            'num_chare_y': num_chare_y
        },
        awaitable=True).get()

    print('\nRunning Jacobi on', charm.numPes(), 'processors with',
          num_chare_x, 'x', num_chare_y, 'chares')
    print('Array Dimensions:', arrayDimX, 'x', arrayDimY)
    print('Block Dimensions:', blockDimX, 'x', blockDimY)
    print('Max iterations:', MAX_ITER)
    print('Threshold:', THRESHOLD)

    if numbaFound:
        # wait until Numba functions are compiled on every PE, so we can get consistent benchmark results
        Group(Util).compile(awaitable=True).get()
        print('Numba compilation complete')
    else:
        print(
            '!!WARNING!! Numba not found. Will run without Numba but it will be very slow'
        )

    sim_done = Future()
    # create 2D chare array of Jacobi objects (each chare will hold one block)
    array = Array(Jacobi, (num_chare_x, num_chare_y), args=[sim_done])
    charm.awaitCreation(array)

    print('Starting computation')
    initTime = time.time()
    array.run()  # this is a broadcast
    total_iterations = sim_done.get()  # wait until the computation completes
    totalTime = time.time() - initTime
    if total_iterations >= MAX_ITER:
        print('Finished due to max iterations', total_iterations, 'total time',
              round(totalTime, 3), 'seconds')
    else:
        print('Finished due to convergence, iterations', total_iterations,
              'total time', round(totalTime, 3), 'seconds')
    exit()
Beispiel #11
0
def main(args):
    g = Group(Test, args=[33])
    a = Array(Test, charm.numPes() * 4, args=[50])
    charm.awaitCreation(g, a)
    exit()