Closed giordano closed 7 years ago
Actually, I think LLVM already does this for you. Since n
is a compile-time constant, its constant-folding optimizations eliminate all of the arithmetic:
julia> g = HCubature.GenzMalik(Val{3});
julia> @code_llvm HCubature.countevals(g)
define i64 @julia_countevals_60874(i8** dereferenceable(80)) #0 !dbg !5 {
top:
ret i64 33
}
Good! Actually, I did see an improvement when benchmarking the two implementations (well, with my patch runtime of countevals
went from ~1 ns to ~0.01 ns), so I thought that there was no optimization in place in current implementation. My bad for not having checked llvm code.
countevals
ingenz-malik.jl
is very cheap and is called just once for each call tohcubature
, so improving it isn't definitely a priority. However, its result can be cached by makingcountevals
a generated function, for example in this way:I didn't open a PR because I'm not sure this is really worth.