The computation algorithm of an operator is implemented through Ascend C APIs, and the loading and call of the operator are implemented through runtime APIs. This section describes the common runtime APIs used for running Ascend C operators in the CANN software stack based on kernel function call. For more information about runtime APIs, see Runtime API Reference.

Kernel loading and execution can also be implemented through binary loading, which is the bottom-layer API implementation. The kernel launch symbol <<<...>>> encapsulates the bottom-layer APIs. To use an operator, you need to compile the operator source file into a binary .o file using BiSheng command lines, and then call the kernel loading and execution APIs such as aclrtLaunchKernelWithConfig to call the operator.
The kernel function is called asynchronously. After the kernel function is called, the control right is returned to the host immediately. You can call aclrtSynchronizeStream to force the host program to wait until all kernel functions are executed.
1
|
aclError aclrtSynchronizeStream(aclrtStream stream); |