function handle, parfor loop, matlab 2018 possible bug

I cut and paste pieces of code just to reproduce the issue
beta = 0.75;
relfiltlen = 6;
decfactor = 4096;
pedestal = 0;
weight = 1;
RK = sinc_hann(beta, relfiltlen, decfactor, pedestal, weight);
kernel_tab = RK.r_fintp(decfactor*RK.i_intplength/2+1:RK.i_filtercoef);
R = makeresampler({RK.i_intplength/2, kernel_tab}, 'fill');
cwin=2; covs=2;
osxy = cwin/2:1/covs:cwin/2+2;
[os_xi, os_yi] = meshgrid(osxy, osxy);
tmap = cat(3, os_yi, os_xi);
parfor i=1:10
corros = tformarray(ones(10), [], R, [1 2], [1 2], [], tmap, []);
end
Here clearly the parfor is useless, but again, it is just to reproduce the problem. This piece of code works in every matlab version, but in 2018 it returns an error: "Undefined function handle".
At the time the parfor prepares to start, a warning: "Could not find appropriate function on path loading function handle C:\Program Files\MATLAB\R2018a\toolbox\images\images\private\resampsep.mexw64>resampsep"
R.resamp_fcn
is a funtion handle and it contains
@resampsep
however, from inside the parfor loop, the function handle is set as
'UNKNOWN Function'
The code in fact works if executed in a for loop.
So, it seems in Matlab 2018 some function handles checks have been implemented which were not there in previous matlab versions.
resampsep
is a private function of the image processing toolbox, visible from within the toolbox libraries but not at the time of parfor "compilation". Here probably the reason of the failure of the check.
Whatever the reason, it causes incompatibility issues between different Matlab versions and I think it should be corrected or changed.
Thanks
dp

5 Comments

Thanks for reporting this - I think I can see the same problem (your code isn't executable for me, but I do think I know what's going wrong), but I want to be sure - what version of MATLAB does this work correctly in?
On any version from 2010 to 2017b
I tried to circumvent the checks by forcing the function handle from within the parfor loop, and I got a more explicit message:
An UndefinedFunction error was thrown on the workers for 'resampsep'. This might be because the file containing 'resampsep' is not accessible on the workers. Use addAttachedFiles(pool, files) to specify the required files to be attached. See the documentation for 'parallel.Pool/addAttachedFiles' for more details.
It means the workers cannot access the private function. I believe this is major issue... Any ideas about how is Matlab going to deal with this?
Many thanks
It looks like the issue was solved in 2018b.
It seems like that one uses parallel computing to run the function will face this issue. I used parallel computing to carry out the multistart optimization and got the same error like urs. Did u find out that whether there is a corrective way for this issue without downloading the matlab of a more latest version?

Sign in to comment.

Answers (0)

Products

Release

R2018a

Asked:

on 25 Sep 2018

Commented:

on 8 Apr 2024

Community Treasure Hunt

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

Start Hunting!