On Sat, 2007-09-08 at 15:04 +1000, skaller wrote:
> On Sat, 2007-09-08 at 12:59 +1000, skaller wrote:
> []
> 
> Parallel assignment is now implement for the case that 
> looks like this:
> 
>       a,b,c = e1, e2, e3
[]
> But the contra case SHOULD be optimised:
> 
>       x = a,b,c
> 
> should be expanded to
> 
>       x.(0) = a;
>       x.(1) = b;
>       x.(2) = c;
> 
> if possible, because it saves constructing a temporary
> tuple on the RHS then assigning it (two writes and a temporary
> instead of one write).

This is now done too, but is not fully effective. For example
in the nbody code, this line:

         var d = bi.pos - bj.pos;

is optimised to:

      d.data[0] = (*bi).pos.data[0] - (*bj).pos.data[0] ;
      d.data[1] = (*bi).pos.data[1] - (*bj).pos.data[1] ;
      d.data[2] = (*bi).pos.data[2] - (*bj).pos.data[2] ;

however, this line:

         delta = delta + d * (bj.mass * mag);

is not optimised at all, because 'delta' appears in the RHS.
We really wanted to check delta.(0), delta.(1) and delta.(2).
Then we would find the RHS of delta.(0) does not involve delta
as a whole, nor delta.(1) or delta.(2), only delta.(0), etc,
and so a parallel assignment is safe.


-- 
John Skaller <skaller at users dot sf dot net>
Felix, successor to C++: http://felix.sf.net

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Felix-language mailing list
Felix-language@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/felix-language

Reply via email to