How to efficiently use spmd to load multiple files and perform execution?
Mostrar comentarios más antiguos
I have the following function to load and process files in parallel. I was expecting the number of cores used to 100% during run time should be limited by "maxNumAllowedByMem" argument. However, I was pleasantly surprised to see 100% on all available cores on my computer. Why is that? I thought I have only provided data to the first (maxNumAllowedByMem)th worker data?
function output = spmd_process_files(fileNameInCells, maxNumAllowedByMem)
spmd
if labindex<=maxNumAllowedByMem
outputBuffer = load(fileNameInCells{labindex});
outputBuffer = aLongProcessFunction(outputBuffer);
end
end
output = outputBuffer{1};
for nthComp = 2:maxNumAllowedByMem
output = someCombineFunction(output, outputBuffer{nthComp});
end
end
Respuestas (2)
Edric Ellis
el 12 de Nov. de 2015
Under some circumstances, the "idle" workers can consume CPU resources while waiting for the other workers to get to the end of the spmd block. You could try using the optional number of workers argument to the spmd block:
spmd (maxNumAllowedByMem)
outputBuffer = ...;
end
1 comentario
Ben Gislason
el 16 de Sept. de 2016
0 votos
Does anyone know of any good examples that show step by step of how to use spmd to load and process multiple data sets? Ethan shows the overall structure to do this but I am running into difficulty setting up the load data and run function aspects. Any help would be greatly appreciated...
Categorías
Más información sobre Startup and Shutdown en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!