Skip to content

Commit

Permalink
src: add maskload example
Browse files Browse the repository at this point in the history
Signed-off-by: Daniel Bevenius <[email protected]>
  • Loading branch information
danbev committed May 26, 2024
1 parent ed3a07f commit 7418c3c
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions fundamentals/simd/src/masking.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#include <stdio.h>
#include <immintrin.h>

int main() {
int i;
int int_array[8] = {1, 2, 3, 4, 5, 6, 7, 8};

__m256i mask = _mm256_setr_epi32(-1, -1, -1, -1, 0, 0, 0, 0);

__m256i result = _mm256_maskload_epi32(int_array, mask);

int* res = (int*)&result;
printf("%d %d %d %d %d %d %d %d\n",
res[0], res[1], res[2], res[3], res[4], res[5], res[6], res[7]);

return 0;
}

0 comments on commit 7418c3c

Please sign in to comment.