Hello,
I have been looking into running independent 2D k-wave simulations on multiple cpu's using parfor in matlab (i.e. one simulation per cpu). To test the performance I ran two simulations using a for loop and then ran the exact same simulations again using a parfor loop using a two core pool (code below) on a 4 core system. When I run simulations using parfor each simulation is ~ 1.7 times slower compared to being run inside a for loop. Therefore the execution time of each loop is nearly the same. I also tested 128x128, 256x256 and 512x512 grids and I saw a factor of 1.7 slow down there too, so I don't think this is due to transferring the grids and data to and from the worker. I have seen the same effect on multiple machines and in HPC environments. I would like to get the simulations to run faster in the parfor loop. Any help or insight on how to do this or if it is possible would be greatly appreciated.
- Jon
Code:
kgrid, medium, source, sensor and input_args are set using the example file "example_pr_2D_TR_circular_sensor.m" in the k-wave toolbox V 1.1.1. the only modification is that PlotSim is set to false.
t_start = tic;
for aa= 1:2
out(aa).sensor_data = kspaceFirstOrder2D(kgrid, medium, source, sensor, input_args{:});
end
t_end_1 = toc(t_start)
t_start = tic;
parfor aa= 1:2
out(aa).sensor_data = kspaceFirstOrder2D(kgrid, medium, source, sensor, input_args{:});
end
t_end_2 = toc(t_start)
Results:
computation time per simulation in for loop = 15.0 seconds
copmutation time per simulation in parfor loop = 24.6 seconds
t_end_1 =
30.1976
t_end_2 =
24.8956