-
Notifications
You must be signed in to change notification settings - Fork 11
Plural right shift #91
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
base: master
Are you sure you want to change the base?
Conversation
#include "zoo/swar/SWAR.h" | ||
#include <cstdint> |
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.
?
B val = msb.value() >> (NB - 1); | ||
auto msbCopiedToLSB = S{val}; |
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.
Why this change?
T res = msbCleared.value() << 1; | ||
return S{res}; |
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.
Why so many unnecessary changes?
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.
was getting seemingly random type errors.
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.
will try and resolve
inc/zoo/swar/associative_iteration.h
Outdated
/** Transforms a number into a number into a binary tally. | ||
* E.g. 0b0011 (3) -> 0b0111 |
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.
You seem to mean this converts a binary to an unary
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.
yes lol thank you.
inc/zoo/swar/associative_iteration.h
Outdated
static_assert(base2TallyTransform_Plural(S{0b0001'0010'0011'0011}).value() == 0b0001'0011'0111'0111); | ||
static_assert(base2TallyTransform_Plural(S{0b0000'0001'0010'0011}).value() == 0b0000'0001'0011'0111); | ||
static_assert(base2TallyTransform_Plural(S{0b0100'0001'0010'0011}).value() == 0b1111'0001'0011'0111); | ||
static_assert(base2TallyTransform_Plural(S{0b0000'0000'0000'0001}).value() == 0b0000'0000'0000'0001); | ||
static_assert(base2TallyTransform_Plural(SWAR<8, uint16_t>{0b000000111'00000101}).value() == 0b01111111'00011111); // 7 -> 5 |
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.
Use whitespace to make the point of the comparison/test evident!
You not only trample the whitespace of others, but fail to use it
Now is correct. Godbolt for your amusement. https://godbolt.org/z/T51GPhT8M
Generate the smallest mask required to blit out the overflow using (2^shift_size - 1) which basially transforms shift size into a tally representation of itself in binary. Such that 2 -> 11; 3 -> 111; 4 -> 1111; etc. This then only requires the lane index mask and a shift, then or'ing it all back into the result.