SetCtrlSpr(ISASI)
Applicability
Product |
Supported |
|---|---|
Atlas 350 Accelerator Card |
√ |
x |
|
x |
|
x |
|
x |
|
x |
|
x |
Function Usage
Sets specific bits of the CTRL register (control register).
Prototype
template <int8_t startBit, int8_t endBit> __aicore__ static inline void SetCtrlSpr(int64_t value)
Parameters
Parameter |
Description |
|---|---|
startBit |
Start bit index. |
endBit |
End bit index. |
Parameter |
Input/Output |
Description |
|---|---|---|
value |
Input |
New value set for the start and end bits. |
CTRL Register Bit |
Function |
Default Value |
Related API |
|---|---|---|---|
CTRL[8:6] |
Controls the enabling of atomic operations and data type selection when data is moved from L0C Buffer, Unified Buffer, or L1 Buffer to the global memory.
|
3'b000 |
N/A |
CTRL[10:9] |
Controls the atomic operation type. This control bit is valid only when atomic operations are enabled via CTRL[8:6].
|
2'b00 |
N/A |
CTRL[45] |
Controls the data type when data from the left and right matrices is used for MMAD computation.
|
1'b0 |
N/A |
CTRL[48] |
Controls the saturation mode during float computation and precision conversion. This control bit is valid only when CTRL[60] is enabled.
This control bit supports only the following data types:
|
1'b0 |
Related APIs:
Constraints:
|
CTRL[50] |
Controls the NAN saturation mode during float precision conversion. This control bit is valid only when CTRL[48] is set to the saturation mode. 1'b0: The NAN output is converted to 0.0. 1'b1: The NAN output remains NAN. This control bit supports only the following data types: fp8_e8m0_t, fp8_e5m2_t, and fp8_e4m3fn_t |
1'b0 |
Precision conversion instruction API (The data type constraints must be met.) |
CTRL[53] |
Controls the saturation mode of integer computation instructions. 1'b0: truncation mode. The overflow value is truncated based on the number of bits of the target data type, with the lower bits retained and the upper bits discarded. 1'b1: saturation mode. The overflow value is saturated to ±MAX. |
1'b0 |
Vector computation API (The input and output data are both of the integer type.) |
CTRL[59] |
Controls the saturation mode for float-to-integer or integer-to-integer precision conversion. This control bit is valid only when CTRL[60] is enabled. 1'b0: saturation mode. The overflow value is saturated to ±MAX. 1'b1: truncation mode. The overflow value is truncated based on the number of bits of the target data type, with the lower bits retained and the upper bits discarded. |
1'b0 |
Precision conversion instruction API |
CTRL[60] |
Controls the global effective mode of the saturation mode. 1'b0: single-instruction saturation 1'b1: global saturation |
1'b1 |
This control bit can be used together with the Reg vector computation API Cast or with CTRL[48] and CTRL[59]. For details about the configuration, see Table 4. |
Global Enable Bit |
Control Bit |
Function |
|---|---|---|
CTRL[60] = 1'b0 |
In the trait template parameter of the Reg vector computation API Cast, set satMode to SatMode::NO_SAT. |
Single-instruction non-saturation mode |
In the trait template parameter of the Reg vector computation API Cast, set satMode to SatMode::SAT. |
Single-instruction saturation mode |
|
CTRL[60] = 1'b1 |
CTRL[48] = 1'b1 |
Global non-saturation mode (float computation and float precision conversion) |
CTRL[48] = 1'b0 |
Global saturation mode (float computation and float precision conversion) |
|
CTRL[59] = 1'b1 |
Global non-saturation mode (float-to-integer or integer-to-integer precision conversion) |
|
CTRL[59] = 1'b0 |
Global saturation mode (float-to-integer or integer-to-integer precision conversion) |
Returns
None
Constraints
- Only the CTRL[8:6], CTRL[10:9], CTRL[45], CTRL[48], CTRL[50], CTRL[53], CTRL[59], and CTRL[60] bits are supported.
- Atomic operation APIs have been encapsulated for setting CTRL[8:6] and CTRL[10:9]. You are advised to use these APIs.
Examples
- Example of configuring the global non-saturation mode for the half type in atomic operations:
AscendC::SetCtrlSpr<6, 8>(2); AscendC::SetAtomicAdd<half>(); AscendC::DataCacheCleanAndInvalid<half, AscendC::CacheLine::ENTIRE_DATA_CACHE, AscendC::DcciDst::CACHELINE_ATOMIC>(dstTensor); AscendC::SetCtrlSpr<48, 48>(1); ...