
3_d2h_sync_memory_copy【免费下载链接】runtime本项目提供CANN运行时组件和维测功能组件。项目地址: https://gitcode.com/cann/runtimeDescriptionThis sample demonstrates synchronous memory copy from Device to Host using theaclrtMemcpyAPI for data transfer.Product SupportThis sample supports the following products:ProductSupportedAscend 950PR/Ascend 950DT√Atlas A3 Training Series Products/Atlas A3 Inference Series Products√Atlas A2 Training Series Products/Atlas A2 Inference Series Products√Build and RunDownload the sample code to an environment where CANN software is installed, and switch to the sample directory.cd ${git_clone_path}/example/1_basic_features/memory/3_d2h_sync_memory_copySet environment variables.# Replace ${install_root} with the CANN installation root directory, which is installed in /usr/local/Ascend by default source ${install_root}/cann/set_env.sh export ASCEND_INSTALL_PATH${install_root}/cann # Set SOC_VERSION and ASCENDC_CMAKE_DIR # -SOC_VERSION: The model of the Ascend AI processor, 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.shRun the following command to execute the sample.bash run.shCANN RUNTIME APIThe key functionality points and their corresponding APIs in this sample are as follows:InitializationCallaclInitto perform initialization configuration.CallaclFinalizeto perform deinitialization.Device ManagementCallaclrtSetDeviceto specify the Device for computation.CallaclrtResetDeviceForceto forcibly reset the current Device and reclaim Device resources.Stream ManagementCallaclrtCreateStreamto create a Stream.CallaclrtDestroyStreamForceto forcibly destroy a Stream and discard all tasks.Memory ManagementCallaclrtMallocHostto allocate memory on the Host.CallaclrtMallocto allocate memory on the Device.CallaclrtFreeHostto free memory on the Host.CallaclrtFreeto free memory on the Device.Data TransferCallaclrtMemcpyto implement Device-to-Host data transfer using memory copy.Sample Output[INFO] Allocate memory on the host memory 0x... successfully [INFO] Allocate memory on the device memory 0x... successfully [INFO] Write the data 123 to the virtual memory 0x... [INFO] Copy memory from memory 0x... to memory 0x... [INFO] Destination data: 123 CANN Version: 1.0.0, TimeStamp: ... Source data: 123【免费下载链接】runtime本项目提供CANN运行时组件和维测功能组件。项目地址: https://gitcode.com/cann/runtime创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考