Is LLVM version of modf
guaranteed to be safer or faster for some input or platform, compared to the fallback method
modf(x) = rem(x,one(x)), trunc(x)
? On my machine (64-bit GNU/Linux), the fallback method is much faster than LLVM with Float64
numbers:
julia> test_llvm_modf() = for x in -1000:0.001:1000; modf(x); end
test_llvm_modf (generic function with 1 method)
julia> @benchmark test_llvm_modf()
BenchmarkTools.Trial:
memory estimate: 0 bytes
allocs estimate: 0
--------------
minimum time: 16.505 ms (0.00% GC)
median time: 16.613 ms (0.00% GC)
mean time: 16.700 ms (0.00% GC)
maximum time: 17.188 ms (0.00% GC)
--------------
samples: 300
evals/sample: 1
julia> test_fallback_modf() = for x in -1000:0.001:1000; rem(x,one(x)), trunc(x); end
test_fallback_modf (generic function with 1 method)
julia> @benchmark test_fallback_modf()
BenchmarkTools.Trial:
memory estimate: 0 bytes
allocs estimate: 0
--------------
minimum time: 589.929 μs (0.00% GC)
median time: 589.941 μs (0.00% GC)
mean time: 596.599 μs (0.00% GC)
maximum time: 856.916 μs (0.00% GC)
--------------
samples: 8373
evals/sample: 1