I seem to be one of few people using the Matlab coder (codegen command) to get speedup, judging by the fact that there is so little discussion or help on-line. I've gotten incredible speedups from it in some cases. I've never seen it documented, but when I make a MEX file using codegen from a Matlab script with a parfor loop, it often will thread the resulting MEX. Parfor in functions spawns multiple processes which is often less efficient than just threading (I'm inferring all this from watching top in linux and seeing multiple 100% processes in Matlab functions, but a single e.g. 1000% process when running the converted MEX). I'm working on a case now where I could really use the speedup, but I see no evidence of multiple threads being used in the MEX even though parfor is working in the base function. Anyone know what the hangup might be, or how the coder chooses when to thread?
When does Matlab choose to thread when using codegen and parfor
865 Views Asked by Mastiff At
1
There are 1 best solutions below
Related Questions in MULTITHREADING
- new thread blocks main thread
- WPF MessageBox Cancel checkbox check
- How to avoid concurrent access to a resource?
- run oncomplete event in async
- Threading Segfault when reading members
- Function timeouts in C and thread
- How are multiple requests to Task.Run handled from a resource management standpoint?
- Acumatica perfomance with threads
- Wait and Notify in Java threads for a given interval
- Different behavior of async with Visual Studio 2013(Windows8.1) and GCC 4.9(Ubuntu14.10)
- How to return blocking queue to the right object?
- background thread using Task.Run
- deletion and cleanup of worker thread in Qt crashes
- Pipeline-like operation using TChan
- implementing in app purchase on android
Related Questions in MATLAB
- How to open and read video stream in Matlab
- Interpolation and replace zeroes
- How can I fix my code to do line by line conditional statements in Matlab
- matlab crash during acquisition of pointgrey images
- Calling text file
- Apply gaussian filter on text
- re-plotting of data on same GUI axes in matlab
- Issue with nume1 in MATLAB
- Multiply two variables in Matlab with vpa - high precision
- ODE - Solving Parameter Dependent on Variable [Matlab]
- Need help in detecting multiple blobs
- How does TIC TOC in matlab work?
- Image based steganography that survives resizing?
- lowering computaional cost in finding the location of minimum distance
- FFT Filtering of signal
Related Questions in PARALLEL-PROCESSING
- Async vs Horizontal scaling
- Scattered indices in MPI
- How to perform parallel processes for different groups in a folder?
- Julia parallel programming - Making existing function available to all workers
- Running scala futures somewhat in parallel
- running a thread in parallel
- How to make DGEMM execute sequentially instead of in parallel in Matlab Mex Function
- Running time foreach package
- How to parallelize csh script with nested loop
- SSIS ETL parallel extraction from a AS400 file
- Fill an array with spmd in Matlab
- Distribute lines of code to workers
- Java 8 parallelStream for concurrent Database / REST call
- OutOfRangeException with Parallel.For
- R Nested Foreach Parallelization not Working
Related Questions in PARFOR
- Serialization error during parfor
- Cell arrays in MATLAB using parfor
- MATLAB: variable progress is uninitialized temporary not reduction
- Problems with parfor-loop in command line execution
- Matlab parfor and input files
- Why is bsxfun on a gpuArray so slow?
- How to use FinalImage variable inside parfor Loop?
- Error using parfor inside spmd block - matlab
- Matlab: access function input in parfor loop
- MATLAB 2014b Parallel Figures
- Using Parfor to create matrix from a vector
- Updating Waitbar throws error while using matlabpool
- How to nest multiple parfor loops
- Is it possible to use parfor loops to increase the speed of training multiple neural networks in MATLAB?
- Matlab Parfor Variable cannot be Classified
Related Questions in MATLAB-CODER
- How can I ensure an emxArray is correctly allocated in generated C code?
- converting matlab code to c code readiness error
- Using coder.extrinsics conditionally
- matlab coder: cannot transpose a matrix that is incorrectly deemed to be 3-D when it should always be 2-D
- 3D Matrix as output of a Matlab Function in a Simulink model
- Error while compiling to LINUX Matlab Code with MatlabR2012a
- cell() constructor is not supported for code generation
- 3D Matrix in Simulink which can be 2D is not supported
- Run Matlab Coder Output Project on Visual Studio or g++
- How to use Matlab embedded coder under Windows to compile for LINUX?
- matlab codegen linking/embedding mex
- error with nested loops when using matlab coder, however there are NO nesting at all
- Matlab c embedded coder code
- The most efficient method to start a matlab code within a C-Routine
- Matlab coder - Expected a scalar. Non-scalars are not supported in IF or WHILE
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
It will only thread the parfor loop itself, it would be dangerous for the coder to guess, and impossible to calculate where there is appropriate parallelism.
If I were you, I would try to put parfor in place of anywhere in the Matlab code that I could.
And now how to determine whether a loop is acceptable to parallelize:
Does it use IO in any form, if so, then don't, it will slow it down and remove any determinism from the code
Is there a loop for parfor to replace? If not, then you'll have to deal with the performance because there might not be anything to parallelize.