Trouble with dspunfold function

I have been looking into multithreading mex functions and I came across dspunfold function. It looked like the perfect match for what I needed but unfortunately I keep running into different errors. I think I have boiled down my code to the absolute bare-bones so that I can show the two errors that are causing the problems.
  1. Use of setdiff function
  2. Passing empty output
Either of cases 1/ 2 above breaks down the dspunfold function. However, I did not see in the function documentation of dspunfold that talks about this. Interestingly, none of this happens when I use codegen (but the resulting mex file is single threaded). Obviously, neither of the two cases are avoidable for me (it is my nonlcon function within fmincon that I am trying to speed-up). Any help or pointers is greatly appreciated.
function [y,z] = foo()
%#codegen
z=[];
fixed_dof = [2;3;5;9;55];
all_dof = (1:240)';
free_dof = setdiff(all_dof,sort(fixed_dof));
y= free_dof;
end
% calling the dspunfold function
dspunfold foo -s auto

4 件のコメント

Chaitanya Awasthi
Chaitanya Awasthi 2021 年 5 月 18 日
I think I figured out why setdiff function is problematic. It is because despite the size of the arguments of the setdiff function being constant, it is possible for the output to be varying in size. I guess I would have to manually assign the value to free_dof variable to fix this error.
Still unsure what to do with the second error.
Jan
Jan 2021 年 5 月 18 日
Just a note: Would this simplification still match your needs:
function [y,z] = foo()
z = [];
y = (1:240).';
fixed_dof = [2;3;5;9;55;245];
y(fixed_dof) = [];
end
Chaitanya Awasthi
Chaitanya Awasthi 2021 年 5 月 18 日
Hi Jan. I had made a small mistake in my presented code in that I had an entry in fixed_dof that wasn't in all_dof. This shouldn't happen (I have edited the code to reflect this). But yes, your modified code will work for me. However, dspfunfold still throws the same errors.
Chaitanya Awasthi
Chaitanya Awasthi 2021 年 5 月 29 日
Sorry, I forgot to update the public on this. I tested the dspunfold function a little more, and while it does speedup the calcuations by at least >= 1.5x (single-threaded vs multi-threaded file), I cannot use this in my fmincon code because it includes latency. This is a deal-breaker for my problem.

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

回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeIntroduction to Installation and Licensing についてさらに検索

製品

リリース

R2019b

質問済み:

2021 年 5 月 18 日

コメント済み:

2021 年 5 月 29 日

Community Treasure Hunt

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

Start Hunting!

Translated by