示例#1
0
    def work(self):

        if self.flag == "4":
            start = time()
            print("step4 on "+str( charm.myPe()))
            #self.driver.step4()
            #self.driver.step6()
            self.contribute(self.driver.separate_step4(), Reducer.sum, self.future)
            print("step4: " + str(time() - start))
        elif self.flag == '6':
            start = time()
            print("step6 on " + str(charm.myPe()))
            # self.driver.step4()
            # self.driver.step6()
            self.contribute(self.driver.separate_step6(), Reducer.sum, self.future)
            print("step6: " + str(time() - start))
        elif self.flag == "3":
            start = time()
            #self.flag = 100
            print("step3 on "+str( charm.myPe()))
            result = self.driver.step3()
            self.contribute(result, Reducer.sum, self.future)
            print("step3: "+ str(time() - start))
        elif self.flag == "5":
        #print("adjnaskaajsdnkjsanksaksnkajnk")
            start = time()
            print("step5 on "+str(charm.myPe()))
            self.contribute(self.driver.step5(), Reducer.sum, self.future)
            print("step5: " + str(time() - start))
        else:
            self.contribute(np.zeros(9000000), Reducer.sum, self.future)
示例#2
0
 def SayGoodbye(self):
     if charm.myPe() < 10:
         print('Goodbye from PE', charm.myPe())
     # goodbye chares do an empty reduction. after the reduction completes,
     # the 'done' method of the mainchare will be called.
     # mainProxy is a global of this module, set previously from the mainchare
     self.reduce(mainProxy.done)
示例#3
0
 def start(self):
     """
     Invoke the starter code for test.
     """
     if charm.myPe() == 0:
         print(self.thisIndex, 'on PE', charm.myPe(), 'before migration')
     self.toPe = (charm.myPe() + 1) % charm.numPes()
     self.thisProxy[self.thisIndex].migrate(self.toPe)
示例#4
0
 def __init__(self, home_pes_future):
     assert (
         not all_created
     )  # makes sure constructor is only called for creation, not migration
     self.iteration = 0
     self.originalPe = charm.myPe()
     self.data = numpy.arange(100, dtype='int64') * (self.originalPe + 1)
     # notify controllers that array elements are created and pass home PE of every element
     self.contribute(charm.myPe(), Reducer.gather, home_pes_future)
示例#5
0
 def migrated(self):
     """
     Test method called after migration to assert that the
     chare has migrated.
     """
     if self.thisIndex == (0, ):
         print(self.thisIndex, 'migrated to PE', charm.myPe())
     assert charm.myPe() == self.toPe
     self.contribute(None, None, charm.thisProxy[0].exit)
示例#6
0
    def sum_local_exp(self, f):
        start = time()
        if self.flag == "4":
            print("step4 on processor:" + str(charm.myPe()))
            self.contribute(self.driver.separate_step4(), Reducer.sum, f)
            print("step4 time to finish:" + str(time() - start))

        elif self.flag == "6":
            print("step6 on processor:" + str(charm.myPe()))
            self.contribute(self.driver.separate_step6(), Reducer.sum, f)
            print("step6 time to finish:" + str(time() - start))
示例#7
0
    def say(self, msg):
        """
        Helper method which is called by invoking the element proxy.
        This method is expected to be called on only the PE for
        which the proxy is created.
        """

        self.count += 1
        print("Say", msg, "on PE", charm.myPe())
        if self.count == 2:
            assert charm.myPe() == 2
            exit()
示例#8
0
    def direct_result(self, f):
        start = time()

        if self.flag == "3":
            print("step3 on processor: " + str(charm.myPe()))
            self.contribute(self.driver.step3(), Reducer.sum, f)
            print("step3 time to finish:" + str(time() - start))

        elif self.flag == "5":
            print("step5 on processor: " + str(charm.myPe()))
            self.contribute(self.driver.step5(), Reducer.sum, f)
            print("step5 time to finish:" + str(time() - start))
示例#9
0
    def work(self):

        if self.flag == "4":
            start = time()
            print("step4 on " + str(charm.myPe()))
            self.contribute(self.driver.separate_step4(), Reducer.sum,
                            self.future)
            print("step4: " + str(time() - start))

        elif self.flag == "6":
            start = time()
            print("step6 on " + str(charm.myPe()))
            self.contribute(self.driver.separate_step6(), Reducer.sum,
                            self.future)
            print("step6: " + str(time() - start))
        else:
            self.contribute(np.zeros(self.total), Reducer.sum, self.future)
示例#10
0
 def start(self):
     self.hasMigrated = False
     self.iteration += 1
     if self.iteration == MAX_ITER:
         self.contribute(None, None, charm.thisProxy[0].exit)
     else:
         self.prevPe = charm.myPe()
         self.AtSync()
示例#11
0
 def getVal(self, iteration):
     result = 53 * testGroup[charm.myPe()].getVal(ret=True).get() * self.thisIndex[0] * self.iteration
     #assert result == 53 * (73 + charm.myPe()) * self.thisIndex[0] * self.iteration
     self.msgsRcvd += 1
     if self.msgsRcvd == numChares:
         self.msgsRcvd = 0
         self.iteration += 1
     return result
