|
[Date Index]
[Thread Index]
[Author Index]
Re: Any idea how to parallelize this small code construct
- To: mathgroup at smc.vnet.net
- Subject: [mg110892] Re: Any idea how to parallelize this small code construct
- From: "Jon Harrop" <usenet at ffconsultancy.com>
- Date: Sat, 10 Jul 2010 04:01:36 -0400 (EDT)
- References: <i13tso$7j1$1@smc.vnet.net>
"pratip" <pratip.chakraborty at gmail.com> wrote in message
news:i13tso$7j1$1 at smc.vnet.net...
> Dear Group,
>
> Here is a simple code to solve linear systems. It is motivated from
> Fullerton University numerics example. Now if someone can suggest how
> to parallelize this code.
>
> SORmethod[A0_, B0_, P0_, omega_, max_] :=
> Module[{A = N[A0], B = N[B0], i, j, k = 0, n = Length[P0], P = P0,
> oldP = P0},
> While[ k < max,
> Do[P[[i]] = (1 - omega) oldP[[i]] +
> omega/A[[i,
> i]] (B[[i]] - Sum[A[[i, j]] P[[j]], {j, 1, i - 1}] -
> Sum[A[[i, j]] oldP[[j]], {j, 1 + i, n}]) , {i, 1, n}];
> oldP = P;
> k = k + 1; ];
> Return[P] ]
Frigo et al. described a cache oblivious divide-and-conquer algorithm that
parallelizes such functions effectively but you'll need modern
infrastructure for load-balanced parallelism on multicores.
I don't really see the point of parallelizing that in Mathematica. The
serial implementation might be useful as an educational exercise but it will
be orders of magnitude slower than necessary and Mathematica cannot express
an efficient parallel solution.
Cheers,
Jon.
Prev by Date:
Re: replacement x->y except in Exp[x]
Next by Date:
Re: image is not graphics
Previous by thread:
Any idea how to parallelize this small code construct
Next by thread:
Displaying cylinders
|