sg0 / rmacxx

C++ interface over MPI-3 RMA
0 stars 0 forks source link

Unexpected behavior when performing operations involving multiple window reads #12

Open MMukundi opened 2 years ago

MMukundi commented 2 years ago

Reproduction:

int main() {
    // -- SNIP --
    win.fill(1);
    std::vector<int> result(25);

    // Problem here:
    4*win(1,{0,0},{4,4})*win(1,{0,0},{4,4}) >> result.data();

    win.flush();
    // -- SNIP --
}

Expected behavior:

result[0] == 4

Observed behavior:

result[0] == 64

Temporary solution:

    // Quick fix; add parenthesis around the window operations
    4*(win(1,{0,0},{4,4})*win(1,{0,0},{4,4}))>> result.data();
sg0 commented 2 years ago

Good catch, I think this is a bug.

sg0 commented 2 years ago

Does 4*win(1,{0,0},{4,4})>> result.data(); evaluate correctly?

MMukundi commented 2 years ago

Oddly, 4*win(1,{0,0},{4,4})>> result.data(); correctly evaluates to 4

sg0 commented 2 years ago

And what does win(1,{0,0},{4,4}) >> result.data() return after 4*win(1,{0,0},{4,4})>> result.data();? I'm trying to determine if temporaries are stored in the buffer underlying a window itself.

MMukundi commented 2 years ago

4*win(1,{0,0},{4,4}) = 4 win(1,{0,0},{4,4}) = 1 This is true whether or not there is a synchronization call between the two operations

sg0 commented 2 years ago

In shared memory, data can be loaded on another process's memory without relying on synch, especially if data size is small. This is something we must poke into, as in assessing this issue.