MathGroup Archive 2008

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Do -like iteration construct with parallel steps?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg84929] Re: Do -like iteration construct with parallel steps?
  • From: Jens-Peer Kuska <kuska at informatik.uni-leipzig.de>
  • Date: Sun, 20 Jan 2008 03:33:18 -0500 (EST)
  • References: <fmq0fo$ass$1@smc.vnet.net>

Hi,
what mean "it steps all the variables in parallel"
Your computer is essential a von Neuman machine and will
work sequential.
A sample implementation of a Do[] is ..

SetAttributes[DoLoop, HoldAll]

DoLoop[body_, {iter_Symbol, from_Integer, to_Integer}] :=
  Module[{cnt = from},
   While[True,
    ReleaseHold[Hold[body] /. iter -> cnt++];
    If[cnt > to, Break[]]
    ];
   Null
   ]

or do you mean

SetAttributes[ParallelLoop, HoldAll]

ParallelLoop[body_, {iter_Symbol, from_Integer, to_Integer}] :=
  Module[{cnt},
   ReleaseHold[Hold[body] /. iter -> #] & /@
    Table[cnt, {cnt, from, to}];
   Null
   ]

but this is *not* really, parallel because the function
ReleaseHold[Hold[body] /. iter -> #] &
run sequential over the table of values

But you may buy the Parallel Computing Toolkit that
has commands for parallel execution but you need more
than a two Mathematica Kernels

Regards
   Jens




Louis Theran wrote:
> Is there an iteration construct similar to Do, except that it steps
> all the variables in parallel (as opposed to the ``nested'' way Do
> does it)?  I didn't see anything in the standard library, and I
> couldn't figure out how to make one myself, so I figured I'd ask if
> anybody has written this.  (Even a sample implementation of Do as it
> is would be helpful.)
> 
> Thanks.
> 
> ^L
> 
> 


  • Prev by Date: Re: Wavelet "filter"?
  • Next by Date: Re: Mathematica commenting of code using (* *) can't be nested
  • Previous by thread: Re: Do -like iteration construct with parallel steps?
  • Next by thread: [M6] Aligning graphics on frame boundaries