clangupc / upc2c

Clang based UPC to C Translator
https://clangupc.github.io/clang-upc2c
Other
4 stars 3 forks source link

round-trip pshared->shared->pshared #85

Closed PHHargrove closed 10 years ago

PHHargrove commented 10 years ago

Based on the generic nature of shared void * it is possible for a programmer to write something like p = (shared void *)q where p and q are both phase-less (cyclic or indefinite) pointers. This occurs, for instance, benchmarks/stream.c of the test suite.

For this case the resulting code is p = upcr_shared_to_pshared(upcr_pshared_to_shared(q)), while p = q would be sufficient.

I am going to look quickly at folding this and possibly the shared->pshared->shared conversion (which must become a call to upcr_shared_resetphase) if I can determine if/how this case would occur in practice.

PHHargrove commented 10 years ago

I have determined that with "extra" casts it is possible to generate the following 4 cases: 1) upcr_shared_to_pshared(upcr_pshared_to_shared(p)) vs. p 2) upcr_shared_to_pshared(upcr_shared_resetphase(p)) vs. upcr_shared_to_pshared(p) 3) upcr_pshared_to_shared(upcr_shared_to_pshared(p)) vs. upcr_shared_resetphase(p) 4) upcr_shared_resetphase(upcr_shared_resetphase(p)) vs. upcr_shared_resetphase(p)

One can generate these four cases (in order) with the four assignments below:

shared [0] int *a;
shared [1] int *b;
shared [2] int *c;
shared [3] int *d;
void foo(void) {
        a = (shared void *)b;
        b = (shared [1] int *)(shared [4] int *)d;
        c = (shared [2] int *)(shared [1] int *)d;
        c = (shared [2] int *)(shared [4] int *)d;
}

I have code to fold the 4 combinations listed above and am testing now...

PHHargrove commented 10 years ago

Code at https://github.com/Intrepid/upc2c/compare/issue-85 has passed my testing. I would appreciate a review before merging to master.

swatanabe commented 10 years ago

AMDG

On 03/19/2014 09:51 PM, Paul H. Hargrove wrote:

Code at https://github.com/Intrepid/upc2c/compare/issue-85 has passed my testing. I would appreciate a review before merging to master.

I don't see any problems. Please go ahead.

In Christ, Steven Watanabe