compare vector of values using intrinsics / simd

0

I'm trying to compare a vector of 8 bit chars to another vector using intrinsics, but encountering an unexpected crash when comparing values. I'm using C/C++ with microsoft visual studio for this. A minimum reproducable example would be the following:

#include <immintrin.h>
#include <string>

int main(int argc, char* argv[]) {
    // Below is longer than 32 bytes so should be enough for an example.
    std::string input = "AEHAICIAAAAAAAAFJIAOEJFEJAIJEJRIAJEJIJRIAJIEJRIAJIEJRAIJIERJAIEJA";
    const char* input_c = input.c_str();
    auto loadedA = _mm256_set_epi8('A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A','A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A');
    auto loaded32 = _mm256_loadu_si256((const __m256i*) input_c);
    // Crash below this line
    auto cmpA = _mm256_mask_cmp_epi8_mask((__mmask32) 0xffffffff, loaded32, loadedA, 0);
    return 0;
}

Edit: Specific question: Is there a fix / alternative instruction I could use that would have similar behaviour? I need to be able to compare 8 bit values.

Edit: The instruction that compiles from _mm256_mask_cmp_epi8_mask was not supported by my CPU. I solved the issue by using _mm256_cmpeq_epi8 instead. Duplicate: Comparing 2 vectors in AVX/AVX2 (c)

c
simd
intrinsics
avx
asked on Stack Overflow Aug 1, 2020 by AceCrow • edited Aug 1, 2020 by AceCrow

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0