How do I translate C++ threading into Matlab Parallel Toolbox?
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
If I have this code in C++, what is the Matlab equivalent in the Parallel toolbox?
HANDLE snThread;
unsigned threadID;
PassIn par;
par.what = 1;
snThread = (HANDLE)_beginthreadex( NULL, 0, displaySN, &par, 0, &threadID);
i = SetThreadPriority(snThread, THREAD_PRIORITY_TIME_CRITICAL);
if (i!=1) {
cout <<"Can not set thread priority. Quit!"<<endl;
CloseHandle(snThread);
} else {
WaitForSingleObject(snThread, INFINITE);
CloseHandle(snThread);
}
cout<<endl;
where displaySN is a function that is described as "The working horse, running a prioritized thread." I can include the displaySN code if people want, however, it will include code that specifically a product of a company and hence may not be intelligible.
So the purpose of the code is to take a bunch of images we previously created, hold them in queue, and run them very quickly one right after the other, essentially showing a movie. Threading helps us achieve the quick turnover in images.
I am a bit confused what the difference is between threading and the parallel computing toolbox or how either relate to each other
1 Kommentar
Gautam Mohan
am 1 Apr. 2016
Hi Lex,
Threading is not really related to the Parallel Computing Toolbox. The PCT is meant to serve as an abstraction within MATLAB to write parallelized code. It provides an interface to multicore systems in the form of a Parallel Pool, and allows for certain keywords such as 'parfor' that allows easy structuring of parallelized code.
It does not offer the kind of low-level parallelism that threading deals with. There isn't an analogous construct in MATLAB for a thread. All parallelization is handled internally by MATLAB, and all the user needs to worry about is the code they are writing. You can read more about the PCT here. It is geared more towards data parallelism.
I would recommend trying to implement your application in MATLAB without worrying about parallelization, and trying to optimize it after writing it if it does not suit your performance requirements.
You can also call C++ functions through MATLAB via the MEX interface . This might be a potential solution for you if a MATLAB implementation is unable to match the performance goals of your current application.
Antworten (0)
Siehe auch
Kategorien
Mehr zu MATLAB Compiler finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!