This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

AM62D-Q1: documentation on __atomic_swap

Part Number: AM62D-Q1

Hi,

I need to use __atomic_swap available in c7x.h on C7x core. It is mentioned in available documentation but not describe in detail. I am looking for this detailed description. I can guess how to use by it looking at signature `int __OVBIFM __atomic_swap(__WR int*, int, int)`. Except the last argument. I guess it is memory order. I must find proper documentation. Compiler does not describe it, assember programming guide is not available. Where I can find the right document?

I found so far

  • spruip0 - C71x DSP CPU, Instruction Set, and Matrix Multiply Accelerator
  • spruiv4d - C7000 C C++ Optimization Guide.pdf
  • spruig8k - C7000 Optimizing C C++ Compiler v5.0.0.LTS
  • Hi Michael,
    The details about the intrinsics are available in SPRUIU4(C7 ISA Guide). You can request the documents from here: https://www.ti.com/secureresources/C7X-EA-DEV.

    However, I don't see much details about the mapping with the third parameter. Let me check internally and get back to you on this.


    Thanks,
    Shreyansh

  • Hi Michal,
    Here is what I found based on the testing scripts since the ISA was a bit unclear about it:

        /* ASW */
        int asw_mem = 2;
        int res1 = __atomic_swap(&asw_mem, /* unused? */ 0, /* replace */ 1);
        assert(res1 == 2);
        assert(asw_mem == 1);
    

    From that, you can see that the values being swapped are between the memory (first) operand and the register (third) operand. It also shows that the second operand is unused. I hope this makes it clear.

    Thanks,
    Shreyansh