Group Abstract Group Abstract

Message Boards Message Boards

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

Getting results from parallel computations

Posted 2 days ago

Parallel instances read a global but do not set a global?

POSTED BY: David Golber
3 Replies

Read up on DistributeDefinitions and SetSharedVariable. Your question is also the correct answer: Parallel instances read a global [via the default DistributeDefinitions] but do not set a global [unless SetSharedVariable[x] has been executed on each global variable x].

The parallel kernels run independently. "Shared" resources in RAM are not shared so much as copied between processes.

Generally, one avoids SetSharedVariable, since interprocess copying is not very efficient. Instead, return the data from each kernel, if possible. For instance:

 {ret1, ret2, ret3, ret4} = Parallelize[foo /@ Range[4]]
POSTED BY: Michael Rogers
Posted 1 day ago

Thanks for this. I had tried DistributeDefinitions, but that didn't do it. I found using Return from Parallelize did it, as you suggested, and it's just as simple as what I originally tried.

POSTED BY: David Golber
Posted 1 day ago

Well, I still don't know why the above doesn't work. But this does work.

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