Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lots of allocations #21

Open
jw3126 opened this issue Nov 9, 2018 · 1 comment
Open

Lots of allocations #21

jw3126 opened this issue Nov 9, 2018 · 1 comment

Comments

@jw3126
Copy link

jw3126 commented Nov 9, 2018

Cuba produces a lot of allocations, 4 per iteration in the example below. Is there a way to avoid this?

julia> using Cuba

julia> f!(x,ret ) = ret
f! (generic function with 1 method)

julia> vegas(f!); # warmup

julia> @time vegas(f!)
  0.001090 seconds (4.01 k allocations: 187.984 KiB)
Component:
 1: 0.0 ± 7.025180405943273e-18 (prob.: -999.0)
Integrand evaluations: 1000
@giordano
Copy link
Owner

giordano commented Nov 9, 2018

I'll have a look but I'm not sure there is anything I can do about this. The only suggestion I can give you is to use cuhre instead of vegas as the former is more accurate and requires fewer evaluations (thus fewer allocations):

julia> using Cuba, BenchmarkTools

julia> @btime cuhre((x, f) -> f[1] = x[1])
  25.231 μs (784 allocations: 36.89 KiB)
Component:
 1: 0.5 ± 4.291960664289122e-15 (prob.: 0.0)
Integrand evaluations: 195
Fail:                  0
Number of subregions:  2

julia> @btime vegas((x, f) -> f[1] = x[1])
  21.588 ms (928004 allocations: 42.48 MiB)
Component:
 1: 0.4999999506146127 ± 4.969630652405548e-5 (prob.: 2.559630372933608e-5)
Integrand evaluations: 232000
Fail:                  0
Number of subregions:  0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants