InitSpmBuffer
Applicability
Product |
Supported/Unsupported |
|---|---|
√ |
|
√ |
|
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 products /Atlas A2 inference products : Data cannot be temporarily stored to the L1 Buffer initialization API.Atlas A3 training products /Atlas A3 inference products : 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. |
Restrictions
None
Return Value Description
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