Faster numerical integration for vector functions
17 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hussein Ammar
el 28 de Jul. de 2019
Comentada: Hussein Ammar
el 28 de Jul. de 2019
Dear all,
I have an algorithm that has a for loop which contains double numerical integartion.
Matlab provides integarl2 with its iterated and tiled methods and the ability to reduce the precision of the integration to make it faster. Unfortunately, integarl2 does not support the functionality 'ArrayValued',true. Which means if I have a vector function I need to write the integral2 evaluations inside a for loop to evaluate each vector element alone.
My problem is that I need to run my algorithm for a large-size vector, and I have checked the execution time, and it looks that this will make my algorithm super slow due to the numerical integartion.
My questions are:
- Does Matlab provide any alternatives to speed up the operation.
- The computer, that I'm running my simulation on, has two beast GPUs GeForce RTX 2080 Ti. Is there anyway to use their power to evaluate the numerical integration (I'm sure it will be faster) without modifying all my Matlab code.
Please reply. Regards,
1 comentario
Walter Roberson
el 28 de Jul. de 2019
https://www.mathworks.com/matlabcentral/answers/130539-how-to-use-gpu-to-calculate-double-integral-with-multivariable-function
Respuesta aceptada
John D'Errico
el 28 de Jul. de 2019
First, why does integral2 not allow arrayvalued integration? I can only conjecture, but I think this is reasonable - integral2 is an adaptive routine. If your various kernels (all stuffed into one vector) are different enough that the adaptive rule would make different choices for each, then it has a problem. As such they decided not to allow that option.
So where does that leave you?
You can use GPU tools to do the work, which requires the parallel processing toolbox, and NVIDIA GPUs. (They make GeForce, so I assume you are ok there.) Can you do that without modifying any code at all? Probably not, since you will need to invoke those GPUs for this specific operation.
Perhps better, is to use parfor. You need the parallel toolbox anyway to use the GPUs. But integral2 will surely not be using multiple cores effectively, as that is NOT the sort of thing that is easily accelerated automatically. However, a simple parfor loop around the call to integral2 will allow you to use all the cores on your machine, at once.
Other options? Without knowing the nature of your integration kernels, I might wonder if you could break the multiple integration up, doing one of them using a direct Gaussian integration of some sort. Of course, that would significantly change your code, and I cannot even guess if it is an option. But it would speed things up.
Más respuestas (0)
Ver también
Categorías
Más información sobre GPU Computing 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!