This is to share a solution to bypass the verification of parallel usage of memory location across tasks.
Sometime you need to share data across task and don't want to use channel to share data.
one way is to write the function in C instead of XC.
but it is possible to make it in XC by creating an alternative symbol, being at the same address:
example:
Code: Select all
int array[2];
extern int array2[5];
void t1(int arr[]) {
arr[1] = 12345;
arr[0] = 1;
}
void t2(int arr[]) {
while (arr[0] == 0);
printf("arr[1]=%d\n", arr[1]);
}
int main(){
par {
on tile[0] : t1(array);
on tile[0] : { asm(".linkset array2, array"); t2(array2);}
}
still using variable across task requires some specific handling especially in -O3.
volatile statement doesn't exist as such in XC (only for unsafe pointers).
using the memory barrier instruction is helpful : asm("":::"memory"); to force the compiler to flush and reload variables.
it is possible to declare the "globals variable" in a C file and use a .h file declaring them external.
then the asm .linkset statements can all be put in a single C file.
for experimentation and feedbacks