Parrallel run using parfor and institute server?
2 views (last 30 days)
I need to speed up my matlab code, for this How can I use parfor nested loop? Here, I am able to use iner parfor loop but it takes time almost equal to normal nested for loop. And outer parfor loop give error. I am trying to run the for loop code as.
Along with this, I also want to run this code using a server facility which contain multiple CPU (as worker) and cores. How would I run it using the server.
Edric Ellis on 10 Oct 2022
The problem with converting the outer loop to parfor is described in the error message that you get when you try:
Error: When indexing the sliced variable 'output', the range of the for-loop variable 'j' must be a row vector of positive constant numbers or variables.
The fix is to calculate the length of na outside the parfor loop. (I know this seems unncessary, but parfor is very fussy about this sort of thing)
na_len = length(na);
The speed-up you get here may well be only small using local workers.
To use more resources, you need to get MATLAB Parallel Server set up on your server facility. Once that is available, you can run your parfor loop across multiple machines.