Parallel computing Monte Carlo
4 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
cedric W
el 25 de Sept. de 2018
Comentada: Joss Knight
el 11 de Oct. de 2018
I'm running 1M simulations on a Monte Carlo basis. I'd like to improve the computation speed and I was thinking about parallel computing but wanted to have a guess about what to expect in term of improvment.
I'd like to understand a little more about modifications that have to be made in my code.
I actually have an almost fully vectorized version of MC simulations and therefore I don't run any loop for i=1:10^6 loop.
How should I modify my code for the parallel computing to be efficient ? I guess – since MATLAB’s strength is to work vectorised – I must not introduce a “ parfor i=1:10^6 “ loop. I was thinking about splitting my computation, i.e. vectorising batches of 10^4 simulations (instead of a single 10^6) and then running a parfor loop 10^2 times. Would this method be ok or would it lead to poorer results (I know it's hard to guess without trying, which is something I haven't done yet, but I need a guess to know if I'm going wrong way) ? What could be an efficient solution ?
FYI, I'm running simulations on a test computer, 4 cores, utilization at around 75% of each core when running.
3 comentarios
KSSV
el 25 de Sept. de 2018
Yes..it will if you have one deserving..read about gpuDevice, gpuArrays etc.
Respuesta aceptada
Joss Knight
el 30 de Sept. de 2018
You seem to have the right idea. For highly vectorized code, parallelization should be done in batches. However, it does depend on what you are doing as to whether you will gain anything using a parallel pool. Many matrix operations in MATLAB are already heavily multi-threaded. Use the system tools to determine whether any of your CPU cores are idle and so available.
12 comentarios
Joss Knight
el 11 de Oct. de 2018
No, it'll generate the same set of numbers in a particular iterate each time you run your code, which may be a different worker because of the way parfor scheduling works, but appears to be what you want.
Más respuestas (0)
Ver también
Categorías
Más información sobre Parallel Computing Toolbox en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!