Hi,
It seems that something happens in the compiler, and it is caused
by a collision between your SumReducer and x10.lang.Reducible.SumReducer
[T].
The following is reduced code to reproduce the symptom:
public class A {
def m() {
val a = finish(SumReducer()) {
offer 1.0;
};
}
static struct SumReducer implements Reducible[Double] {
public def zero() = 0.0;
public operator this(a:Double, b:Double) = (a + b);
}
}
As a workaround, please try utilizing x10.lang.Reducible.SumReducer[T] (or
renaming your struct) as the following:
public class A {
def m() {
val a = finish(Reducible.SumReducer[Double]()) {
offer 1.0;
};
}
//static struct SumReducer implements Reducible[Double] {
// public def zero() = 0.0;
// public operator this(a:Double, b:Double) = (a + b);
//}
}
Regards,
Yuki MAKINO
From: Konstantina Panagiotopoulou <[email protected]>
To: Mailing list for users of the X10 programming language
<[email protected]>
Date: 2013/07/01 20:47
Subject: Re: [X10-users] Performance tuning for the N Body problem
So this is the code...I have ommitted some parts to make it more clear...
the error I get is the following
x10c: ----------
1. ERROR in /home/kwnouli/Desktop/x10/uniComm.java (at line 421)
SumReducer $_obj = new SumReducer((java.lang.System[]) null);
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
The constructor Reducible.SumReducer(System[]) is undefined
----------
2. ERROR in /home/kwnouli/Desktop/x10/uniComm.java (at line 423)
return $_deserialize_body($_obj, $deserializer);
^^^^^^^^^^^^^^^^^^
The method $_deserialize_body(uniComm.SumReducer, X10JavaDeserializer)
in the type uniComm.SumReducer is not applicable for the arguments
(Reducible.SumReducer, X10JavaDeserializer)
----------
2 problems (2 errors)
x10c: Non-zero return code: 255
2 errors.
And I cannot understand why it tries to deserialize the body object since I
only need the e: Double value...
Am I missing something?
Thanks again Josh
Regards,
Konstantina
2013/7/1 Konstantina Panagiotopoulou <[email protected]>
Hey Josh,
I used the code you provided above.
public def Advance(dt:double) {
val directEnergy = finish(SumReducer()) {
finish ateach(pl in bodies) {
var e:Double = 0.0;
val myBodies : Rail[Body] =bodies(pl);
val toSent = new Rail[Body](myBodies.size as Int,
(i:Int)=>new Body(myBodies(i).mass,myBodies(i).posx, myBodies(i).posy,
myBodies(i).posz, myBodies(i).velx, myBodies(i).vely, myBodies(i).velz));
val nextPlace = here.next();
if (nextPlace != here) {
@Uncounted at(nextPlace) async {
atomic {
otherBodies(nextPlace.id)(pl) = toSent;
}
}
}
for (i in 0..(myBodies.size-1)) {
val bodyI = myBodies(i);
e+= 0.5 * bodyI.mass * (bodyI.velx*bodyI.velx + bodyI.vely*bodyI.vely +
bodyI.velz*bodyI.velz);
for (j in 0..(i-1)) {
val bodyJ = myBodies(j);
//code to update my bodies' velocity ...
val dx: double = bodyI.posx - bodyJ.posx;
val dy: double = bodyI.posy - bodyJ.posy;
val dz: double = bodyI.posz - bodyJ.posz;
var d2: double = dx*dx + dy*dy + dz*dz;
e-= (bodyI.mass*bodyJ.mass) / Math.sqrt(d2);
}
}
offer e;
}
var target : Place = nextPlace.next();
var source : Place = here.prev();
while (source != here) {
if (target != here) {
// send myBodies (toSent) to the next target
place
val targetPlace = target;
@Uncounted at(targetPlace) async {
atomic {
otherBodies(targetPlace.id)(pl) =
toSent;
}
}
}
when(otherBodies(here.id)(source.id) != null);
//all interactions with otherBodies at other place
val other = otherBodies(here.id)(source.id);
for (j in 0..(other.size-1)) {
val bodyJ= other(j);
for (i in 0..(myBodies.size-1)) {
val bodyI = myBodies(i);
e+= 0.5 * bodyI.mass * (bodyI.velx*bodyI.velx + bodyI.vely*bodyI.vely +
bodyI.velz*bodyI.velz);
val dx: double = bodyI.posx - bodyJ.posx;
val dy: double = bodyI.posy - bodyJ.posx;
val dz: double = bodyI.posz - bodyJ.posx;
var d2: double = dx*dx + dy*dy + dz*dz;
//computation to update my bodies' velocity
e-= (bodyI.mass*bodyJ.mass) / Math.sqrt(d2);
}
offer e;
}
target = target.next();
source = source.prev();
}
}
};
return directEnergy;
}
static struct SumReducer implements Reducible[Double] {
public def zero() = 0.0;
public operator this(a:Double, b:Double) = (a + b);
}
2013/7/1 Josh Milthorpe <[email protected]>
Hi Konstantina,
a more general version of collecting finish / offers is proposed, called
'accumulator variables', but this is not yet fully implemented.
Collecting finish should work fine in X10 2.3.
The Reducible interface is in x10.lang. It includes a generic
SumReducer struct type that you could use instead of the Double-specific
one I posted.
Can you post the code that is causing the error, along with the compile
error that you receive?
Cheers,
Josh
------------------------------------------
Josh Milthorpe
Postdoctoral Fellow, Research School of Computer Science
Australian National University, Building 108
Canberra, ACT 0200
Australia
Phone: + 61 (0)2 61254478
Mobile: + 61 (0)407 940743
E-mail: [email protected]
Web: http://cs.anu.edu.au/~Josh.Milthorpe/
On 29/06/13 01:31, Konstantina Panagiotopoulou wrote:
Hello again,
I tried to restructure my code according to the example..
The problem is that I get errors with the SumReducer struct (the
errors point to the java generated code, and can't really make
sense)
I checked the specification for v2.3. and found this:
offers. The offers concept was experimental in 2.1, but was
determined inadequate. It has not been removed from the compiler
yet, but it will be soon. In
the meantime, traces of it are still visible in the grammar. They
should not be
used and can safely be ignored
Also I cannot track the Reducible interface in the API.
Is there any other more explicit way to reduce values from
different places?
Thanks again,
Konstantina
2013/6/27 Konstantina Panagiotopoulou <[email protected]>
Hello again,
I tried to restructure my code according to the example..
The problem is that I get errors with the SumReducer struct
(the errors point to the java generated code, and can't really
make sense)
I checked the specification for v2.3. and found this:
offers. The offers concept was experimental in 2.1, but was
determined inadequate. It has not been removed from the compiler
yet, but it will be soon. In
the meantime, traces of it are still visible in the grammar.
They should not be
used and can safely be ignored
Also I cannot track the Reducible interface in the API.
Is there any other more explicit way to reduce values from
different places?
Thanks again,
Konstantina
2013/6/22 Vijay Saraswat <[email protected]>
On 6/21/13 9:21 PM, Konstantina Panagiotopoulou wrote:
Thanks a lot for the useful feedback.
Although, I did not expect I would need such low level
tuning. Looks a lot like MPI.
X10 is a procedural programming language for distributed
programming where the notions of concurrency and distribution
are made explicit.
It is closer to MPI than, say, a more limited, declarative
language with implicit concurrency, in which the compiler
determines run-time concurrency and distribution (e.g. ZPL).
We are very interested in such (declarative) languages as well,
and building them on top of X10, in the long term.
------------------------------------------------------------------------------
This SF.net email is sponsored by Windows:
Build for Windows Store.
http://p.sf.net/sfu/windows-dev2dev
_______________________________________________
X10-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/x10-users
------------------------------------------------------------------------------
This SF.net email is sponsored by Windows:
Build for Windows Store.
http://p.sf.net/sfu/windows-dev2dev
_______________________________________________
X10-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/x10-users
------------------------------------------------------------------------------
This SF.net email is sponsored by Windows:
Build for Windows Store.
http://p.sf.net/sfu/windows-dev2dev
_______________________________________________
X10-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/x10-users
------------------------------------------------------------------------------
This SF.net email is sponsored by Windows:
Build for Windows Store.
http://p.sf.net/sfu/windows-dev2dev
_______________________________________________
X10-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/x10-users