Git Product home page Git Product logo

Comments (2)

JoshuaLampert avatar JoshuaLampert commented on July 18, 2024

For the Svärd-Kalisch equations, it's a bit more delicate because the elliptic operators changes over time, which currently leads to massive allocations:

@timeit timer() "dv elliptic" begin
hmD1betaD1 = Diagonal(h) - D1betaD1
dv[:] = hmD1betaD1 \ dv
end

The SummaryCallback for examples/svaerd_kalisch_1d/svaerd_kalisch_1d_dingemans.jl currently gives

 ──────────────────────────────────────────────────────────────────────────────
        DispersiveSWE                 Time                    Allocations      
                             ───────────────────────   ────────────────────────
      Tot / % measured:           1.91s /  99.3%           3.61GiB /  99.7%    

 Section             ncalls     time    %tot     avg     alloc    %tot      avg
 ──────────────────────────────────────────────────────────────────────────────
 rhs!                 5.16k    1.88s   99.2%   364μs   3.59GiB   99.7%   730KiB
   dv elliptic        5.16k    1.10s   58.2%   213μs   2.77GiB   76.9%   563KiB
   dv hyperbolic      5.16k    719ms   38.0%   139μs    590MiB   16.0%   117KiB
   deta hyperbolic    5.16k   53.3ms    2.8%  10.3μs    250MiB    6.8%  49.5KiB
   ~rhs!~             5.16k   4.87ms    0.3%   944ns    810KiB    0.0%     161B
   source terms       5.16k    265μs    0.0%  51.3ns     0.00B    0.0%    0.00B
 analyze solution        86   14.3ms    0.8%   167μs   10.0MiB    0.3%   119KiB
 ──────────────────────────────────────────────────────────────────────────────

Do you see a possibility to reduce the allocations @ranocha?

from dispersiveshallowwater.jl.

ranocha avatar ranocha commented on July 18, 2024

I'm using the following approach in another project:

system_matrix = Symmetric(...)
if issparse(system_matrix)
    (; factorization) = parameters
    cholesky!(factorization, system_matrix)
    dv .= factorization \ tmp
else
    factorization = cholesky!(system_matrix)
    ldiv!(dv, factorization, tmp)
end

You could do something similar here:

  • use in-place factorizations like lu! for dense matrices
  • pre-allocate the factorization for sparse matrices and re-use it (assuming that the sparsity pattern does not change over time)

from dispersiveshallowwater.jl.

Related Issues (14)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.