How do I translate C++ threading into Matlab Parallel Toolbox?
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaire
Gautam Mohan
le 1 Avr 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.
Réponses (0)
Voir également
Catégories
En savoir plus sur MATLAB Compiler dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!