Quantcast
Channel: First steps - JuliaLang
Viewing all articles
Browse latest Browse all 2795

Efficient way for assigning a massive array

$
0
0

@AhmedAlreweny wrote:

Hello,
I am new to Juila (and programming in general). I am working on solving a massive linear system resulting from a finite difference discretization of an ODE. My matrix is almost a bordered matrix (got some elements on the corners because of periodic BCs), so I defined it as a SparseMatrix. To fill up this system, I need multiple calls to one function that computes the Jacobian at each time step. The system size might reach 10 millions. At the beginning, I thought that the linear solver is taking most of the time, but it turns out that the filling up of the system take a MASSIVE amount of time and allocations. This is one example of the resources needed to fill up only one block on the diagonal of the system.

@time (
for j = 1:M
    s=size(f_dx(j), 1)
    e=(1+(j-1)*s)+(N-1)

    D_matrix[1+(j-1)*s:e  ,  1+(j-1)*s:e,
    ] = -f_dx(j)
end
)
57362.172008 seconds (7.79 G allocations: 18.049 TiB, 2.93% gc time)

I need every possible tip to optimize the assigning procedure, please.

Posts: 7

Participants: 3

Read full topic


Viewing all articles
Browse latest Browse all 2795

Trending Articles