示例#12
0
 def calculate(self):
     print("this piece " + str(self.pos) + "   is on processor:" +
           str(charm.myPe()))
     st = time()
     partial_direct_interaction = ro.driver.multicore_step3(
         self.total_processors, self.pos)
     self.contribute(partial_direct_interaction, Reducer.sum, self.f)
     print("time to calculate " + str(self.pos) +
           "th piece of the direct interaction:" + str(time() - st))
示例#13
0
 def recvLocations(self, locations):
     loc = defaultdict(list)
     for chare_idx, pe in enumerate(locations):
         loc[pe].append(chare_idx)
     myPe = charm.myPe()
     myPos = loc[myPe].index(self.thisIndex[0])
     # i-th chare in a PE sends to i-th chare in PE-1 and PE+1 and to itself
     nb1 = self.thisProxy[loc[(myPe - 1) % charm.numPes()][myPos]]
     nb2 = self.thisProxy[loc[(myPe + 1) % charm.numPes()][myPos]]
     self.nbs = [nb1, nb2, self.thisProxy[self.thisIndex]]
     self.contribute(None, None, mainProxy.start)
示例#14
0
    def work(self):

        if self.flag == "467":
            start = time()
            print("step467 on processor:"+str( charm.myPe()))
            self.contribute(self.driver.step4(), Reducer.sum, self.thisProxy[0].collectResult)
            print("step467 took " + str(time() - start)+" seconds to finish")
        elif self.flag == "3":
            start = time()
            print("step3 on processor:"+str( charm.myPe()))
            result = self.driver.step3()
            self.contribute(result, Reducer.sum, self.thisProxy[0].collectResult)
            print("step3 took "+ str(time() - start)+" seconds to finish")
        elif self.flag == "5":
            start = time()
            print("step5 on processor:"+str(charm.myPe()))
            self.contribute(self.driver.step5(), Reducer.sum, self.thisProxy[0].collectResult)
            print("step5 took " + str(time() - start) +" seconds to finish")
        else:
            self.contribute(np.zeros(self.total), Reducer.sum, self.thisProxy[0].collectResult)
示例#15
0
    def __init__(self):
        self.x = numpy.arange(DATA_LEN, dtype='float64')
        y = self.x * (self.thisIndex[0] + 1)

        self.S1 = y.tobytes()
        self.S2 = array.array('d', y)
        self.S3 = y

        self.msgsRcvd = 0

        self.contribute(charm.myPe(), Reducer.gather,
                        self.thisProxy.recvLocations)
示例#16
0
    def work(self):

        if self.flag == "4":
            start = time()
            print("step4 on processor"+str( charm.myPe()))
            self.contribute(self.driver.multicore_separate_step4(self.total_processors,self.pos), Reducer.sum, self.future)
            print("step4 time to finish: " + str(time() - start)+" on processor "+str(str(charm.myPe())))
        elif self.flag == "3":
            print("step3 on processor " + str(charm.myPe()))
            st = time()
            partial_direct_interaction = self.driver.multicore_step3(self.total_processors, self.pos)
            self.contribute(partial_direct_interaction, Reducer.sum, self.future)
            print("time to calculate " + str(self.pos) + "th piece of the direct interaction:" + str(time() - st))
        elif self.flag == "6":
            start = time()
            print("step6 on processor "+str(charm.myPe()))
            self.contribute(self.driver.multicore_separate_step6(self.total_processors, self.pos), Reducer.sum, self.future)
            print("step6 time to finish: " + str(time() - start)+" on processor "+str(str(charm.myPe())))
        elif self.flag == "5":
            start = time()
            print("step5 on "+str(charm.myPe()))
            self.contribute(self.driver.step5_with_extent(self.total_processors, self.pos), Reducer.sum, self.future)
            print("step5 time to finish: " + str(time() - start)+" on processor "+str(str(charm.myPe())))
示例#17
0
    def start(self):
        # print('Controller running on PE', charm.myPe())
        for i in range(charm.numPes()):
            assert i == charm.thisProxy[i].myPe(ret=True).get()

        pe = charm.myPe() - 1
        if pe == -1:
            pe = 0
        charm.thisProxy[pe].exec('global MY_GLOBAL; MY_GLOBAL = 7262',
                                 __name__,
                                 awaitable=True).get()
        assert charm.thisProxy[pe].eval('MY_GLOBAL', __name__,
                                        ret=True).get() == 7262

        Group(Test)
示例#18
0
 def start(self):
     if self.thisIndex == (0, ) and self.iteration % 20 == 0:
         print('Iteration ' + str(self.iteration))
     self.check()
     A = numpy.arange(1000, dtype='float64')
     work = 1000 * int(round(math.log(charm.myPe() + 1) +
                             1))  # elements in higher PEs do more work
     for i in range(work):
         A += 1.33
     self.iteration += 1
     if self.iteration == MAX_ITER:
         self.contribute(None, None, charm.thisProxy[0].exit)
     elif self.iteration % 20 == 0:
         self.AtSync()
     else:
         self.thisProxy[self.thisIndex].start()
