Skip to content

Instantly share code, notes, and snippets.

@dmarion
Created September 21, 2021 19:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dmarion/13252cfef5b054b364faf881a61e96e4 to your computer and use it in GitHub Desktop.
Save dmarion/13252cfef5b054b364faf881a61e96e4 to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include <sys/mman.h>
#include <x86intrin.h>
int main() {
void *p = (void *)0x100000000ULL;
__m512i v, zero = {};
p = mmap(p, 4096, PROT_READ | PROT_WRITE,
MAP_FIXED | MAP_PRIVATE | MAP_POPULATE | MAP_ANONYMOUS, -1, 0);
printf("p = %p\n", p);
for (int i = 0; i < 512; i++)
((unsigned long long *)p)[i] = i;
v = _mm512_mask_loadu_epi64(zero, 0x0f, p + 4096 - 32);
printf("%llu %llu %llu %llu %llu %llu %llu %llu\n", v[0], v[1], v[2], v[3],
v[4], v[5], v[6], v[7]);
v = _mm512_mask_loadu_epi64(zero, 0xff, p + 4096 - 32);
printf("%llu %llu %llu %llu %llu %llu %llu %llu\n", v[0], v[1], v[2], v[3],
v[4], v[5], v[6], v[7]);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment