Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question about use of self-rpc #2

Open
bonachea opened this issue Aug 21, 2023 · 0 comments
Open

Question about use of self-rpc #2

bonachea opened this issue Aug 21, 2023 · 0 comments

Comments

@bonachea
Copy link

Hi - I was just looking through your code to learn about how it uses UPC++.

I noticed a strange idiom in a number places of sending loopback RPCs, here's one example in gossip.h:

// declaration:
        upcxx::dist_object<std::vector<VertexId>> visited{ {} };
        auto getVisitedSize = [](upcxx::dist_object<std::vector<VertexId>>& visited) {
            return upcxx::rpc(upcxx::rank_me(), [](upcxx::dist_object<std::vector<VertexId>>& visited) {
                return visited->size();
                }, visited).wait();
        };

// call-site:
        while (getVisitedSize(visited) != localStorage.size()-1) {
             ...

I'd like to understand why this code sends an RPC to rank_me(), rather than simply accessing the object. This is a valid use, but a puzzling one. For example, I believe the code above could be rewritten more simply as:

// declaration:
        upcxx::dist_object<std::vector<VertexId>> visited{ {} };
        auto getVisitedSize = [](upcxx::dist_object<std::vector<VertexId>>& visited) {
            return visited->size();
        };

// call-site:
        while (getVisitedSize(visited) != localStorage.size()-1) {
             ...

or even more simply as:

// declaration:
        upcxx::dist_object<std::vector<VertexId>> visited{ {} };

// call-site:
        while (visited->size() != localStorage.size()-1) {

either of which I believe are equivalent for all the use cases here (ie. in the absence of multithreading within a process racing on the data structure, or inactive dist_object). Either of my replacement versions should also be slightly more efficient, because it doesn't needlessly invoke the RPC logic to enqueue the trivial operation and response via loopback.

Is there some subtle rationale for this idiom that I'm not seeing?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant