Maybe you do the reduce in a static context (so the error is that you refer
to instance method in a static context) ?

Can you try both:
v = v_dst.reduce(ArrayD_add, v);
and
v = v_dst.reduce(*this.*ArrayD_add, v);

If both don't work, email the full code and I'll look into it.


On Wed, Jun 2, 2010 at 9:05 AM, Christoph Pospiech <
christoph.pospi...@de.ibm.com> wrote:

> On Tuesday 01 June 2010 07:53:07 pm Dr. Christoph Pospiech wrote:
> > > On Tuesday 01 June 2010 02:06:08 pm Yoav Zibin wrote:
> > > > self.home==here
> > > > This means u need to use ! After the type.
> > > >
> > >
> > >
> > > Following the recent posts, I tried the following.
> > >
> > >         global def ArrayD_add(s1:Array[double]!,
> > >                         s2:Array[double]!)
> > >         {s1.region() == s2.region()}: Array[double] {
> > >                 s1.lift(s1, s2, Double.+);
> > >                 return(s1);
> > >         }
> > >
> > > This seems to compile OK.
> > >
> > > BTW, while leaving the typedef in the code (and using it elsewhere) I
> had
> > >  to  remove it from the function definition, as it seem to blow up my
> > >  workspace (compile ran out of memory).
> > >
> >
> > Originally, I want to do the following.
> >
> >         // Finally, we set up a distribution
> >         // with one point per place
> >         val Dv_tmp:Dist = Dist.makeUnique(D.places());
> >
> >         val v_dst : DistArray[Array[Double]] =
> >  DistArray.make[Array[double]](Dv_tmp); finish ateach(pt in Dv_tmp ) {
> >                 v_dst(pt) = new Array[double](n,
> >                                 (q:Point) => {(0.0) as double});
> >         }
> >
> >         // Of course the values for v_dst(pt)(q) change later
> >         // but they stay at the same Place.
> >         // Basically one Array[double] at each place.
> >
> >         val v : Array[double] = v_dst.reduce(??, unit);
> >
> > The ArrayD_add function was supposed to go into the location marked with
> >  ??.  But now I am stating that both arguments have home == here, which
> is
> >  definitely not the case for v_dst(pt), pt in Dv_tmp.
> >
> > I guess I need to add some communication by hand, say along the lines of
> > something like Array[double].raw().copyFrom() ? Suggestions welcome !
> >
>
> Hi,
>
> I have now implemented the functions as follows.
>
> [...]
>        static type ArrayD = Array[Double]{rank==1};
> [...]
>                 // Finally, we set up a distribution
>                // with one point per place
>                val Dv_tmp:Dist = Dist.makeUnique(D.places());
>
>                 v_dst  = DistArray.make[ArrayD](Dv_tmp);
>                 finish ateach(pt in Dv_tmp ) {
>                         v_dst(pt) = new Array[Double](n,
>                                (q:Point) => {(0.0) as Double});
>                }
> [...]
>
>    /**
>     *  Lift the copyFrom function from Rails to special Arrays
>     */
>    public def ArrayD_cp(s1:Array[Double])
>    {s1.rail()}: Array[Double]! {
>        if (s1.home() == here) {
>                return(s1 as Array[Double]!);
>        } else {
>                val n:Int = s1.raw().length();
>                val p:Place = s1.home();
>                val R:Rail[Double] = at(p) s1.raw();
>                val s2:Array[Double] = new Array[Double](n);
>                s2.raw().copyFrom(0,R,0,n);
>                return(s2 as Array[Double]!);
>        }
>    }
>
>    /**
>     *  Function for Adding two arrays of the special ArrayD form
>     */
>    public def ArrayD_add(s1:Array[Double],
>                        s2:Array[Double])
>        {s1.region() == s2.region(), s1.rail(), s2.rail()}: Array[Double] {
>                val s1_loc:Array[Double]! = ArrayD_cp(s1);
>                val s2_loc:Array[Double]! = ArrayD_cp(s2);
>                s1_loc.lift(s1_loc, s2_loc, Double.+);
>                return(s1_loc);
>        }
> [...]
>
>                /**
>                 * Initialize v to zero and use it as
>                 * neutral element in the reduce
>                 */
>                 for ( r in v.region() ) {
>                         v(r) = 0.0;
>                 }
>                v = v_dst.reduce(ArrayD_add, v);
>
> All except for the last line compile OK, but the compiler complains the
> following about the last line.
>
> Could not find field or local variable "ArrayD_add".
>
> v_dst.reduce expects a function as first variable, correct ? Why is it
> looking
> for a field ? And why doesn't it find
> public def ArrayD_add(s1:Array[Double],s2:Array[Double])
>        {s1.region() == s2.region(), s1.rail(), s2.rail()} => Array[Double]
> ?
>
> --
>
> Mit freundlichen Grüßen / Kind regards
>
> Dr. Christoph Pospiech
> High Performance & Parallel Computing
> Phone:  +49-351 86269826
> Mobile: +49-171-765 5871
> E-Mail: christoph.pospi...@de.ibm.com
> -------------------------------------
> IBM Deutschland GmbH
> Vorsitzender des Aufsichtsrats: Erich Clementi
> Geschäftsführung: Martin Jetter (Vorsitzender),
> Reinhard Reschke, Christoph Grandpierre,
> Klaus Lintelmann, Michael Diemer, Martina Koederitz
> Sitz der Gesellschaft: Ehningen / Registergericht: Amtsgericht Stuttgart,
> HRB
> 14562 WEEE-Reg.-Nr. DE 99369940
>
>
>
> ------------------------------------------------------------------------------
>
> _______________________________________________
> X10-users mailing list
> X10-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/x10-users
>
------------------------------------------------------------------------------

_______________________________________________
X10-users mailing list
X10-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/x10-users

Reply via email to