MathGroup Archive 2009

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

Search the Archive

Re: Followup question: Problem with parallel evaluation of integrals

  • To: mathgroup at smc.vnet.net
  • Subject: [mg99905] Re: Followup question: Problem with parallel evaluation of integrals
  • From: Jens-Peer Kuska <kuska at informatik.uni-leipzig.de>
  • Date: Tue, 19 May 2009 06:43:13 -0400 (EDT)
  • References: <guqvb2$a7i$1@smc.vnet.net>

Hi,

you have serious problems withe the Mathematica syntax and
you should read the general Mathematica before you try parallel
computations.
But

ParallelEvaluate[$ProcessID]

testfunc6[FF_, GG_] := Block[{xxx, yyy, ff, gg, S},
   ff[x_] := FF[x];
   gg[x_] = GG /. ip_InterpolatingFunction :> ip[x];
   xxx[S_?NumericQ] := NIntegrate[Sin[ff[x]], {x, 0, S}];
   yyy[S_?NumericQ] := Block[{x},
     NIntegrate[Cos[gg[x]], {x, 0, S}]];
   DistributeDefinitions[ff, gg, xxx, yyy];
   Print["ff[x]=", ff[x]];
   Print["gg[x]=", gg[x]];
   Print["xxx[.1]=", ParallelEvaluate[xxx[.1]]];
   Print["xxx[.1]=", xxx[.1]];
   Print["Int(xxx[S])=",
    ParallelEvaluate[Integrate[xxx[S], {S, 0, 1}] // N]];

   Print["yyy[1][.1]=", ParallelEvaluate[yyy[.1]]];
   Print["yyy[1][.1]=", yyy[.1]];
   (*Print["Int(yyy[1][S])=",ParallelEvaluate[Integrate[yyy[S],{S,0,
   1}]]//N]
   *)
   ]

f1 = Interpolation[Table[{i, i}, {i, 0, 1, 1/4}]]
f2 = 3 f1

testfunc6[f1, f2]

work fine. But nonsense in Mathematica is also nonsense if you
evaluate it parallel -- it only become parallel nonsense.

Regards
   Jens




Alan Barhorst wrote:
> Hello, I have done more experimentation and the problem is pronounced  
> when I try to feed parallel kernels the things I need evaluated.  Here  
> is a session that shows how the order of when the grid point iterates  
> for NIntegrate are applied to an interior integral.  The help menu  
> shows how to do what I want in the main kernel, but something about  
> using ParallelEvaluate releases the hold on the NIntegrate before the  
> place holder symbol is assigned a numerical value.
> 
> Any help is appreciated.
> 
> 
> AB
> ________________________________________________________
> Alan A. Barhorst, PhD, PE	        | alan.barhorst at ttu.edu
> Professor					| http://www.me.ttu.edu/
> Mechanical Engineering		| Phone: 806-742-3563, ext 241
> Texas Tech University
> Lubbock, TX 79409-1021		
> 
> When leaders disregard the law and human dignity, kooks
> are emboldened; innocence lost.
> 
> Human potential cannot be developed or measured from a
> floating moral reference frame.
> ________________________________________________________
> 
> ParallelEvaluate[$ProcessID]
> 
> testfunc6[FF_, GG_] := Module[{xxx, yyy, ff, gg},
>    SetSharedFunction[ff, gg];
>    ParallelEvaluate[ff[x_] := FF[x]];
>    ParallelEvaluate[gg[x_] := GG[x]];
> 
>    Print["ff[x]=", ff[x]];
>    Print["gg[x]=", gg[x]];
> 
>    SetSharedFunction[xxx];
>    ParallelEvaluate[xxx[S_] := Integrate[Sin[ff[x]], {x, 0, S}] // N];
>    Print["xxx[.1]=", ParallelEvaluate[xxx[.1]]];
>    Print["xxx[.1]=", xxx[.1]];
>    Print["Int(xxx[S])=", ParallelEvaluate[Integrate[xxx[S], {S, 0,  
> 1}] // N]];
> 
>    (*here since the function is subscripted it must be defined in the  
> base kernel as well*)
> 
>    SetSharedFunction[yyy];
>    yyy[S_] := Integrate[Cos[gg[x]], {x, 0, S}] // N;
>    ParallelEvaluate[yyy[S_] := Integrate[Cos[gg[x]], {x, 0, S}] // N];
>    Print["yyy[1][.1]=", ParallelEvaluate[yyy[1][.1]]];
>    Print["yyy[1][.1]=", yyy[1][.1]];
>    Print["Int(yyy[1][S])=", ParallelEvaluate[Integrate[yyy[1][S], {S,  
> 0, 1}] // N]];
> 
>    UnsetShared["*"];
> 
>    ]
> 
> f1 = Interpolation[Table[{i, i}, {i, 0, 1, 1/2}]]
> f2 = 3 f1
> 
> testfunc6[f1, f2]
> 
> 


  • Prev by Date: Re: Interesting Mersenne identities and a prime based
  • Next by Date: Re: Re: Exports to eps, pdf ImageSize
  • Previous by thread: Re: Interesting Mersenne identities and a prime based
  • Next by thread: SQLServerLaunch