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

A memcpy fused version would be nice. #896

Open
Emjayen opened this issue Nov 9, 2023 · 2 comments
Open

A memcpy fused version would be nice. #896

Emjayen opened this issue Nov 9, 2023 · 2 comments

Comments

@Emjayen
Copy link

Emjayen commented Nov 9, 2023

As per the title: for performance reasons (single pass & overlapping writes) a version which performs xxh3 and memcpy would be nice to have. Ideally with the option for nt stores where available.

@Cyan4973
Copy link
Owner

Cyan4973 commented Nov 9, 2023

What do you mean ?
a "safer" memcpy() followed by a memcmp() ?

@t-mat
Copy link
Contributor

t-mat commented Nov 9, 2023

I have no idea what is actually asked in this issue.

But I'm just guessing "fused" function means:

memcpy(dst, data, dataSize);
xxh_update(&state, dst, dataSize);

More specific example:

uint8_t*  p     = ...;
xxh_state state = ...;

while(...) {
  // Store some data to tmp[]
  uint8_t tmp[...];
  my_magic_func(tmp, sizeof(tmp), ...);

  // LHS ("performance reason") may happen
  // - https://en.wikipedia.org/wiki/Load-Hit-Store
  // We can reverse the order of invocation in this case though.
  memcpy(p, tmp, sizeof(tmp));
  xxh_update(&state, p, sizeof(tmp));

  p += sizeof(tmp);
}

hash = xxh_digest(&state);

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

3 participants