Skip to content

Question about use of self-rpc #2

@bonachea

Description

@bonachea

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions