Last active
August 29, 2015 14:19
-
-
Save bmyerz/4ac060c35f9dbd5f64fb to your computer and use it in GitHub Desktop.
code that is candidate for object flattening optimization
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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") | |
} |
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.
ok updated with more const to make it easier.
anyway, shouldn't we be considering a SC for DRF model?
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.
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
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 flattensx
by locally dereferencingstr
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.