assemblyintelxeon-phi

How AVX-512CD (conflict detection) differs from atomic variables access?


So I was watching this ANL Training video and they show how

void Histogram ( const float* age, int* const hist, const int n, const float group_width, const int m) {
    const float oogw = 1.0f / group_width;
    // Populating the histogram.
    for( int i = 0; i < n; i++) {
        // Calculating the index of the bin age[i] goes to.
        const int j = (int) ( age[i] * oogwflh );
        // Incrementing the appropriate bin in the histogram.
        hist[j]++;
    }
}

And loop gets verctorized. With this instruction. https://youtu.be/5IHqKKxuLM0?list=PLGj2a3KTwhRa__pANkWixmIZWBLQkEhZD&t=641

How it is diferent from atomics and is it resonable to expect to expect conflict detection support from compilers on instruction level (for difrent enteties e.g. POD structs) in future?


Solution

  • The AVX512 conflict detection instructions detect conflicts which would occur when a single scatter instruction writes to the same store location more than once. This is a conflict between different vector lanes in the same instruction.

    Atomic operations protect against race conditions which occur when more than one logicalCPU executes a load/store to the same address "at the same time".

    Thus you require the conflict detection instructions if your code is vectorized even if it runs single threaded, whereas there is no need for atomic operations until your code is parallelized and executing with many threads.