Created
October 31, 2014 21:02
-
-
Save toivoh/0b8537ae82fb66c83f1d to your computer and use it in GitHub Desktop.
Trying to get Julia to produce an unrolled loop with SIMD instructions in it
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module TestSIMD | |
immutable TypeConst{T} end | |
function innerloop!{T, M}(dest::Vector{T}, dest_ofs, src::Vector{T}, src_ofs, ::TypeConst{M}) | |
@simd for i=1:M | |
@inbounds dest[i + dest_ofs] $= src[i + src_ofs] | |
end | |
end | |
function showcode(T, n) | |
println() | |
@show T n | |
println("===========") | |
code_native(innerloop!, (Vector{T}, Int, Vector{T}, Int, TypeConst{n})) | |
end | |
showcode(Uint64, 8) | |
showcode(Uint64, 16) | |
end # module |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I'm trying to get Julia to emit an inner loop that is unrolled and uses SIMD instructions, but it seems that I can't have both at the same time. (Trying to optimize https://gist.github.com/toivoh/c9a1f1e064396bdf3447)
With
n = 8
, I get unrolling but no SIMD instructions:With
n = 16
, I get SIMD instructions but no unrolling: