Using Parallel Computing Toolbox to run code on CPU and GPU simultaneously
2 comentarios
- How long does it take to run the code you want to speed up to run serially? If you're entire body of code runs in 2 weeks, there may be only part of the code that can be improved.
- Have you addressed code analyzer tips, like preallocation?
- Is it possible you're offsetting implicit multi-threading (e.g., fft) with explicit multi-processing (e.g., parfor) and getting a zero-sum gain on a single machine?
- How are you using the Parallel Computing Toolbox (explicitly calling parfor, parallel-enabled functions, etc.)?
To clarify, it is not possible to just to something like
parfeval(GpuDevice2, @handle_to_function, parameters)
in order to run m code on a gpu.
Functions that are defined for gpu use run on gpu if the function is invoked with a gpu array parameter. So you have to construct arrays on the gpu and run functions on those arrays. You would only want to do this on workers that have a gpu allocated to them. So basically you would need two variations of the code (or careful writing of a single version) with one version tuned to run on gpu and the other that does no gpu work at all. You would have to keep track of which thread was of which type.
It is not difficult to do this, just not as simple as saying "run this on gpu"
Respuestas (1)
Categorías
Más información sobre GPU Computing in MATLAB en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!