Group Abstract Group Abstract

Message Boards Message Boards

0
|
7.6K Views
|
3 Replies
|
1 Total Like
View groups...
Share
Share this post:

Sow and reap in parallel submit with outside variable use

Posted 12 years ago
POSTED BY: Mathias Breuss
3 Replies

Probably, the time required to do all the parallel staff (kernels communication and other) is greater then plain sequential computation time. The benefit from parallel computations can be seen, for example, for ParallelTable[] when it's arg takes some decent time to be evaluated for a single iteration:

ParallelTable[Pause[1]; 0.,{4.}]; // AbsoluteTiming
Table[Pause[1];0.,{4.}]; // AbsoluteTiming
(*{1.009058, Null}*)
(*{4.003229, Null}*)

I.M.

POSTED BY: Ivan Morozov
Posted 12 years ago

Hi Ivan,

thanks for your answer. That solved the problem indeed.

However, lets say I put end = 2000, using ParallelSubmit it takes 2 seconds to compute the result. While it barely takes any time when I run

Reap[For[t = 0, t < end, t++, Sow[t]]]

without using ParallelSubmit.

Any Idea why that might be slower?

POSTED BY: Mathias Breuss

Hi,

'end' var should be shared:

SetSharedVariable[end] ;
end = 5 ;
ParallelSubmit[Reap[For[t = 0, t < end, t++, Sow[t]]]] ;
WaitAll[%]

I.M.

POSTED BY: Ivan Morozov
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard