> Consider an expression like
>    +/?100$0
> on a a dual-core machine.  Sure, you could parcel out 50 additions to each
> core, then add the results but consider how the massive overhead of moving
> the data and starting up another core would completely swamp the tiny
> amount
> of processing required by 50 additions. 
> 
That's an interesting example that can get almost arbitrarily complicated.

An implicit assumption in such parallelization of +/ is that + is
associative.
This, strictly speaking, is true neither for floating point numbers nor
for machine integers.  Furthermore, for extended precision integers 
associativity holds but it might still be desirable to be able to control
the order of execution to make time and/or space smaller.

Here is one curious example with three numbers: 
-------------------------------------------------------------------------
$ uname -srvmo # AMD Turion 64
CYGWIN_NT-5.1 1.5.24(0.156/4/2) 2007-01-31 10:57 i686 Cygwin

$ /cygdrive/c/j602/bin/jconsole.exe
   9!:14''
j602/beta/2007-09-19/23:00
   a=:0.1 _10.1 10
   +/a
3.60822e_16
   +/|.a
0
   0.1+(_10.1+10)
3.60822e_16
   (0.1+_10.1)+10
0
-------------------------------------------------------------------------
This shows that the associativity does not hold.

Now comes the curious part:
-------------------------------------------------------------------------
$ uname -srvmo # Pentium 4
Linux 2.6.18-5-686 #1 SMP Fri Jun 1 00:47:00 UTC 2007 i686 GNU/Linux
$ ~/j602/bin/jconsole
   9!:14''
j602/beta/2007-09-19/23:00
   a=:0.1 _10.1 10
   +/a
3.60822e_16
   +/|.a
3.60822e_16
   0.1+(_10.1+10)
3.60822e_16
   (0.1+_10.1)+10
0
-------------------------------------------------------------------------

This could mean that the evaluation of +/ is nondeterministic:
one and the same +/|.a gives me two different numbers on two different 
computers for the same 9!:14''

That's without any parallelization. Now, when one spreads
+/ across processors (especially for a large number of numbers),
one expects that the manner in which parallelization is done will 
affect the result of evaluation.  Not too big of a deal provided that 
implementation (or even language) specifies the order of execution or 
the scheme of deterministic parallelization.

-- 
View this message in context: 
http://www.nabble.com/Aiming-at-a-multi-core-future-tp14383671s24193p14430423.html
Sent from the J Programming mailing list archive at Nabble.com.

----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to