matlabversiontransparencyparfor

Matlab R2015b vs R2015a - table in parfor loop - transparancy violation


I am currently experiencing a basic transparency violation error when creating a table in a parfor loop. The most confusing point it that the exact same example code works in R2015a, but does not work anymore in the newer version R2015b.

To simulate the problem i am running the following code on both Matlab versions:

A = [1,2,3,4];

parfor i=1:5
  table(A)
end

Doing so returns the following error:

Error using table (line 247) Transparency violation error.
See Parallel Computing Toolbox documentation about Transparency

I am now curious to hear if anyone experienced the same issue or if anyone can provide an explanation for this. Using the prior version both my initial code and also this simple example worked like a charm.


Solution

  • Unfortunately, this is because the workspace transparency checks in R2015b got more stringent, and disallow the use of inputname, which is what the table constructor is using. I think the only way to fix this is to move the table construction function call into a function called from within your parfor loop. I.e.

    parfor idx = 1:1
      t{idx} = iBuildTable(idx);
    end
    
    function t = iBuildTable(varargin)
      t = table(varargin{:});
    end
    

    NOTE: The original problem has been fixed in R2019b of MATLAB, out now (released 2019-09-11).