charmplusplus / charm4py

Parallel Programming with Python and Charm++
https://charm4py.readthedocs.io
Apache License 2.0
289 stars 21 forks source link

WIP: Add 'expedited' decorator for urgent messages #212

Open ZwFink opened 2 years ago

ZwFink commented 2 years ago

This patch adds the @expedited decorator to enable urgent inter-PE messages to skip the message queue. This patch also lays the groundwork for adding additional entry method options such as priorities.

Example of usage:

from charm4py import charm, Chare, Array, expedited

class Test(Chare):
    """
    A chare array to test the element proxy.
    """

    def __init__(self):
        self.count = 0

    @expedited
    def say(self, msg):
        """
        Helper method which is called by invoking the element proxy.
        This method is expected to be called on only the chare for
        which the proxy is created.
        """

        self.count += 1
        print("Say", msg, "called on", self.thisIndex, "on PE", charm.myPe())
        if self.count == 2:
            assert self.thisIndex == (3,)
            exit()

    def start(self):
        proxy = self.thisProxy[3]
        proxy.say("bye")
        proxy.say("bye")

def main(args):
    arr_proxy = Array(Test, 6)
    arr_proxy[0].start()

charm.start(main)
lgtm-com[bot] commented 2 years ago

This pull request introduces 1 alert when merging d813e1d70ca9572aa0a6b1d8662b20ce09a9fc6c into 0b9a2bed73fa55f15af3511fe5e3fc2cffed29dc - view on LGTM.com

new alerts:

lgtm-com[bot] commented 2 years ago

This pull request introduces 1 alert when merging eae84977d56c8a6edf6a43c35491f2596b14a430 into 0b9a2bed73fa55f15af3511fe5e3fc2cffed29dc - view on LGTM.com

new alerts: