Giter VIP home page Giter VIP logo

Comments (7)

stevengj avatar stevengj commented on June 27, 2024 2

I think to keep generality, the in-place one uses in-place operations and leaves the other one alone.

Yes, but it would be good to refactor so that they can share as much code as possible. I'd hate to see the entire current implementation copy-pasted and then modified.

from quadgk.jl.

stevengj avatar stevengj commented on June 27, 2024

Sounds good to me. I'm not entirely sure of the API for passing f!, though. quadgk!, since presumably you'd also want to pass a pre-allocated result array?

Some tricky refactoring might be required to keep the current generality (since not all types support things like .+=) while allowing in-place operations with preallocated arrays where possible.

One approach would be to internally wrap f! in an InplaceIntegrand functor type and dispatch on that, so that we can pass it through do_quadgk etcetera, and then add various methods foo(f, ...) which use the current behavior for generic f and an optimized in-place behavior for f::InplaceIntegrand.

from quadgk.jl.

ChrisRackauckas avatar ChrisRackauckas commented on June 27, 2024

I think it would be quadgk! with a pre-allocated result array. I think to keep generality, the in-place one uses in-place operations and leaves the other one alone. quadgk would then be good for scalars and static arrays (so no broadcasting internally), while quadgk! would be more optimized for types which mutate and broadcast. Broadcast is almost a superset of indexable since GPUArrays and things like that are types which broadcast well but don't really index (they now have a fallback to avoid).

I would also like to have options to pass in the work vectors, much like it's done in the differentiation libraries, so I can avoid it allocating those each time. Or some kind of config/plan type that is made once and re-use.

from quadgk.jl.

dominikkiese avatar dominikkiese commented on June 27, 2024

Has there been any progress on this? Came over this issue when using quadgk in multithreaded loops on Intel KNL cpus, as the allocation made by the integrand severly limits proper scaling.

from quadgk.jl.

stevengj avatar stevengj commented on June 27, 2024

No, no one has worked on this yet.

from quadgk.jl.

stevengj avatar stevengj commented on June 27, 2024

Note that for integrating small vector integrands, you can use SVector from StaticArrays.jl and it will be fast. See also this discussion on discourse.

from quadgk.jl.

stevengj avatar stevengj commented on June 27, 2024

I just pushed a PR to address this issue.

Note that it still cannot operate entirely in-place, because the QuadGK algorithm must dynamically allocate a heap data structure containing integration results on subintervals determined from error estimation.

from quadgk.jl.

Related Issues (20)

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.