Skip to content

Instantly share code, notes, and snippets.

@tanakamura
Created March 31, 2019 16:18
Show Gist options
  • Save tanakamura/223aedf51fe03b4b165c1d1b22750965 to your computer and use it in GitHub Desktop.
Save tanakamura/223aedf51fe03b4b165c1d1b22750965 to your computer and use it in GitHub Desktop.
/*
* clzero の後にstoreするとmemsetよりはるかに悪くなる
*
* * clzeroのみ :30[GB/s]
* * clzero + ストア :3[GB/s]
* * memset :12.5[GB/s]
*/
void *amd_clzero(void *dst, const void *src, size_t sz)
{
size_t line_size = 64;
size_t num_line = sz / line_size;
unsigned char *d = (unsigned char*)dst;
unsigned char *s = (unsigned char*)src;
for (int i=0; i<num_line; i++) {
_mm_clzero(d);
d[0] = 99;
d += line_size;
}
return NULL;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment