InitSpmBuffer
Function Usage
Initializes the SPM buffer.
For details about the SPM buffer and its usage example, see 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 in the required SPM buffer size.
1__aicore__ inline void InitSpmBuffer(const int32_t bufferSize)
Parameters
|
Parameter |
Input/Output |
Meaning |
|---|---|---|
|
workspace |
Input |
Workspace address |
|
bufferSize |
Input |
Size of the SPM buffer, in bytes |
Availability
Precautions
None
Returns
None
Example
- 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: SPM Buffer