Speed up code - deletion of rows/columns
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
In my code I have a lot of big sized variables. In order for the code to run on my computer, I decided on deleting already assigned (and further processed, thus not anymore needed) rows / columns.
velocity_air(:,:,2) = [];
transformation_matrix(:,:,:,:,2) = [];
It seems to me, that by doing this, I succeed in reducing the required RAM, however those deleting assignments take a lot of time. In fact, the time increases exponentially when I increase the number of iterations.
Is there another way to delete used rows / columns?
What else can I do to have the code run faster?
2 comentarios
KSSV
el 25 de Ag. de 2020
Check squeeze once. First you need to think why those many dimensions in matrix?
Respuestas (2)
Steven Lord
el 25 de Ag. de 2020
I'm guessing you're doing this in a loop. In that case consider the old song 99 Bottles of Beer, slightly modified.
99 bottles of beer on the wall, 99 bottles of beer
Take one down, pass it around, slide all the other bottles forward to fill the slot, 98 bottles of beer on the wall
Doesn't quite have the same ring to it, does it? And you're going to be sliding all the bottles forward a lot. How often does that 99th bottle move? That's kind of what you're doing when you delete a page from the middle of the array.
How big are these "big sized variables"? How much memory does the system on which you're running your code have?
Mir Amid Hashemi
el 28 de Sept. de 2020
I had a similar problem, however I don't know if it can be applied to your code. I created a fifo of constant length in the gpu. Whenever I considered one element of the fifo to have processed, I gather it to CPU ram and use that index to put a new element. What you might be doing is changing the dimension of your matrix dynamically and it slows performance.
0 comentarios
Ver también
Categorías
Más información sobre Solver Outputs and Iterative Display 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!