Share
Syntax
share[name]
Semantics
This type allows the programmer to have two variables sharing the same memory (the variable that the share type is applied to uses the memory of that specified as arguments to the type.) This is very useful in HPC applications as often processes are running at the limit of their resources. The type will share memory with that of the variable name in the above syntax. In order to keep this type safe, the sharee must be smaller than or of equal size to the memory chunk, this is error checked.
Example
function void main() { var a:Int::allocated[multiple[]]; var c:Int::allocated[multiple[] :: share[a]]; var e:array[Int,10]::allocated[single[on[1]]]; var u:array[Char,12]::allocated[single[on[1]] :: share[e]]; };
In the example above, the variables a and c will share the same memory. The variables e and u will also share the same memory. There is some potential concern that this might result in an error - as the size of u array is 12, and size of e array is only 10. If the two arrays have different types then this size will be checked dynamically - as an int is 32 bit and a char only 8 then this sharing of data would work in this case.
Since: Version 0.41b