Example #1
0
 def done_float(self, reduction_result):
   expected_result = [x*CkNumPes() for x in [10.1, 13.4]]
   indices_sum = (CkNumPes() * (CkNumPes() - 1))/2
   expected_result += [float(indices_sum)]
   assert_allclose(reduction_result, expected_result, 1e-03)
   print("[Main] All sum_float contributions done. Test passed")
   self.recvdReductions += 1
   if (self.recvdReductions >= self.expectedReductions):
       CkExit()
Example #2
0
    def __init__(self, args):

        ro.mainProxy = self.thisProxy
        ro.NUM_CHARES = CkNumPes() * CHARES_PER_PE
        ro.arrayProxy = Array(Test, ro.NUM_CHARES)
        ro.arrayProxy.run()
        self.startTime = time.time()
Example #3
0
    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)
Example #4
0
 def __init__(self, args):
     ro.numChares = CkNumPes() * CHARES_PER_PE
     ro.arrayIndexes = [(i, ) for i in range(ro.numChares)]
     ro.testProxy = Array(Test, ro.numChares)
     ro.mainProxy = self.thisProxy
     ro.testProxy.doIteration()
     self.iterations = 0
     self.startTime = time.time()
Example #5
0
 def done_gather_single(self, result):
     gather_arr_indices = list(range(self.nElements))
     gather_grp_indices = list(range(CkNumPes()))
     assert result == gather_arr_indices or result == gather_grp_indices, "Gather single elements failed."
     print("[Main] Gather collective for single elements done. Test passed")
     self.recvdReductions += 1
     if (self.recvdReductions >= self.expectedReductions):
         CkExit()
Example #6
0
 def testWhen(self, id, msg):
     assert (CkMyPe() == 0) and (self.current == id) and (msg == "hi")
     print(str(id) + " " + str(self.msgsRcvd))
     self.msgsRcvd += 1
     if self.msgsRcvd >= GRP_TO_SEND:
         self.msgsRcvd = 0
         self.current += 1
         if self.current == CkNumPes(): charm.exit()
Example #7
0
 def done_gather_array(self, result):
     gather_arr_indices = [tuple([i]) for i in range(self.nElements)]
     gather_grp_indices = [[i, 42] for i in range(CkNumPes())]
     assert result == gather_arr_indices or result == gather_grp_indices, "Gather arrays failed."
     print("[Main] Gather collective for arrays done. Test passed")
     self.recvdReductions += 1
     if (self.recvdReductions >= self.expectedReductions):
         CkExit()
Example #8
0
 def SayHi(self, hellos):
     hellos.addHello("Hi[" + str(hellos.hiNo) + "] from element " +
                     str(self.thisIndex))
     hellos.hiNo += 1
     if self.thisIndex + 1 < CkNumPes():
         # Pass the hello list on:
         self.thisProxy[self.thisIndex + 1].SayHi(hellos)
     else:
         ro.mainProxy.done(hellos)
Example #9
0
    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()
Example #10
0
  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()
Example #11
0
    def __init__(self, args):

        if len(args) <= 1:
            self.total_iterations = default_total_iterations
        else:
            self.total_iterations = int(args[1])

        self.iteration = self.count = 0
        self.programStartTime = self.periodStartTime = time.time()
        ro.mainProxy = self.thisProxy  # store the main proxy

        print("Running wave2d on " + str(CkNumPes()) + " processors")

        # Create new array of worker chares
        ro.arrayProxy = Array(Wave, (chareArrayWidth, chareArrayHeight))
        # Start the computation
        ro.arrayProxy.begin_iteration(False)
Example #12
0
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)
Example #13
0
  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())
Example #14
0
 def reduceGroupToGroup(self, reduction_result):
   assert self.thisIndex == 0
   assert list(reduction_result) == [CkNumPes()*x for x in [5, 7, -3, 0]], "Group-to-group reduction failed."
   ro.mainProxy.done_group_to_group()
Example #15
0
 def __init__(self, args):
     print("Running Hello on " + str(CkNumPes()) + " processors")
     grpProxy = Group(Hello)
     grpProxy[0].SayHi(HelloList(17))
     ro.mainProxy = self.thisProxy
Example #16
0
 def __init__(self, args):
     if CkNumPes() < 3: charm.abort("Run program with at least 3 PEs")
     Group(Test).run()
Example #17
0
 def done_int(self, reduction_result):
   assert reduction_result == 42*CkNumPes(), "Group-to-singleton sum_int reduction failed"
   print("[Main] All sum_int contributions done. Test passed")
   self.recvdReductions += 1
   if (self.recvdReductions >= self.expectedReductions):
       CkExit()
Example #18
0
 def reduceGroupToArrayBcast(self, reduction_result):
   assert reduction_result == -4*CkNumPes(), "Group-to-array bcast reduction failed."
   self.contribute(None, None, ro.mainProxy.done_group_to_array_bcast)
Example #19
0
 def reduceGroupToArray(self, reduction_result):
   assert self.thisIndex[0] == 0
   assert_allclose(reduction_result, [CkNumPes()*x for x in [4.2, 13.1]], 1e-03)
   ro.mainProxy.done_group_to_array()
Example #20
0
 def reduceGroupToGroupBcast(self, reduction_result):
   assert_almost_equal(reduction_result, -4.2*CkNumPes(), 1e-03)
   self.contribute(None, None, ro.mainProxy.done_group_to_group_bcast)
Example #21
0
 def SayHi(self):
     print("Hello from PE", CkMyPe(), "on", time.strftime('%c'))
     ro.byes[(self.thisIndex + 1) % CkNumPes()].SayGoodbye()
Example #22
0
 def __init__(self, args):
     if CkNumPes() < 3:
         charm.abort("Run program with at least 3 PEs")
     grp_proxy = Group(Test)
     grp_proxy[0].start()