InitSpmBuffer
Applicability
Product |
Supported |
|---|---|
Atlas 350 Accelerator Card |
√ |
√ |
|
√ |
|
x |
|
√ |
|
x |
|
√ |
Function Usage
Initializes the SPM buffer.
Prototype
- Temporarily stored to workspace initialization. Specify the GM address to the SPM buffer.
1 2
template <typename T> __aicore__ inline void InitSpmBuffer(const GlobalTensor<T>& workspace, const int32_t bufferSize)
- Temporarily store data to the L1 Buffer initialization, you do not need to specify the address. The data is temporarily stored to the L1 buffer by default. You only need to pass the required SPM buffer size.
1__aicore__ inline void InitSpmBuffer(const int32_t bufferSize)
Atlas A2 training product /Atlas A2 inference product : Data cannot be temporarily stored to the L1 Buffer initialization API.Atlas A3 training product /Atlas A3 inference product : Data cannot be temporarily stored to the L1 Buffer initialization API.
Parameters
Parameter |
Input/Output |
Meaning |
|---|---|---|
workspace |
Input |
Workspace address. |
bufferSize |
Input |
Size of the SPM buffer, in bytes. |
Constraints
None
Returns
None
Examples
- Temporarily stored to workspace initialization
1 2 3 4 5
AscendC::TPipe pipe; int len = 1024; // Set the SPM buffer to 1024 pieces of data of the T type. workspace_gm.SetGlobalBuffer((__gm__ T *)usrWorkspace, len); // usrWorkspace is user-defined. auto gm = workspace_gm[AscendC::GetBlockIdx() * len]; pipe.InitSpmBuffer(gm, len * sizeof(T));
- Temporarily stored to L1 Buffer initialization
1 2 3
AscendC::TPipe pipe; int len = 1024; // Set the SPM buffer to 1024 pieces of data of the T type. pipe.InitSpmBuffer(len * sizeof(T));
Parent topic: TPipe