I have a conceptual question. I have a MATLAB code for simulating a beam propagation (optics) which has lots of for loops inside it but every iteration in a loop depends on the previous one (n+1 th iteration depends on the values from nth iteration). As I understood it means that the loops are not suitable for parallel computing, i.e. I cannot use parfor instead of for. Does that mean when I send my job using batch to the node of a cluster, am I only using 1 core in that node?
I tried to send the same code with requesting 28 and 56 cores seperately and there was no time difference in run time. ChatGPT told me that its because my code does not suppport parallel computing and I’m only using one core.
Is there a faster way other than the parallel computing if I won’t be able to use it?
1
There are different types of parallel computing. In your case, what you’re doing sounds like a typical “ODE-style” problem where you’re propagating a system in time. Generally, these are challenging to parallelise. Probably your best bet is instead of trying to parallelise over time-steps, try and use data-parallelism to run each time-step more quickly.
This approach only really works well if each time-step exposes a lot of possibly-parallel computations. If you’re working with FFT-based optical propagation, you can perhaps use distributed
arrays to make a data-parallel approach. Data parallelism on the CPU like this can be hard to get good speedup. Using gpuArray
(if possible) might be more appropriate.