-
Notifications
You must be signed in to change notification settings - Fork 230
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 additional space to store 64-bit hash codes on 32-bit machines #3359
Conversation
Wait so you're saying we earmark 32-bits extra on the stack so that when we read 64 bits from the hash counter we don't get junk? I'm concerned that we're reading a 64-bit integer on 32-bit systems! Why not make threadlocal variables in interpreter all 64 bits? Also, is the problem with using Tangentially, are there users out there with 32-bit systems who use the most recent M2 versions? (i.e. not users still running M2 v1.9 or something) |
Yes, exactly.
That might be a better solution, but I think all of the other thread local variables are 32-bit ints.
hash_t is already a typedef for uint64_t.
Probably not. I occasionally run it on my 32-bit raspberry pi for giggles. I need it to build on several 32-bit architectures for Debian, though. |
I could be wrong, but I think they're just
Does Debian require all packages to build on 32-bit archs? I've always been a bit concerned about tests or examples that were removed because they failed on rare architectures. |
Theoretically, an
Kind of. There are three officially supported 32-bit architectures (i386, armhf, and armel), plus a bunch of non-official ones. If Macaulay2 stops building on any of the three official ones, then it won't migrate from unstable to testing on any of the architectures, 32-bit or 64-bit. There are ways around this if we ever decide to completely remove 32-bit support one day, though. Converting this to a draft. I like the idea of making the array of thread-local variables hold 64 bits per slot instead of 32. |
I've looked at this a little more, and I'm not sure how to change the number of bits per element of the array without some more serious study of how pthreads work. For now, I'm proposing that we keep this hacky solution so that hashes work properly on 32-bit systems. I'll add a TODO comment. |
On 32-bit machines, thread local variables are stored in arrays of 32-bit chunks of memory. But now that we use 64-bit hash codes, we were getting the hash counter by concatenating two adjacent elements of the array, giving us unexpected results. We add a new thread local variable to store these extra 32 bits, fixing this issue.
Also fix the comments -- these hash codes differ based on 32-bit v. 64-bit, not endianness.
9047c48
to
137c226
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good! I'll merge once tests past.
This is a followup to #3335, checking off the final checkbox from the TODO list in #3335 (comment).
On 32-bit machines, thread local variables are stored in arrays of 32-bit chunks of memory. But now that we use 64-bit hash codes, we were getting the hash counter by concatenating two adjacent elements of the array, giving us unexpected results.
We add a new thread local variable to store these extra 32 bits, fixing this issue. This will be unnecessary if we switch to an atomic hash counter (see #3358).
Now that we can actually see what the expected result should be, we also update the hash code test for
RR
objects for 32-bit machines.