SetSysWorkSpace
Supported Products
|
Product |
Supported/Unsupported |
|---|---|
|
|
√ |
|
|
√ |
|
|
x |
|
|
√ |
|
|
x |
|
|
√ |
Function Usage
Sets the pointer to the system workspace, which is the workspace required by the framework. When using high-level APIs such as Matmul Kernel APIs, this API needs to be called. When the project-based operator development mode or kernel direct scheduling mode is used (the HAVE_WORKSPACE compilation option is enabled), the framework automatically sets the workspace, and you do not need to manually set it. In other scenarios, you need to call SetSysWorkSpace to set the system workspace.
Before calling this API on the kernel, call GetLibApiWorkSpaceSize on the host to obtain the size of the system workspace and set workspace size. An example is as follows.
1 2 3 4 5 6 7 8 9 10 11 12 13 |
// User-defined tiling function static ge::graphStatus TilingFunc(gert::TilingContext* context) { AddApiTiling tiling; ... size_t usrSize = 256; // Set the workspace size as required. // To use the system workspace, call GetLibApiWorkSpaceSize to obtain the size of the system workspace. auto ascendcPlatform = platform_ascendc:: PlatformAscendC(context->GetPlatformInfo()); uint32_t sysWorkspaceSize = ascendcPlatform.GetLibApiWorkSpaceSize(); size_t *currentWorkspace = context->GetWorkspaceSizes(1); // Obtain the workspace pointer through the framework. The input parameter of GetWorkspaceSizes is the number of required workspace blocks. Currently, only one board can be used. currentWorkspace[0] = usrSize + sysWorkspaceSize; // Specify the total workspace size. The total workspace space is allocated and managed by the framework. ... } |
Prototype
1
|
__aicore__ inline void SetSysWorkspace(GM_ADDR workspace) |
Parameters
|
Parameter |
Input/Output |
Description |
|---|---|---|
|
workspace |
Input |
Pointer to the workspace passed by the kernel function, including the system workspace and the workspace used by the user. |
Restrictions
None
Return Value Description
None
Example
1 2 3 4 5 6 7 8 9 10 11 |
template<typename aType, typename bType, typename cType, typename biasType> __aicore__ inline void MatmulLeakyKernel<aType, bType, cType, biasType>::Init( GM_ADDR a, GM_ADDR b, GM_ADDR bias, GM_ADDR c, GM_ADDR workspace, const TCubeTiling& tiling, float alpha) { // Initialize the fusion operator. // ... AscendC::SetSysWorkspace(workspace); if (GetSysWorkSpacePtr() == nullptr) { return; } } |