why MATLAB 2019b MEX file is slower

4 ビュー (過去 30 日間)
Kat Lee
Kat Lee 2019 年 10 月 24 日
編集済み: James Tursa 2019 年 10 月 29 日
Hey all
I am testing performance comparison among R2017b and R2019b, and I have noticed that for most .m functions, it's becoming way much faster, but one noticable thing is that the time for mex file (calling multi-thread C) has been tripled, which is very werid.
I believe this could be caused by some overhead in C or mex side. But am still very curious why a better MATLAB can cause slow down
Thanks
Kat

採用された回答

James Tursa
James Tursa 2019 年 10 月 24 日
編集済み: James Tursa 2019 年 10 月 24 日
Impossible to say for sure without knowing what your mex function is doing. One thing to note is that in R2018a the storage format of complex variables changed from separate real & imag to interleaved real & imag. So passing complex variables may force a copy-in-copy-out behavior in one version but not the other. What is your mex function doing?
See:
  2 件のコメント
William Lu
William Lu 2019 年 10 月 29 日
Thanks James.
The mex file I use heavily involves extracting complex matrices.
I'm currently following this article on improving my mex's performance used in R2019
James Tursa
James Tursa 2019 年 10 月 29 日
編集済み: James Tursa 2019 年 10 月 29 日
If you are passing complex matrices back & forth, you absolutely need to rewrite your code for interleaved real & imag and compile with the -R2018a flag in order to regain that performance. If you need help with this don't hesitate to post more questions.
There are two ways to get at your data. Using the new data types as shown in the doc:
mxComplexDouble *xc = mxGetComplexDoubles(prhs[0]);
// then use xc[i].real and xc[i].imag in your code
Or using a regular primitive data type and adjusting the indexing by 2:
double *pr = (double *) mxGetData(prhs[0]);
// then use pr[i*2] and pr[i*2+1] for the real & imag parts in your code

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeC Matrix API についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by