Calling AscendCL Single-Operator
Prerequisite
Procedure
- Go to the directory where the msOpGen script install.sh is located.
cd ${git_clone_path}/samples/operator/ascendc/0_introduction/1_add_frameworklaunch - Run the following command to generate a custom operator project and provide the operator implementation on the host and kernel:
bash install.sh -v Ascendxxxyy # xxxyy indicates the processor type.
- In the CMakePresets.json file under the ${git_clone_path}/samples/operator/ascendc/0_introduction/1_add_frameworklaunch/CustomOp directory, set the cacheVariables configuration item from "Release" to "Debug".
1 2 3 4 5
"cacheVariables": { "CMAKE_BUILD_TYPE": { "type": "STRING", "value": "Debug" },
- Compile and deploy the operator by referring to Compiling and Deploying Operators.
- Go to the directory of the msOpGen script install.sh, build the single-operator call application by referring to README, and obtain the executable file execute_add_op.
cd ${git_clone_path}/samples/operator/ascendc/0_introduction/1_add_frameworklaunch/AclNNInvocation - Import the operator dynamic loading path.
Import the path of the .o file output in the build_out directory on the kernel after the custom operator project is compiled to environment variables.
export LAUNCH_KERNEL_PATH=/ {path_to_kernel} / kernel_name.o //{path_to_kernel} indicates the path of the operator binary file *.o generated after the operator kernel is compiled. Replace it with the actual path.
Multiple .o files may be generated for multiple data types of the operator on the kernel side. Select the .o file called in the example in Step 4 for import.
- Use msDebug to load the single-operator executable file execute_add_op obtained in Step 5.
export LD_LIBRARY_PATH=$ASCEND_HOME_PATH/opp/vendors/customize/op_api/lib:$LD_LIBRARY_PATH cd AclNNInvocation/output msdebug execute_add_op (msdebug) target create "execute_add_op" Current executable set to '/home/AclNNInvocation/output/execute_add_op' (aarch64). (msdebug)
- Set a breakpoint.
b add_custom.cpp:55
- Run the operator program and wait until the breakpoint is hit.
(msdebug) r Process 1385976 launched: '$home/shelltest/test/samples/operator/ascendc/0_introduction/1_add_frameworklaunch/AclNNInvocationNaive/build/execute_add_op' (aarch64) [Launch of Kernel anonymous on Device 0] Process 1385976 stopped [Switching to focus on Kernel anonymous, CoreId 24, Type aiv] * thread #1, name = 'execute_add_op', stop reason = breakpoint 1.1 frame #0: 0x0000000000001564 AddCustom_1e04ee05ab491cc5ae9c3d5c9ee8950b.o`KernelAdd::Compute(this=0x000000000028f8a8, progress=0) (.vector) at add_custom.cpp:55:19 52 LocalTensor<DTYPE_Y> yLocal = inQueueY.DeQue<DTYPE_Y>(); 53 LocalTensor<DTYPE_Z> zLocal = outQueueZ.AllocTensor<DTYPE_Z>(); 54 Add(zLocal, xLocal, yLocal, this->tileLength); -> 55 outQueueZ.EnQue<DTYPE_Z>(zLocal); 56 inQueueX.FreeTensor(xLocal); 57 inQueueY.FreeTensor(yLocal); 58 } (msdebug)
For details about the subsequent debugging process, see Importing Debugging Information, Printing Memory and Variables, and Switching Cores.
Parent topic: Typical Cases