Sorry !
My full msg is here:
Thank you MIkio, but still there is a problem.
I renamed it, and it compiles but only with : finish(mySumReducer())
(the Reducible.mySumReducer() gives the following error:
x10:95: No valid method call found for call in given type.
Call: mySumReducer()
Type: x10.lang.Reducible
.x10:95: The reducer must be of type Reducible[T], for some type T.
Reducer: x10.lang.Reducible.mySumReducer()
Reducer type: <unknown>
.x10:263: Cannot find enclosing collecting finish for offer statement.
Offer: offer energyThisPlace;
3 errors.
)
Now, the one that compiles gives a runtime exception:
java.lang.ClassCastException:
x10.lang.FinishState.CollectingFinish[x10.lang.Double]
at x10.rtt.Types.cast(Types.java:802)
at x10.lang.Runtime.makeOffer__0x10$lang$Runtime$$T(Runtime.java:3681)
at uniComm$$Closure$7.$apply(uniComm.java:2718)
at x10.lang.Activity.run(Activity.java:726)
at x10.lang.Runtime$Worker.loop$O(Runtime.java:1460)
at x10.lang.Runtime$Worker.$apply(Runtime.java:1407)
at x10.core.Thread$2.run(Thread.java:62)
java.lang.ClassCastException:
x10.lang.FinishState.CollectingFinish[x10.lang.Double]
at x10.rtt.Types.cast(Types.java:802)
at x10.lang.Runtime.makeOffer__0x10$lang$Runtime$$T(Runtime.java:3681)
at uniComm$$Closure$7.$apply(uniComm.java:2718)
at x10.lang.Activity.run(Activity.java:726)
at x10.lang.Runtime$Worker.loop$O(Runtime.java:1460)
at x10.lang.Runtime$Worker.$apply(Runtime.java:1407)
at x10.lang.Runtime$Pool.$apply(Runtime.java:1835)
at x10.lang.Runtime.start(Runtime.java:2265)
at x10.runtime.impl.java.Runtime.$apply(Runtime.java:159)
at x10.core.Thread$2.run(Thread.java:60)
Although, I can see that it calculates the energyThisPlace when I print
it.After the last place, the exception is thrown.
The code is still:
public def Advance(dt:double) {
val directEnergy = finish(mySumReducer()){
finish ateach(pl in bodies) {
.......
offer energyThisPlace;
}//ateach
};
return directEnergy;
}//advance
Regards,
Konstantina
2013/7/5 Konstantina Panagiotopoulou <kwno...@hotmail.com>
> Thank you MIkio, but still there is a problem.
> I renamed it, and it compiles but only with : finish(mySumReducer())
>
> (the Reducible.mySumReducer() gives the following error:
>
> x10:95: No valid method call found for call in given type.
> Call: mySumReducer()
> Type: x10.lang.Reducible
> .x10:95: The reducer must be of type Reducible[T], for some type T.
> Reducer: x10.lang.Reducible.mySumReducer()
> Reducer type: <unknown>
> .x10:263: Cannot find enclosing collecting finish for offer statement.
> Offer: offer energyThisPlace;
> 3 errors.
> )
>
> Now, the one that compiles gives a runtime exception:
>
> java.lang.ClassCastException:
> x10.lang.FinishState.CollectingFinish[x10.lang.Double]
> at x10.rtt.Types.cast(Types.java:802)
> at x10.lang.Runtime.makeOffer__0x10$lang$Runtime$$T(Runtime.java:3681)
> at uniComm$$Closure$7.$apply(uniComm.java:2718)
> at x10.lang.Activity.run(Activity.java:726)
> at x10.lang.Runtime$Worker.loop$O(Runtime.java:1460)
> at x10.lang.Runtime$Worker.$apply(Runtime.java:1407)
> at x10.core.Thread$2.run(Thread.java:62)
> java.lang.ClassCastException:
> x10.lang.FinishState.CollectingFinish[x10.lang.Double]
> at x10.rtt.Types.cast(Types.java:802)
> at x10.lang.Runtime.makeOffer__0x10$lang$Runtime$$T(Runtime.java:3681)
> at uniComm$$Closure$7.$apply(uniComm.java:2718)
> at x10.lang.Activity.run(Activity.java:726)
> at x10.lang.Runtime$Worker.loop$O(Runtime.java:1460)
> at x10.lang.Runtime$Worker.$apply(Runtime.java:1407)
> at x10.lang.Runtime$Pool.$apply(Runtime.java:1835)
> at x10.lang.Runtime.start(Runtime.java:2265)
> at x10.runtime.impl.java.Runtime.$apply(Runtime.java:159)
> at x10.core.Thread$2.run(Thread.java:60)
>
> Although, I can see that it calculates the energyThisPlace.
>
> The code is still:
>
> public def Advance(dt:double) {
>
>
>
>
> 2013/7/2 Mikio Takeuchi <mikio.takeu...@gmail.com>
>
>> Hi Konstantina,
>>
>> Because the reason of this problem is name clash, a simple solution is to
>> rename your SumReducer to some other name such as MySumReducer.
>> I confirmed it works.
>> Sorry for inconvenience.
>>
>> -- Mikio
>>
>>
>> 2013/7/2 Konstantina Panagiotopoulou <kwno...@hotmail.com>
>>
>>> Hello,
>>>
>>> I tried the workaround you suggested. Again, I 'm getting the same
>>> error... :(
>>>
>>> x10c: ----------
>>> 1. ERROR in /u1/msc/kp167/Desktop/x10/uniComm.java (at line 435)
>>> SumReducer $_obj = new SumReducer((java.lang.System[]) null);
>>> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>>> The constructor Reducible.SumReducer(System[]) is undefined
>>> ----------
>>> 2. ERROR in /u1/msc/kp167/Desktop/x10/uniComm.java (at line 437)
>>> 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.
>>>
>>> Regards,
>>> Konstantina
>>>
>>>
>>> 2013/7/2 Mikio Takeuchi <mikio.takeu...@gmail.com>
>>>
>>>> Hi,
>>>>
>>>> It was a problem of Java codegen that caused name clash between your
>>>> SumReducer with Reducible.SumReducer.
>>>> I fixed it in r25712 (trunk) and r25713 (2.3.1.2 branch).
>>>> As Yuki suggested, you can rename SumReducer or just use
>>>> Reducible.SumReducer as workaround.
>>>>
>>>> Thanks for reporting the problem.
>>>> -- Mikio
>>>>
>>>>
>>>> 2013/7/2 Yuki Makino <mak...@jp.ibm.com>
>>>>
>>>>> 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 <kwno...@hotmail.com>
>>>>> To: Mailing list for users of the X10 programming language
>>>>> <x10-users@lists.sourceforge.net>
>>>>> 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 <kwno...@hotmail.com>
>>>>> 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 <josh.miltho...@anu.edu.au>
>>>>> 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: josh.miltho...@anu.edu.au
>>>>> 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 <kwno...@hotmail.com>
>>>>> 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 <vi...@saraswat.org>
>>>>> 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
>>>>> X10-users@lists.sourceforge.net
>>>>> 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
>>>>> X10-users@lists.sourceforge.net
>>>>> 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
>>>>> X10-users@lists.sourceforge.net
>>>>> 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
>>>>> X10-users@lists.sourceforge.net
>>>>> 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
>>>> X10-users@lists.sourceforge.net
>>>> 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
>>> X10-users@lists.sourceforge.net
>>> 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
>> X10-users@lists.sourceforge.net
>> 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
X10-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/x10-users