...
Code Block |
---|
int a = 0; int x = 0; // 1 finish { async IN(a) OUT(x) { // compute something x = someValue; // 2 } // here 'x' has an undetermined value could // be either the value x from 1 or x from 2 } // here 'x' contains the value computed in the async |
Referencing Internal HC Values Without ROSE Generated HC Code
It's possible with certain function/macro calls to reference the HC worker state even though you aren't in a valid HC program. I ran into this in some HCMPI code compiled with hcc when trying to call
Code Block |
---|
HCMPI_Comm_rank
HCMPI_Comm_size |
which reference the fields comm_rank and comm_size in the HC worker state. However, I got segfaults because no HC worker state existed as hcc had not generated any of the necessary code using ROSE. I solved this by adding a dummy finish scope in the program, indicating to the compiler that this was indeed HC code. hcc then correctly produced the auto-generated code for initializing the HC state.
Calling HC Functions From non-HC Code
When calling an HC function from non-HC code in separate files, the hcc compiler will not be able to resolve the function definition. This is a result of the name-mangling that HC does, which is not reflected in the original header files. As a result, when the final ROSE generated C file is compiled with the original calling C/C++, the compiler won't resolve the originally named function to the new HC-mangled one. The way to fix this is by adding
Code Block |
---|
#pragma hc continuable |
above the function declaration in the header file. And tada! Fixed. Credit to Vincent for teaching me this.