CANN/runtime:资源限制内核执行示例
1_launch_kernel_with_reslimit【免费下载链接】runtime本项目提供CANN运行时组件和维测功能组件。项目地址: https://gitcode.com/cann/runtimeDescriptionThis sample demonstrates basic flow of executing Kernel after setting Device resource limits in current process. The sample sets Cube Core resource limit, queries current limit value, and dispatches print Kernel. After running, you can see Kernel outputHello Worldlog and script verification result.Product SupportThis sample supports the following products:ProductSupportedAscend 950PR/Ascend 950DTYesAtlas A3 training series products/Atlas A3 inference series productsYesAtlas A2 training series products/Atlas A2 inference series productsYesBuild and RunDownload sample code to environment with CANN software installed, switch to sample directory.cd ${git_clone_path}/example/2_advanced_features/kernel/1_launch_kernel_with_reslimitSet environment variables.# Replace ${install_root} with CANN installation root directory, default installation at /usr/local/Ascend source ${install_root}/cann/set_env.sh export ASCEND_INSTALL_PATH${install_root}/cann # Replace ${ascend_name} with Ascend AI processor model, obtained by checking Name field using npu-smi info and removing spaces export SOC_VERSION${ascend_name} # Replace ${cmake_path} with ascendc.cmake directory, for example ${install_root}/cann/aarch64-linux/tikcpp/ascendc_kernel_cmake export ASCENDC_CMAKE_DIR${cmake_path}If environment variables are not set beforehand,run.shautomatically attempts to detectASCEND_INSTALL_PATH,ASCEND_HOME_PATH,$HOME/Ascend/cann,/usr/local/Ascend/cann,/opt/Ascend/cann,SOC_VERSION, andASCENDC_CMAKE_DIR; if automatic detection fails, set manually using the above commands.Run the following command to execute the sample.bash run.shCANN RUNTIME APIKey features and interfaces in this sample:InitializationCallaclInitinterface to initialize configuration.CallaclFinalizeinterface to deinitialize.Device ManagementCallaclrtSetDeviceinterface to specify Device for computation.CallaclrtResetDeviceForceinterface to forcibly reset current computation Device and reclaim Device resources.Stream ManagementCallaclrtCreateStreaminterface to create Stream.CallaclrtSynchronizeStreaminterface to block waiting for Stream task execution completion.CallaclrtDestroyStreamForceinterface to forcibly destroy Stream.Runtime ConfigurationCallaclrtSetDeviceResLimitinterface to set current process Device resource limit.CallaclrtGetDeviceResLimitinterface to get current process Device resource limit.Sample Output[INFO]: Current compile soc version is ... Configuring CMake... Building... [INFO] ACL initialized. [INFO] Device 0 selected. [INFO] Stream created. [INFO] Device resource limit type 0 set to 8. [INFO] Current device resource limit type 0 is 8. Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World [INFO] Run the launch_kernel_with_reslimit sample successfully. [SUCCESS]: Launch kernels under resource limits successfully.【免费下载链接】runtime本项目提供CANN运行时组件和维测功能组件。项目地址: https://gitcode.com/cann/runtime创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考