matlab parfor with arrayfun (sliced variable) -
as title says, want have parfor loop inside usage of arrayfun.
created minimal working example problem:
having following lines in file called thisparfortest.m
function test=thisparfortest(countmax) parfor count=1:countmax test(count).nummer=count; test(count).bisdrei=arrayfun(@(testnum)eq(test(count).nummer,testnum),1:3); end
the command mcc('-e','-v','thisparfortest')
results in
compiler version: 4.18.1 (r2013a) error: file: **************\thisparfortest.m line: 3 column: 5 variable test in parfor cannot classified. see parallel loops in matlab, "overview". processing c:\program files\matlab\r2013a\toolbox\matlab\mcc.enc processing include files... 2 item(s) added. processing directories installed mcr... file mccexcludedfiles.log contains list of functions excluded ctf archive. 0 item(s) added. generating matlab path compiled application... created 43 path items. parsing file "****************\thisparfortest.m" (referenced from: "compiler command line"). parsing file "c:\program files\matlab\r2013a\toolbox\compiler\deploy\deployprint.m" (referenced from: "compiler command line"). parsing file "c:\program files\matlab\r2013a\toolbox\compiler\deploy\printdlg.m" (referenced from: "compiler command line"). unable determine function name or input/output argument count function in matlab file "thisparfortest". please use mlint determine if file contains errors. error using mcc error executing mcc, return status = 1 (0x1).
but advised mlint thisparfortest
(and checkcode
) returns no problems - in editor.
loop can done , compiled loop.
please not ask sense of these commands - here mwe.
think, should reported mathworks - or have done wrong?
additions: when running
function retval=thisparfortest(countmax) helpfun=@(x)arrayfun(@(testnum)eq(x,testnum),1:3); parfor count=1:countmax retval(count).nummer=count^2; retval(count).bisdrei=helpfun(retval(count).nummer); end
with for
loop works, when using shown version parfor
results in
error using thisparfortest>(parfor supply) (line 3) undefined function or variable "retval". error in thisparfortest (line 3) parfor count=1:countmax caused by: undefined function or variable "retval"
shouldn't caught mlint/checkcode? this happens without compiler.
i don't believe issue has compilation. when attempt run code in regular matlab same error variable test
in parfor
cannot classified.
there's no bug here - not every piece of code can run inside parfor
loop, , it's not possible matlab determine prior runtime pieces can , can't. tries job, , when does, code analyzer tell prior runtime - when can't, give runtime error you've found.
perhaps can think of way matlab have statically determined variable not classified - in case reported mathworks enhancement request code analyzer.
Comments
Post a Comment