Parla.py
Parla.py copied to clipboard
PArray coherence issue
When doing a reduce operation using PArrays, the data in follow-up operations is not consistent or None. The following example without a reduction works fine:
def main():
t = TaskSpace("tasks")
a = TaskSpace("acc")
n = 4
arr = asarray(np.zeros((n,256,256)))
for i in range(n):
@spawn(t[i], output=[arr[i]],placement=gpu)
def task_a():
arr[i] = 1
for i in range(n):
@spawn(t[n+i],dependencies=[t[:n]], input=[arr[i]],placement=gpu)
def task_b():
print(arr[i].mean())
if __name__ == "__main__":
with Parla():
main()
The outputs are 1.0, 1.0, 1.0, 1.0.
Adding a reduce operation leads to wrong values, often 0.5, 0.0, 0.0, 0.0
def main():
t = TaskSpace("tasks")
a = TaskSpace("acc")
n = 4
arr = asarray(np.zeros((n,256,256)))
for i in range(n):
@spawn(t[i], output=[arr[i]],placement=gpu)
def task_a():
arr[i] = 1
@spawn(a[0],dependencies=[t[:n]], input=[arr],placement=gpu)
def acc():
print(arr.mean())
for i in range(n):
@spawn(t[n+i],dependencies=[a[0]], input=[arr[i]],placement=gpu)
def task_b():
print(arr[i].mean())
if __name__ == "__main__":
with Parla():
main()
When the acc operation binds the parameter via inout
the values are sometimes None and yield runtime exceptions. This only happens on GPU, not on CPU.