Questa domanda è chiusa. Riaprila per modificarla o per rispondere.

Is there a way to parallelize the function hygepdf?

4 visualizzazioni (ultimi 30 giorni)
Ewen Chan
Ewen Chan il 17 Mag 2018
Chiuso: MATLAB Answer Bot il 20 Ago 2021
So I have a script that uses the hygepdf function in a for loop and the result of i=i+1 does not depend on the result that is calculated when i=i.
(Hopefully that makes sense.)
Given that, is there a way that I can use the parallel computing toolbox and multiple workers so that I will be able to compute each of the hygepdf computations in the for loop in parallel and then assemble the results back together as if it had ran it in the for loop?
i.e. here is the quasi-pseudocode:
original with a for loop
for i=1:16
and then change is to that it can run each of those 16 loops in parallel:
something like
Hopefully I am able to articulate what I am trying to do sufficiently enough that people will understand what I am going for here.
Again, the basic premise in this for loop calculation is that the result of the current index isn't needed by the next index, so I want to see if there is a way to use multiple workers to run the for loop in parallel and then just assemble the results together at the end.
Thank you.
  4 Commenti
Paolo il 17 Mag 2018
Modificato: Paolo il 17 Mag 2018
You are welcome, you can use tic toc to get an indication of the performance increase. Let me know if that solves your question and I'll turn that comment into an answer.
Ewen Chan
Ewen Chan il 17 Mag 2018
Yeah, I'm already using tic/toc.
I see the worker nodes starting up, but then after a while, the extra parallel workers aren't doing anything more and I am not really 100% sure why.
Unfortunately, I am not authorized to release the code, otherwise I would, so I realize and understand that it means the team's ability to help me is severely limited because of this.
Having said that, here is what the structure of it looks like (at a very high level):
In the second block, I tried to nest a parfor inside a parfor and it didn't let me. (I did a find/replace all.)
I'm not much a programmer and I have a VERY limited understanding about MATLAB, but are there other commands here that I can try to use to increase the amount or level of parallelization?
If parfor is only resulting in limited returns, are there more explicit ways for me to quote "manually" make it run on the other workers?
(It would be akin to running another instance of MATLAB without actually have to run another instance of MATLAB.)
Again, hopefully I am communicating my question in a manner that makes sense to people besides myself.
If I am not communicating my question in a clear manner, please let me know.

Risposte (1)

Bernhard Suhm
Bernhard Suhm il 12 Giu 2018
I am not an expert for the Parallel Computing toolbox, but if the calculation inside the for loop body is fairly simple (as it looks in your case), the loop bodies will actually be executed in groups, so there's no guarantee all workers will remain busy. I've added PCT as keyword so someone there can jump in if they have other suggestions.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by