SetAtomicMax (ISASI)

Applicability

Product

Supported

Atlas 350 Accelerator Card

Atlas A3 training product/Atlas A3 inference product

Atlas A2 training product/Atlas A2 inference product

Atlas 200I/500 A2 inference product

x

Atlas inference product AI Core

x

Atlas inference product Vector Core

x

Atlas training product

x

Function Usage

Sets whether to perform atomic comparison for subsequent data transferred from VECOUT to GM, which compares the content to be copied with the existing content in GM and writes the maximum value to GM.

You can set different data types using template parameters.

Prototype

1
2
template <typename T>
__aicore__ inline void SetAtomicMax() 

Parameters

Table 1 Template parameters

Parameter

Description

T

Sets different data types.

For the Atlas A2 training product/Atlas A2 inference product, the supported data types are int8_t, int16_t, half, bfloat16_t, int32_t, and float.

For the Atlas A3 training product/Atlas A3 inference product, the supported data types are int8_t, int16_t, half, bfloat16_t, int32_t, and float.

For the Atlas 350 Accelerator Card, the supported data types are int8_t, int16_t, half, bfloat16_t, int32_t, and float.

Returns

None

Constraints

  • You are advised to disable atomic maximization by using DisableDmaAtomic to avoid affecting subsequent functions.
  • For the Atlas A2 training product/Atlas A2 inference product, the inf/nan mode cannot be set for the bfloat16_t type.

Example

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
#include "kernel_operator.h"

uint32_t size = 256;
AscendC::LocalTensor<half> dst0Local = queueDst0.DeQue<half>();
AscendC::LocalTensor<half> dst1Local = queueDst1.DeQue<half>();
AscendC::DataCopy(dstGlobal, dst1Local, size);
AscendC::PipeBarrier<PIPE_MTE3>();
AscendC::SetAtomicMax<half>();
AscendC::DataCopy(dstGlobal, dst0Local, size);
queueDst0.FreeTensor(dst0Local);
queueDst1.FreeTensor(dst1Local);
AscendC::DisableDmaAtomic();

The input data of each core is as follows:
Src0: [1,1,1,1,1, ...,1] // 1 × 256
Src1: [2,2,2,2,2, ...,2] // 2 × 256
Final output data: [2,2,2,2,2, ...,2] // 2 × 256