From a9e0f30b5401514cac875032950cd7707d7f847b Mon Sep 17 00:00:00 2001 From: cmhu <2657262686@qq.com> Date: Fri, 23 Aug 2024 16:38:50 +0800 Subject: [PATCH] 删除aclrtSetDevice --- test/main.cpp | 24 ++++++++---------------- test/vpc_test.cpp1 | 7 ------- 2 files changed, 8 insertions(+), 23 deletions(-) diff --git a/test/main.cpp b/test/main.cpp index f995104..743a93a 100755 --- a/test/main.cpp +++ b/test/main.cpp @@ -94,7 +94,6 @@ void dvpp_jpeg_encode(acldvppPicDesc *encodeInputDesc_, string out_file_name){ // 2.运行管理资源申请(依次申请Device、Context、Stream) aclrtContext context_; aclrtStream stream_; - aclrtSetDevice(0); aclrtCreateContext(&context_, 0); aclrtCreateStream(&stream_); @@ -138,7 +137,6 @@ void dvpp_jpeg_encode(acldvppPicDesc *encodeInputDesc_, string out_file_name){ // 11. 释放运行管理资源(依次释放Stream、Context、Device) aclrtDestroyStream(stream_); aclrtDestroyContext(context_); - aclrtResetDevice(0); } char* ReadBinFile(std::string fileName, uint32_t &fileSize) @@ -175,28 +173,23 @@ char* ReadBinFile(std::string fileName, uint32_t &fileSize) void DestroyResource() { aclError ret; - if (stream_ != nullptr) { - ret = aclrtDestroyStream(stream_); - if (ret != ACL_SUCCESS) { - ERROR_LOG("destroy stream failed"); + if (context_ != nullptr) { + if (stream_ != nullptr) { + ret = aclrtDestroyStream(stream_); + if (ret != ACL_SUCCESS) { + ERROR_LOG("destroy stream failed"); + } + stream_ = nullptr; } - stream_ = nullptr; - } - INFO_LOG("end to destroy stream"); + INFO_LOG("end to destroy stream"); - if (context_ != nullptr) { ret = aclrtDestroyContext(context_); if (ret != ACL_SUCCESS) { ERROR_LOG("destroy context failed"); } context_ = nullptr; } - INFO_LOG("end to destroy context"); - ret = aclrtResetDevice(deviceId_); - if (ret != ACL_SUCCESS) { - ERROR_LOG("reset device failed"); - } INFO_LOG("end to reset device is %d", deviceId_); ret = aclFinalize(); @@ -213,7 +206,6 @@ int main(int argc, char *argv[]) aclInit(nullptr); /* 2.Run the management resource application, including Device, Context, Stream */ - aclrtSetDevice(deviceId_); aclrtCreateContext(&context_, deviceId_); aclrtCreateStream(&stream_); aclrtGetRunMode(&runMode); diff --git a/test/vpc_test.cpp1 b/test/vpc_test.cpp1 index 040ccef..cea5958 100755 --- a/test/vpc_test.cpp1 +++ b/test/vpc_test.cpp1 @@ -213,7 +213,6 @@ int vpc_crop(acldvppPicDesc *input){ // 2.运行管理资源申请(依次申请Device、Context) aclrtContext g_context; - aclRet = aclrtSetDevice(0); aclRet = aclrtCreateContext(&g_context, 0); // 3.初始化媒体数据处理系统 @@ -328,7 +327,6 @@ int vpc_crop(acldvppPicDesc *input){ // 8. 释放运行管理资源(依次释放Context、Device) aclRet = aclrtDestroyContext(g_context); - aclRet = aclrtResetDevice(0); return 0; } @@ -356,7 +354,6 @@ void dvpp_jpeg_encode(acldvppPicDesc *encodeInputDesc_, string out_file_name){ // 2.运行管理资源申请(依次申请Device、Context、Stream) aclrtContext context_; aclrtStream stream_; - aclrtSetDevice(0); aclrtCreateContext(&context_, 0); aclrtCreateStream(&stream_); @@ -400,7 +397,6 @@ void dvpp_jpeg_encode(acldvppPicDesc *encodeInputDesc_, string out_file_name){ // 11. 释放运行管理资源(依次释放Stream、Context、Device) aclrtDestroyStream(stream_); aclrtDestroyContext(context_); - aclrtResetDevice(0); } @@ -418,7 +414,6 @@ void dvpp_crop(acldvppPicDesc *input_pic_desc){ // 2.运行管理资源申请(依次申请Device、Context、Stream) aclrtContext context_; aclrtStream stream_; - ret = aclrtSetDevice(0); ret = aclrtCreateContext(&context_, 0); ret = aclrtCreateStream(&stream_); @@ -509,8 +504,6 @@ void dvpp_crop(acldvppPicDesc *input_pic_desc){ // 12. 释放运行管理资源(依次释放Stream、Context、Device) aclrtDestroyStream(stream_); aclrtDestroyContext(context_); - aclrtResetDevice(0); - } -- libgit2 0.21.4