CheckLocalMemoryIA(ISASI)

Applicability

Product

Supported

Atlas 350 Accelerator Card

x

Atlas A3 training product/Atlas A3 inference product

Atlas A2 training product/Atlas A2 inference product

Atlas 200I/500 A2 inference product

Atlas inference product AI Core

Atlas inference product Vector Core

x

Atlas training product

x

Function Usage

Checks the UB read and write operations within the specified range. If the UB read and write operations are within the specified range, an EXCEPTION error is reported. If the UB read and write operations are not within the specified range, no error is reported.

Prototype

1
__aicore__ inline void CheckLocalMemoryIA(const CheckLocalMemoryIAParam& checkParams)

Parameters

Table 1 Parameters

Parameter

Input/Output

Description

checkParams

Input

UB access check configuration. The parameter type is CheckLocalMemoryIAParam.

For details, see ${INSTALL_DIR}/include/ascendc/basic_api/interface/kernel_struct_mm.h. Replace ${INSTALL_DIR} with the CANN installation path.

For details about the parameter description, see Table 2.

Table 2 Parameters in the CheckLocalMemoryIAParam structure

Parameter

Description

enableBit

Configures the exception register. enableBit ∈ [0,3]. The default value is 0.

  • 0: exception register 0.
  • 1: exception register 1.
  • 2: exception register 2.
  • 3: exception register 3.

startAddr

Start address of CheckLocalMemoryIAParam, 32-byte aligned. Value range: startAddr ∈ [0, 65535]. The default value is 0. For example, startAddr may be obtained by using LocalTensor.GetPhyAddr()/32.

endAddr

End address of CheckLocalMemoryIAParam, 32-byte aligned. Value range: endAddr ∈ [0, 65535]. The default value is 0.

isScalarRead

Checks scalar read access.

  • false: disabled. The default value is false.
  • true: enabled.

isScalarWrite

Checks scalar write access.

  • false: disabled. The default value is false.
  • true: enabled.

isVectorRead

Checks vector read access.

  • false: disabled. The default value is false.
  • true: enabled.

isVectorWrite

Checks vector write access.

  • false: disabled. The default value is false.
  • true: enabled.

isMteRead

Checks Mte read access.

  • false: disabled. The default value is false.
  • true: enabled.

isMteWrite

Checks Mte write access.

  • false: disabled. The default value is false.
  • true: enabled.

isEnable

Enables or disables the exception register configured by the enableBit parameter.

  • false: disabled. The default value is false.
  • true: enabled

reserved

Reserved parameter. This parameter is reserved for future functions. Developers can use the default value.

Restrictions

  • The unit of startAddr/endAddr is 32 bytes. The check range does not contain startAddr but contains endAddr, that is, (startAddr, endAddr].
  • This API needs to be reset each time it is called (by setting isEnable to false).
  • For details about the operand address alignment requirements, see General Address Alignment Restrictions.

Example

This example checks whether vector write access is within the set range of (startAddr, endAddr]. In the current example, if the vector write is within the specified range, an error (ACL_ERROR_RT_VECTOR_CORE_EXCEPTION) is reported.
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
AscendC::TPipe pipe;
AscendC::TQue<AscendC::TPosition::VECIN, 1> inQueueSrc0, inQueueSrc1;
AscendC::TQue<AscendC::TPosition::VECOUT, 1> outQueueDst
pipe.InitBuffer(inQueueSrc0, 1, 512 * sizeof(half));
pipe.InitBuffer(inQueueSrc1, 1, 512 * sizeof(half));
pipe.InitBuffer(outQueueDst, 1, 512 * sizeof(half));
AscendC::LocalTensor<half> src0Local = inQueueSrc0.DeQue<half>();
AscendC::LocalTensor<half> src1Local = inQueueSrc1.DeQue<half>();
AscendC::LocalTensor<half> dstLocal = outQueueDst.AllocTensor<half>();
AscendC::CheckLocalMemoryIA({ 0, (uint32_t)(dstLocal.GetPhyAddr() / 32),(uint32_t)((dstLocal.GetPhyAddr() + 512 * sizeof(half)) / 32), false, false, false, true, false, false,
true });