CANN/runtime事件状态查询示例
2026/6/25 6:53:32 网站建设 项目流程

0_event_status

【免费下载链接】runtime本项目提供CANN运行时组件和维测功能组件。项目地址: https://gitcode.com/cann/runtime

Description

This sample demonstrates Event status query flow after creation, after recording, and after synchronization.

Product Support

This sample supports the following products:

ProductSupported
Ascend 950PR/Ascend 950DTYes
Atlas A3 training series products/Atlas A3 inference series productsYes
Atlas A2 training series products/Atlas A2 inference series productsYes

Compile and Run

  1. Download the sample code to the environment where CANN software is installed. Switch to the sample directory.
cd ${git_clone_path}/example/1_basic_features/event/0_event_status
  1. Set environment variables.
# Replace ${install_root} with the CANN installation root directory. The default installation is in the `/usr/local/Ascend` directory. source ${install_root}/cann/set_env.sh export ASCEND_INSTALL_PATH=${install_root}/cann # Set SOC_VERSION and ASCENDC_CMAKE_DIR # -SOC_VERSION: Ascend AI processor model, such as Ascend910_9362, Ascend910B2, and so on # -ASCENDC_CMAKE_DIR: The sample involves calling AscendC operators. Configure the AscendC compiler ascendc.cmake path, such as /usr/local/Ascend/cann/x86_64-linux/tikcpp/ascendc_kernel_cmake source ${git_clone_path}/example/set_sample_env.sh
  1. Run the following command to execute the sample.
bash run.sh

CANN RUNTIME API

The key functionality points and their key interfaces involved in this sample are as follows:

  • Initialization
    • CallaclInitinterface for initialization configuration.
    • CallaclFinalizeinterface for deinitialization.
  • Device Management
    • CallaclrtSetDeviceinterface to specify the Device for computation.
    • CallaclrtResetDeviceForceinterface to forcefully reset the current computation Device and reclaim Device resources.
  • Context Management
    • CallaclrtCreateContextinterface to create Context.
    • CallaclrtDestroyContextinterface to destroy Context.
  • Stream Management
    • CallaclrtCreateStreaminterface to create Stream.
    • CallaclrtSetStreamFailureModeinterface to set the operation when Stream execution encounters errors. Default is continue on error, can be set to stop on error.
    • CallaclrtDestroyStreamForceinterface to forcefully destroy Stream.
  • Event Management
    • CallaclrtCreateEventinterface to create Event.
    • CallaclrtRecordEventinterface to record Event.
    • CallaclrtSynchronizeEventinterface to block and wait for Event to complete.
    • CallaclrtQueryEventStatusinterface to query Event status.
    • CallaclrtDestroyEventinterface to destroy Event.
  • Memory Management
    • CallaclrtMallocinterface to allocate memory on Device.
    • CallaclrtFreeinterface to release memory on Device.
  • Data Transfer
    • CallaclrtMemcpyinterface to implement data transfer through memory copy.

Sample Output

[INFO] After create event, current event status is 0. [INFO] Applied resource successfully, beging assigning task. [INFO] Begin a long task. [INFO] 0 is incompleted, 1 is completed. [INFO] After record but before synchronize, current event status is 0. [INFO] After synchronize, current event status is 1. [INFO] The answer is 1. [INFO] Resource cleanup completed.

【免费下载链接】runtime本项目提供CANN运行时组件和维测功能组件。项目地址: https://gitcode.com/cann/runtime

创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考

需要专业的网站建设服务?

联系我们获取免费的网站建设咨询和方案报价,让我们帮助您实现业务目标

立即咨询