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

Add trait "iscomplete" to Alphabet #151

Closed
jakobnissen opened this issue Mar 13, 2021 · 2 comments
Closed

Add trait "iscomplete" to Alphabet #151

jakobnissen opened this issue Mar 13, 2021 · 2 comments
Milestone

Comments

@jakobnissen
Copy link
Member

Add trait "iscomplete" to every alphabet. It should default to Val{false}(). It should return Val{true} if length(symbols(A)) == 1 << bits_per_symbol(A), i.e. if all bitpatterns are valid. In that case, the decoder can skip validation. There are also other efficiencies to be had, such as better random sequence generation.

@jakobnissen jakobnissen added this to the v3.0.0 milestone Mar 15, 2021
@TransGirlCodes
Copy link
Member

Oooh I like that idea!

@TransGirlCodes TransGirlCodes mentioned this issue Apr 30, 2021
17 tasks
@jakobnissen
Copy link
Member Author

Okay, this is now added in #161 . Turns out it was not that important, actually. With a little tweaking of the index functions to remove all unnecessary branches and signed/unsigned conversions, here is what f(x, i) = @inbounds x[i] compiles to:

julia> @code_native debuginfo=:none f(a, 2)
	.section	__TEXT,__text,regular,pure_instructions
	leaq	-4(,%rsi,4), %rax
	movq	(%rdi), %rcx
	movq	(%rcx), %rcx
	movq	%rax, %rdx
	shrq	$3, %rdx
	andq	$-8, %rdx
	shrxq	%rax, (%rcx,%rdx), %rax
	andb	$15, %al
	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

No branches or pull requests

2 participants