How To Perform Synchronized Parallel Computing Using Parfeval?

Hi ,
I am running 2 functions running with an infinite loop within using the parfeval function provided in the parallel computing toolbox. Is synchronization between these 2 functions possible? If yes, then is there any way to establish a semaphore mechanism or an external control dependency during the runtime of these functions ? I have been trying to get the output using fetchOutputs to return the signal the control which causes a blocking call and disrupts the execution of my code.
Is there any other way to achieve this goal using the parallel computing toolbox?
Thanks and regards,
Kaushik Gowda H N

5 件のコメント

Raymond Norris
Raymond Norris 2021 年 9 月 23 日
It would be helpful if you could sketch out the pseudo code of what you're trying to run.
Kaushik Gowda
Kaushik Gowda 2021 年 9 月 23 日
Hi Norris ,
Thank you for the response. I'm trying to have the changes in tables3 reflect in tables4 using the global state variable. How do I achieve this (preferable by avoiding fetchOutputs as it leads to a blocking call)?
Thanks and regards,
Kaushik Gowda H N
KARNAM PRANAV
KARNAM PRANAV 2021 年 9 月 23 日
Hi MATLAB community,
Even I had a similar question. Could I please get a quick update on this.
Mohammad Sami
Mohammad Sami 2021 年 9 月 24 日
編集済み: Walter Roberson 2021 年 9 月 25 日
You cannot declare a global variable in main thread and expect its value to propagate between main thread and workers.
You can look at my answer below to see how you might setup a two way data exchange between main thread and a single worker. You may repeat that with another worker.
However I don't see how your code improves the efficiency, one of the worker will always be idle in your current design, since it depend on the other thread to calculate some value and change the state. In your design only one worker is active at one time.
You may want to see how the workers can work on independent calculations so that you can use both workers simultaneously.
Kaushik Gowda
Kaushik Gowda 2021 年 9 月 27 日
Thank you for the reply. Helped me with my problem.

サインインしてコメントする。

回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeParallel for-Loops (parfor) についてさらに検索

製品

リリース

R2021a

質問済み:

2021 年 9 月 23 日

コメント済み:

2021 年 9 月 27 日

Community Treasure Hunt

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

Start Hunting!

Translated by