Functions on class-agnostic arrays
Status: Beta
Brought to you by:
canonizer
Provide support for "class-agnostic" arrays (and possibly pointers) in NUDA functions on device. A function on class-agnostic array is a function operating on an array which can use single code to work with both local, global and private arrays. E.g.
...
public nucode sum(a : array[float]) : float {
mutable res = 0.0f;
nfor(i in a.Length) {
res += a[i];
}
res;
}
// may be further called as
def a = nunew array(n) : array[float];
...
nuwork(64) nfor(i in n) {
def la = nulocal array(64) : array[float];
def pa = nupriv array(64) : array[float];
...
def totalSum = sum(a) + sum(la) + sum(pa);
...
}
It would also be interesting to move from hardwiring memory class into type to a more flexible approach of storing array's memory class as an attribute. As OpenCL does not support classless pointers, however, using functions on arrays would require either code duplication or on-demand generation of versions of function with specific memory classes.
In order to avoid at least some of duplication, mechanism of #define macros can be used.