Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Critical
-
Resolution: Fixed
-
Affects Version/s: X10 2.1.2
-
Fix Version/s: X10 2.1.2
-
Component/s: XRX Runtime
-
Labels:None
-
Number of attachments :
Description
The following program uses an at-expression to copy the array v to a new array w.
It modifies v, and prints elements of w. However, both C++ and Java back ends seem to
get the original array as w, not a copy, when there is one place.
public class CopyBackFromAtExp { public static def spawnAndReturn() { val v = [1]; async { for([i] in 1 .. 20) { v(0) = i; Console.OUT.println("v(0) = " + i); } } return v; } public static def main(argv:Array[String](1)) { val w = at(here.next()) spawnAndReturn(); for([j] in 1 .. 20) { Console.OUT.println("w(0) = " + w(0)); } } }
C++ output
~/x10/prog-guide/x10.samples/guide/heart-of-concurrency: x10c++ CopyBackFromAtExp.x10
~/x10/prog-guide/x10.samples/guide/heart-of-concurrency: mpirun a.out
w(0) = 1
v(0) = 1
w(0) = 1
v(0) = 2
w(0) = 2
v(0) = 3
w(0) = 3
v(0) = 4
w(0) = 4
v(0) = 5
w(0) = 5
v(0) = 6
w(0) = 6
v(0) = 7
v(0) = 8
w(0) = 7
v(0) = 9
v(0) = 10
w(0) = 9
v(0) = 11
v(0) = 12
w(0) = 11
v(0) = 13
w(0) = 13
v(0) = 14
w(0) = 14
v(0) = 15
w(0) = 15
v(0) = 16
w(0) = 16
v(0) = 17
w(0) = 17
v(0) = 18
w(0) = 18
v(0) = 19
w(0) = 19
v(0) = 20
w(0) = 20
w(0) = 20
w(0) = 20
Java output:
: x10 CopyBackFromAtExp
v(0) = 1
v(0) = 2
v(0) = 3
v(0) = 4
v(0) = 5
v(0) = 6
v(0) = 7
v(0) = 8
v(0) = 9
v(0) = 10
v(0) = 11
v(0) = 12
v(0) = 13
v(0) = 14
v(0) = 15
v(0) = 16
v(0) = 17
v(0) = 18
v(0) = 19
v(0) = 20
w(0) = 1
w(0) = 20
w(0) = 20
w(0) = 20
w(0) = 20
w(0) = 20
w(0) = 20
w(0) = 20
w(0) = 20
w(0) = 20
w(0) = 20
w(0) = 20
w(0) = 20
w(0) = 20
w(0) = 20
w(0) = 20
w(0) = 20
w(0) = 20
w(0) = 20
w(0) = 20
~/x10/prog-guide/x10.samples/guide/heart-of-concurrency:
The problem is easier to see if we force interleaving: