SetNeedAtomic

Description

Sets whether the framework is required to perform the atomic clean operation to ensure that the output memory has been initialized before the operator kernel is executed.

Atomic clean refers to the process of initializing the output memory on the global memory (GM) before operator execution to ensure the correctness of operations such as accumulation, maximum value calculation, and minimum value calculation.

  • Before performing accumulation, clear related values in the GM.
  • Before calculating the maximum value, initialize the related values in the GM to the minimum value of the corresponding data type.
  • Before calculating the minimum value, initialize the related values in the GM to the maximum value of the corresponding data type.

The operator can be initialized by itself or by setting this API to enable the framework to automatically insert for operator clearup. Using the framework for initialization can take advantage of the optimization capabilities of the framework, such as centralized allocation of clear addresses in graph mode, thereby improving the efficiency of resource management and allocation.

The SetNeedAtomic API is used together with InitValue. InitValue is used to configure the outputs to be initialized and the initial values.

Prototype

ge::graphStatus SetNeedAtomic(const bool atomic)

Parameters

Parameter

Input/Output

Description

atomic

Input

  • true: Atomic clean is required.
  • false: Atomic clean is not required.

Returns

ge::GRAPH_SUCCESS on success.

For details about the definition of graphStatus, see ge::graphStatus.

Restrictions

SetNeedAtomic and InitValue must be used together. Otherwise, the initialization does not take effect.

Example

ge::graphStatus Tiling4XXX(TilingContext* context) {
  auto ret = context->SetNeedAtomic(true);
  // ...
}