The largest data type that can be selected using an atom atom?

I wanted to try and atomically reset 256 bits using something like this:

#include <x86intrin.h>
#include <iostream>
#include <array>
#include <atomic>

int main(){

    std::array<std::atomic<__m256i>, 10> updateArray;

    __m256i allZeros = _mm256_setzero_si256();

    updateArray[0].fetch_and(allZeros);
}

but I get compiler errors about an element not having fetch_and(). Is this not possible, because the 256-bit type is too large to guarantee atomicity?

Is there any other way to implement this? I am using GCC.

If not, then what is the largest type I can reset atomically - 64 bits?

EDIT: Can any AVX commands perform a sampling-AND atomically?

+4
source share
2 answers

So, there are a few different things to solve:

  • What can a processor do?
  • What do we mean by the atomic path?
  • , ?
  • ++ 11/14?

# 1 # 2:

x86 8, 16, 32, 64, 128, 256 512 . [ , ] . , " ", [ , , ]. " " " " - [ ] , .

VEX LOCK ( Intel)

VEX- LOCK, VEX, #UD

VEX AVX, #UD "undefined " - , , .

, 100% , 256 . SSE: SSE: 16B?

# 3 , .

# 4 - , std::atomic<uintmax_t>, uintmax_t - 128 256 , , , . , 128 uintmax_t, .

"" , " 100%, , ", SSE, AVX AVX512 - (), // .

x86 - CMPXCHG16B, 64- , MATCH . , -, 128- , , , - , , , -.

, , Intel AMD, .

+5

, // . lock and [mem], %rax . ( Intel insn ref , lock and, .)

AVX, VPAND, ( , ), (//), .

Mats Petersson , , , , AVX . , cmpxchange, , - cmpexchange.

0

All Articles