Message Boards Message Boards

0
|
2041 Views
|
0 Replies
|
0 Total Likes
View groups...
Share
Share this post:

Improve ProgressIndicator efficiency in paralleldo loop?

Posted 8 years ago

I am using ProgressIndicator to keep track of loop calculation. This does not cost me anything for DoLoop but for ParallelDo it costs me a lot. I have a idea why this is happening but I am not sure how to prevent it. I use a counter to keep track of the loop and taking the values from each kernel has a large overhead. Here variable "d" I use for keeping track in paralleldo Is there a way to assign d++ to main kernel so I wont pay for transferring it.

ns = 200;
  mat = SetAccuracy[RandomReal[{-100, 100}, ns], nd];
                mat2 = SetAccuracy[RandomReal[{-200, 200}, ns], nd];
  d= 0;
  aI = ConstantArray[0, np];
  SetSharedVariable[aI, d];

  Time = AbsoluteTiming[
     If[nd <= 16,
      Monitor[Do[
        If[iC == 2, Print["Do Loop"]];
        aI[[iC]] = SetAccuracy[mat.(mat2/iC^0.5), nd], {iC, np}], 
       ProgressIndicator[Dynamic[iC/np]]],
      Monitor[ParallelDo[d++;
        If[iC == 2, Print[" ParallelDo Loop"]];
        aI[[iC]] = SetAccuracy[mat.(mat2/iC^0.5), nd];
        , {iC, np}],
       ProgressIndicator[Dynamic[d/np]]]]];

  Print["Do loop time = ", Time[[1]], ", np = ", np, ", nd = ", nd];
  aInum = Apply[Plus, (aI/np)];
  Print["Total = ", aInum];
  Return[aInum]];
np = 1000;
nd = 30;
myDummyF[nd, np];

In the attachment I have the code so you can compare the times.

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

Group Abstract Group Abstract