- Create a pool of size 96 which you use for everything
- For CPU work, just use the pool as normal
- For GPU work, use a restricted-size spmd block for those things.
Is it possible to create multiple parallel pools simultaneously
36 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
EUAN FOSTER
el 8 de Feb. de 2023
Comentada: EUAN FOSTER
el 9 de Feb. de 2023
Hi all,
I have been trying to speed up some code on a HPC I have access to. The PC has 96 cores and 2 GPUs
To do this, I have wrote an application to make it easier for myself and others
I have been implementing parallelisation in order to get the speed increases I am seeking.
I would therefore like to have two parallel pools. One for the CPU cores and the other for the GPUs. Ideally I would have these parallel pools live at the same time and call each of them when I want something to be evaluated on the CPU or GPU.
Right now I need to close the CPU pool, open a GPU pool, evaluate a GPU function, then close the GPU and reopen the CPU pool. While this is faster than doing nothing, the closing and opening of pools is a little slow!
Is this possible? If so can someone please provide some example code or even pseudocode of the overall framework.
Thanks
0 comentarios
Respuesta aceptada
Edric Ellis
el 9 de Feb. de 2023
There's no direct way to do what you're after here. (As @Walter Roberson points out, you can have a backgroundPool and a parpool pool simultaneously, but that probably doesn't help you here).
Here's one potential workaround, which may or may not suit your needs. Basically, the idea is this:
Your client code might look like this:
parpool(96)
% Some CPU stuff
parfor i = 1:1000
out(i) = doStuff(i);
end
% Some GPU stuff
spmd(2)
gpuDevice(spmdIndex); % Make sure we're using the correct GPU
outGpu = doStuffOnTheGPU(spmdIndex);
end
You can also use a restricted-size parfor loop in a similar manner, but there are complexities ensuring you have workers with distinct GPUs that mean it might not be efficient.
Más respuestas (1)
Walter Roberson
el 8 de Feb. de 2023
Editada: Walter Roberson
el 8 de Feb. de 2023
You can have only one parallel pool at a time from a MATLAB client session.
Pools created using parpool('threads') and backgroundPool are both thread-based pools which utilize the same resources. It is possible that activity on one pool may block activity on the other and vice versa. Additionally, persistent data and random number generation stream state are shared in between these pools.
This implies that you might possibly (still) only be able to have one process parpool at a time, but that possibly you could have a process pool at the same time as a background pool, and that definitely you can have a parpool thread pool at the same time as a background pool.
At the moment I do not know whether it is possible to have a cluster pool at the same time as a local pool. I seem to recall there have been a couple of posts implying it was possible, but don't count on it.
I guess your question is really whether you can have more than one cluster pool. The line I quoted first implies not, but I would not rule out the possibility that the line turns out to really only be talking about local pools.
0 comentarios
Ver también
Categorías
Más información sobre Parallel Computing Fundamentals 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!