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

Show conciseness of generated code in README/docs? #14

Closed
ali-ramadhan opened this issue Mar 12, 2021 · 0 comments · Fixed by #16
Closed

Show conciseness of generated code in README/docs? #14

ali-ramadhan opened this issue Mar 12, 2021 · 0 comments · Fixed by #16

Comments

@ali-ramadhan
Copy link
Collaborator

ali-ramadhan commented Mar 12, 2021

Seems like other packages like to show off how short the generated LLVM or assembly code is to show that the code generated is performant. Is it worth adding something similar for DispatchedTuples.jl?

I'm not too familiar with @generated so I played around to see if the generated code was indeed concise. Looks like it is!

DispatchedSet

julia> ds = DispatchedSet((Center() => "c", Face() => :f))
DispatchedSet{Tuple{Tuple{Center, String}, Tuple{Face, Symbol}}, DispatchedTuples.NoDefaults}(((Center(), "c"), (Face(), :f)), DispatchedTuples.NoDefaults())

julia> @code_native dispatch(ds, Face())
        .text
; ┌ @ DispatchedTuples.jl:147 within `dispatch'
; │┌ @ DispatchedTuples.jl within `macro expansion'
; ││┌ @ tuple.jl:29 within `getindex'
        movq    8(%rdi), %rax
; ││└
        retq
        nopw    %cs:(%rax,%rax)
; └└

julia> @code_native dispatch(ds, Center())
        .text
; ┌ @ DispatchedTuples.jl:147 within `dispatch'
; │┌ @ DispatchedTuples.jl within `macro expansion'
; ││┌ @ tuple.jl:29 within `getindex'
        movq    (%rdi), %rax
; ││└
        retq
        nopw    %cs:(%rax,%rax)
; └└

DispatchedTuple

julia> dt = DispatchedTuple((Center() => "c", Face() => "f", Center() => :c, Face() => :f))
DispatchedTuple{Tuple{Tuple{Center, String}, Tuple{Face, String}, Tuple{Center, Symbol}, Tuple{Face, Symbol}}, DispatchedTuples.NoDefaults}(((Center(), "c"), (Face(), "f"), (Center(), :c), (Face(), :f)), DispatchedTuples.NoDefaults())

julia> @code_native dispatch(dt, Center())
        .text
; ┌ @ DispatchedTuples.jl:107 within `dispatch'
        movq    %rdi, %rax
; │┌ @ DispatchedTuples.jl:24 within `macro expansion'
; ││┌ @ tuple.jl:29 within `getindex'
        movq    (%rsi), %rcx
        movq    16(%rsi), %rdx
; ││└
        movq    %rcx, (%rdi)
        movq    %rdx, 8(%rdi)
        retq
        nopw    %cs:(%rax,%rax)
; └└

julia> @code_native dispatch(dt, Face())
        .text
; ┌ @ DispatchedTuples.jl:107 within `dispatch'
        movq    %rdi, %rax
; │┌ @ DispatchedTuples.jl:24 within `macro expansion'
; ││┌ @ tuple.jl:29 within `getindex'
        movq    8(%rsi), %rcx
        movq    24(%rsi), %rdx
; ││└
        movq    %rcx, (%rdi)
        movq    %rdx, 8(%rdi)
        retq
        nopw    %cs:(%rax,%rax)
; └└
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

Successfully merging a pull request may close this issue.

1 participant