ReadGmByPassDCache(ISASI)

Applicability

Product

Supported

Atlas 350 Accelerator Card

Atlas A3 training product/Atlas A3 inference product

x

Atlas A2 training product/Atlas A2 inference product

x

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

Reads data from the global memory address without passing through the DCache.

When multiple cores operate the global memory address, if the data cannot be aligned to the cache line, random overwriting of multi-core data may occur because data is read and written based on the cache line size when the DCache is used. In this case, you can directly read and write the global memory address without using the DCache to avoid random overwriting.

Prototype

1
2
template <typename T>
__aicore__ inline T ReadGmByPassDCache(__gm__ T* addr)

Parameters

Table 1 Template parameters

Parameter

Description

T

Operand data type.

For the Atlas 350 Accelerator Card, the supported data types are int8_t, uint8_t, int16_t, uint16_t, int32_t, uint32_t, int64_t, and uint64_t.

Table 2 API parameters

Parameter

Input/Output

Meaning

addr

Input

Source global memory address.

Returns

Data at the source global memory address.

Constraints

If this API is continuously called (polling) for multi-core synchronization, the bus will be occupied for a long time. As a result, other cores cannot access the global memory. There will be a deadlock when multiple cores read the same global memory. If polling is required, you are advised to add Nop instructions between the calls to this API. The recommended number of instructions is 800, which is generally the number of cores to be synchronized multiplied by 200.

Example

1
2
3
4
5
6
7
8
9
__gm__ int32_t* addr = srcGlobal.GetPhyAddr();
int32_t value = ReadGmByPassDCache(addr);

// When Scalar Unit reads and writes the same global memory, the read operation needs to release the bus to avoid long-time occupation.
int target = -1;
while (target != 0) {
     target = ReadGmByPassDCache(addr);
     Nop<800>();
}