Skip to content

Fixes issue 99. Replace aligned loads with unaligned.#101

Merged
lemire merged 4 commits into
masterfrom
dlemire/issue_99
Feb 16, 2023
Merged

Fixes issue 99. Replace aligned loads with unaligned.#101
lemire merged 4 commits into
masterfrom
dlemire/issue_99

Conversation

@lemire

@lemire lemire commented Feb 16, 2023

Copy link
Copy Markdown
Member

Based on #100 but arguably more complete and better?

Credit to @pps83 for the hard work.

Fixes #99

@lemire

lemire commented Feb 16, 2023

Copy link
Copy Markdown
Member Author

@pps83 Would you review?

@pps83 pps83 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should also update commit title, something like "Replace aligned loads with unaligned"

and make sure you squash commits when merging.

Comment thread src/horizontalbitpacking.cpp Outdated
std::numeric_limits<int32_t>::min(),
std::numeric_limits<int32_t>::max());
for (int i = 0; i < values; ++i) {
for (uint32_t i = 0; i < values; ++i) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unsigned. Even though values is uint32_t, it's quite strange to use uint32_t as loop counter.
same for a change bellow

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems necessary to ensure i < values is both efficient and correct for values approaching std::numeric_limits<uint32_t>::max() right?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe to avoid any concern, you could use the standard algorithms library to fill the vector in a declarative fashion.

Suggested change
for (uint32_t i = 0; i < values; ++i) {
std::generate_n(std::begin(v), values, std::bind(dist, e2));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that would be outside of the scope of the PR.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's quite strange to use uint32_t as loop counter.

Why? Many compilers object to signed/unsigned comparisons. I don't want to change the type of values. The alternative for the counters are size_t, unsigned int, ... none of them functionally better. Well, size_t (an unsigned type) is arguably better but I am not certain it matters.

std::generate_n(std::begin(v), values, std::bind(dist, e2));

@cbsmith Good idea, but it is out of scope here. I only changed that bit to silence a warning. If you'd like to modernize the C++, the please consider issue a distinct PR. There is much that could be done...

@pps83

pps83 commented Feb 16, 2023

Copy link
Copy Markdown
Contributor

also, it looks it's based off from some old version, not from the last master.

Comment thread headers/VarIntG8IU.h
Comment thread headers/VarIntG8IU.h
Comment thread src/horizontalbitpacking.cpp Outdated
@pps83

pps83 commented Feb 16, 2023

Copy link
Copy Markdown
Contributor

I checked the PR, many of the issues I saw got resolved. However, I still see one place where a byte or two end up unmodified the output. Perhaps, it's ok to merge this one, and take a look at that issue separately.

@lemire lemire changed the title Fixes issue 99. Fixes issue 99. Replace aligned loads with unaligned. Feb 16, 2023
@lemire

lemire commented Feb 16, 2023

Copy link
Copy Markdown
Member Author

Merging.

@cbsmith : I invite you to prepare a distinct PR if you'd like.

@lemire
lemire merged commit 2ec76c3 into master Feb 16, 2023
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 this pull request may close these issues.

Some of the functions leave gaps in output buffers

3 participants