示例#19
0
 def sayHi(self, hello_num):
     print('Hi[' + str(hello_num) + '] from element', self.thisIndex,
           'on PE', charm.myPe())
     lastIdx = tuple([size - 1 for size in self.array_dims])
     if self.thisIndex == lastIdx:
         # this is the last index, we are done
         print('All done')
         exit()
     else:
         # send a hello message to the next element (in row-major order)
         nextIndex = list(self.thisIndex)
         num_dims = len(self.array_dims)
         for i in range(num_dims - 1, -1, -1):
             nextIndex[i] = (nextIndex[i] + 1) % self.array_dims[i]
             if nextIndex[i] != 0:
                 break
         return self.thisProxy[nextIndex].sayHi(hello_num + 1)
示例#20
0
 def doReduction(self):
     print('Test element ' + str(self.thisIndex) + ' on PE ' + str(charm.myPe()) + ' is starting its contributions.')
     # test contributing single int back to Main
     self.contribute(42, Reducer.sum, mainProxy.done_int)
     # test contributing list of floats back to main
     num = [10.1, 13.4]
     self.contribute(num+[float(self.thisIndex[0])], Reducer.sum, mainProxy.done_float)
     # test nop reduction to main
     self.contribute(None, Reducer.nop, mainProxy.done_nop)
     # test contributing to Test[0]
     self.contribute(4.2, Reducer.sum, self.thisProxy[0].reductionTarget)
     # test contributing to Test (broadcast)
     self.contribute(numpy.array([4.2, 8.4]), Reducer.sum, self.thisProxy.reductionTargetBcast)
     # test contributing to TestGroup[0]
     self.contribute(4, Reducer.sum, groupProxy[0].reduceFromArray)
     # test contributing to TestGroup (broadcast)
     self.contribute(array.array('i', [0, 8, 3]), Reducer.sum, groupProxy.reduceFromArrayBcast)
示例#21
0
    def start(self):
        assert charm.myPe() == 1

        N = charm.numPes() * 3
        a1 = charm.thisProxy[0].createArray(Test, N, ret=True).get()
        f = Future()
        a1.work(f, 5)
        assert f.get() == N * 5

        N = 25
        a2 = charm.thisProxy[0].createArray(Test, (5, 5), args=[33],
                                            ret=True).get()
        f = Future()
        a2.work(f, 6)
        assert f.get() == N * (6 + 33)

        exit()
示例#22
0
 def doReduction(self):
     print('TestGroup element on PE ' + str(charm.myPe()) +
           ' is starting its contributions.')
     # test contributing single int back to Main
     self.contribute(42, Reducer.sum, mainProxy.done_int)
     # test contributing list of floats back to Main
     num = [10.1, 13.4]
     self.contribute(num + [float(self.thisIndex)], Reducer.sum,
                     mainProxy.done_float)
     # test nop reduction to main
     self.contribute(None, Reducer.nop, mainProxy.done_nop)
     # test contributing to TestArray[0]
     self.contribute([4.2, 13.1], Reducer.sum,
                     arrayProxy[0].reduceGroupToArray)
     # test contributing to TestArray (broadcast)
     self.contribute(-4, Reducer.sum, arrayProxy.reduceGroupToArrayBcast)
     # test contributing to TestGroup[0]
     self.contribute([5, 7, -3, 0], Reducer.sum,
                     self.thisProxy[0].reduceGroupToGroup)
     # test contributing to TestGroup (broadcast)
     self.contribute(-4.2, Reducer.sum,
                     self.thisProxy.reduceGroupToGroupBcast)
示例#23
0
 def __init__(self):
     print('TestGroup ' + str(self.thisIndex) + ' created on PE ' +
           str(charm.myPe()))
示例#24
0
文件: start.py 项目: sdrave/charm4py
def main(args):
    print('Charm program started on processor', charm.myPe())
    print('Running on', charm.numPes(), 'processors')
    exit()
示例#25
0
 def SayHi(self):
     if charm.myPe() < 10:
         print('Hello from PE', charm.myPe(), 'on', time.strftime('%c'))
     # call SayGoodbye method of the goodbye chare on my PE, bye_chares is
     # a global variable of this module, set previously from the mainchare
     bye_chares[charm.myPe()].SayGoodbye()
示例#26
0
 def work2(self, cb):
     self.contribute(charm.myPe(), Reducer.sum, cb)
示例#27
0
 def check1(self):
     assert charm.myPe() == 3
     return 68425
示例#28
0
 def resumeFromSync(self):
     assert self.migratable == (self.thisIndex[0] % 2 != 0)
     if not self.migratable:
         assert charm.myPe() == self.originalPe
     assert self.hasMigrated == (self.prevPe != charm.myPe())
     self.thisProxy[self.thisIndex].start()
示例#29
0
 def __init__(self):
     print('Hello from MyChare instance in processor', charm.myPe())
示例#30
0
 def __init__(self):
     self.iteration = 0
     self.originalPe = charm.myPe()
     if self.thisIndex[0] % 2 == 0:
         self.setMigratable(False)