Skip to content

Instantly share code, notes, and snippets.

@bmyerz
Last active August 29, 2015 14:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bmyerz/4ac060c35f9dbd5f64fb to your computer and use it in GitHub Desktop.
Save bmyerz/4ac060c35f9dbd5f64fb to your computer and use it in GitHub Desktop.
code that is candidate for object flattening optimization
// pgas pseudocode, borrowing syntax from Chapel and UPC
struct global_ptr_string {
int len;
global const char* str;
global_ptr_string(...) { ... }
}
const global_ptr_string x(...);
on(10) {
for (int i=0; x.str[i]!='\0'; i++) {
printchar (x.str[i])
}
print ("\n")
}
@bmyerz
Copy link
Author

bmyerz commented Apr 16, 2015

I don't want partition 10 to have to do a global dereference of x.str (whether it is multiple times or even one time). I would prefer that when the RPC is made, it flattens x by locally dereferencing str and shipping it together. This results in one message instead of greater than 1.

I believe this is similar to "scalar replacement" in Communication Optimizations for Distributed-Memory X10 Programs but a bit different. They are trying to ship one field instead of an object to reduce size of one message, I am trying to ship deep objects to replace roundtrip messages with one big message.

@bholt
Copy link

bholt commented Apr 16, 2015

What would concern me with this optimization is that you have to prove that nothing modifies x.str between when the on(10) starts and the printchar (currently) dereferences it.

@bmyerz
Copy link
Author

bmyerz commented Apr 16, 2015

ok updated with more const to make it easier.

anyway, shouldn't we be considering a SC for DRF model?

@bholt
Copy link

bholt commented Apr 16, 2015

making it const should do the trick (assuming you can trust const, unlike in C++). ;)

anyway, shouldn't we be considering a SC for DRF model?

sure, but you're proposing moving a load up, so you have to at least prove nothing in your on block modifies it between where you hoisted it.

@bholt
Copy link

bholt commented Apr 16, 2015

this is exactly the kind of thing I remember wishing Chapel would do for me. That or just make const things available everywhere so I didn't have to worry about where they lived.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment