Clear Filters
Clear Filters

How to use parfeval?

2 views (last 30 days)
DhanaLakshmiR
DhanaLakshmiR on 15 Feb 2018
Commented: DhanaLakshmiR on 24 Feb 2018
can anyone will explain the syntax of F = parfeval(p,fcn,numout,in1,in2,...) this? p(builds parallel pool),fcn(is the function),What is numout,in1,in2? I have 3output from the function how can i use that output using fetchoutputs(f)? Kindly give answers.

Accepted Answer

Walter Roberson
Walter Roberson on 15 Feb 2018
You need to have an existing parpool stored in a variable that you pass in as the first parameter.
fun is the handle of the function to be executed.
If you need the third output then numout should be at least 3: the value should be the maximum number of output that you need from each call.
When you collect the output then you will get a cell array if I recall correctly, which you can index at {3}
  3 Comments
Walter Roberson
Walter Roberson on 23 Feb 2018
Yes, that should work.
However, remember that there is overhead is communicating with a parallel pool and asking it to do work and getting the results back, so using parfeval is slower if the work to be done is not "big enough" or if you do not have at least two workers processing data. In the code outline you show, you are always immediately waiting for the future you just created, so you will only ever have one future executing at a time, and the amount of work you are asking the future to do is trivial so the cost of using the parfeval will overwhelm any benefits. In the code you outline, you would be better off just calling sixdof directly without any parallel pool.
DhanaLakshmiR
DhanaLakshmiR on 24 Feb 2018
Thank you for your explanation.

Sign in to comment.

More Answers (0)

Categories

Find more on Background Processing in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!