-
Notifications
You must be signed in to change notification settings - Fork 42
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
tests: Add alignment test #14
Conversation
This test fails on ARM currently |
Thanks! Do you know how to fix it or should I look into it? |
Apparently it works with the arm asm removed, and built with generic. |
Definitely. I'll try to figure out the problem, and if not, will just disable ARM asm until there's a solution. |
We didn't dig into precisely where, but the problem is the |
Also, for another data point, if you modify that test to use |
OK, thanks. I've verified that it indeed failed the test (on Raspberry Pi 3) and removed ARM assembly until someone sends a PR with a fixed version. (I've created https://github.com/dchest/siphash/tree/arm-asm branch that points to the last commit before removal and issue #15). |
I'll take a look. Having a repro will definitely help unearth the issue. |
@rakitzis thank you! |
@rakitzis Only have time for a quick readthrough, but I don't see an alignment check that jumps to |
It's here: AND.S $3,R10,R8
BNE hashloopunaligned In Go code, that is effectively: if val&0x03 != 0 {
hashloopunaligned()
} EDIT: Oh you were talking about |
I'm sure the problem is more subtle but I need to sit with the code when I can stop thinking about other things for a little while... it's tricky to get into the right mindset! |
To clarify, I didn't mean to imply the root of the issue is there. I was responding to @Kunde21 about the check that jumps to the branch (although for the non 128-bit version). That definitely is not the root cause of the issue for 32-bit and 64-bit. |
@davecgh That's present in |
OK so that might be it, but it's best to sit with the test cases and make sure there is 100% coverage. Unaligned is considerably trickier to get right. |
I found the bug: MOVB vs. MOVBU. Byte loads on ARM are sign-extending. Here is a patch:
|
In truth I would like to make sure Hash128 works at all -- the lack of the branch to the unaligned code seems suspicious to me. On the other hand I have found that unaligned loads work on the ARM v7 CPU I have access to. Can someone with deep understanding of the ARM family offer an opinion as to whether special treatment of unaligned loads is even necessary here? Thanks. |
Incidentally the broken code passed the initial tests because the source bytes are in the range 0-63, no sign extension was ever exercised. |
Answering my own question: it seems armv5 (supported by Go) requires unaligned accesses to be synthesized in software. |
No description provided.