BLAS Common APIs
Operator Usage Description
To use a BLAS operator, you need to create a handle, call the plan API of the corresponding operator to initialize the operator configuration corresponding to the handle and bind the handle, call the BLAS common API asdBlasGetWorkspaceSize to obtain the workspace size required for computation and the executor that contains the operator calculation process, call asdBlasSetWorkspace to set the workspace for the corresponding plan, and call the BLAS operator API to perform calculation. After the calculation is complete, destroy the plan to prevent memory leakage. For details about the calling example, see Operator Call Example.
Common API Description
asdBlasCreate
Function: This API is used to create a globally unique handle.
Prototype: AspbStatus asdBlasCreate(asdBlasHandle &handle)
Parameter description:
Parameter |
Input/Output |
Type |
Description |
|---|---|---|---|
handle |
Input |
asdBlasHandle |
Handle of the asdBlasCreate API. |
asdBlasSetStream
Function: This API is used to bind the stream created using runtime to a specific plan instance.
Prototype: AspbStatus asdBlasSetStream(asdBlasHandle handle, void *stream)
Parameter description:
Parameter |
Input/Output |
Type |
Description |
|---|---|---|---|
handle |
Input |
asdBlasHandle |
Handle of the asdBlasSetStream API. |
stream |
Input |
void * |
Pointer to the stream object. |
asdBlasDestroy
Description: This API is used to destroy a created plan and release the resources applied for the plan.
Prototype: AspbStatus asdBlasDestroy(asdBlasHandle handle)
Parameter description:
Parameter |
Input/Output |
Type |
Description |
|---|---|---|---|
handle |
Input |
asdBlasHandle |
Handle of the asdBlasDestroy API. |
asdBlasSetWorkspace
Function: This API is used to set a workspace for a plan.
Prototype: AspbStatus asdBlasSetWorkspace(asdBlasHandle handle, void *workSpace);
Parameter description:
Parameter |
Input/Output |
Type |
Description |
|---|---|---|---|
handle |
Input |
asdBlasHandle |
Handle of the asdBlasSetWorkspace API. |
workSpace |
Input |
void * |
Pointer to a variable that stores the size of the required workspace. |
asdBlasSynchronize
Function: This API is used to execute the synchronization waiting operator.
Prototype: AspbStatus asdBlasSynchronize(asdBlasHandle handle)
Parameter description:
Parameter |
Input/Output |
Type |
Description |
|---|---|---|---|
handle |
Input |
asdBlasHandle |
Handle of the asdBlasSynchronize API. |
asdBlasGetWorkspaceSize
Function: This API is used to compute the size of the required workspace and the executor that contains the operator computation process.
Prototype: AspbStatus asdBlasGetWorkspaceSize(asdBlasHandle handle, size_t &workspaceSize);
Parameter description:
Parameter |
Input/Output |
Type |
Description |
|---|---|---|---|
handle |
Input |
asdBlasHandle |
Handle of the asdBlasGetWorkspaceSize API. |
workspaceSize |
Input |
size_t |
Size of the required workspace. |