Le mercredi 26 novembre 2014 à 07:55 -0800, Colin Lea a écrit :
> I'm implementing an inference algorithm and am running into memory
> allocation issues that are slowing it down. I created a minimal
> example that resembles my algorithm and see that the problem persists.
> 
> 
> The issue is that Julia is allocating a lot of extra memory when
> adding matrices together. This happens regardless of whether or not I
> preallocate the output matrix. 
> 
> 
> Minimal example: 
> https://gist.github.com/colincsl/ab44884c5542539f813d
> 
> 
> Memory output of minimal example (using
> julia --track-allocation=user):
> https://gist.github.com/colincsl/c9c9dd86fca277705873
> 
> 
> Am I misunderstanding something? Should I be performing the operation
> differently?
> 
> 
> One thing I've played with is the matrix C. The indices are a sliding
> window (e.g. use C[t-10:t] for all t). When I remove C from the
> equation the performance increases by a factor of 2.5. However, it
> still uses more memory than expected. Could this be the primary issue?
Matrix addition returns a copy (at least currently), so you want to
avoid using it in a tight loop. You can simply write another loop inside
the existing ones to go over 'out' an fill it element by element.


Regards

Reply via email to