Multi-Threading w/ MEX: Adding Two Vectors

A basic MEX function that adds two vectors together, but utilizes multiple threads. Created as a way to learn MEX multi-threading.

現在この提出コンテンツをフォロー中です。

In order to optimize certain pieces of a simulation, I tried to build out a multi-threaded algorithm for solving certain linear algebra problems that I couldn't find good solutions to in various libraries or that couldn't be vectorized in proper MATLAB code.

Since I found a lot of the tutorials available online very confusing, once I figured things out I thought it would be handy to share what I learned. With thanks to Yair Altman and his multi-threading example from 2018 that included all of the information I needed to finally figure things out:

https://undocumentedmatlab.com/blog/multi-threaded-mex

To add non-Windows compatibility, you can add in pthreads by following along with Yair's example.

This needs to be compiled with the command, "mex -R2018a madd.cpp"

引用

oreoman (2026). Multi-Threading w/ MEX: Adding Two Vectors (https://jp.mathworks.com/matlabcentral/fileexchange/70406-multi-threading-w-mex-adding-two-vectors), MATLAB Central File Exchange. に取得済み.

謝辞

ヒントを得たファイル: max_in_place - example of multi-threaded MEX function

ヒントを与えたファイル: Simpler MEX Multi-Threading w/ a Persistent Thread Pool

カテゴリ

Help Center および MATLAB AnswersMATLAB Algorithm Acceleration についてさらに検索

一般的な情報

MATLAB リリースの互換性

  • R2018a 以降のリリースと互換性あり

プラットフォームの互換性

  • Windows
  • macOS
  • Linux
バージョン 公開済み リリース ノート Action
1.0.0