Commit a9e0f30b5401514cac875032950cd7707d7f847b

Authored by Hu Chunming
1 parent 5246117d

删除aclrtSetDevice

test/main.cpp
@@ -94,7 +94,6 @@ void dvpp_jpeg_encode(acldvppPicDesc *encodeInputDesc_, string out_file_name){ @@ -94,7 +94,6 @@ void dvpp_jpeg_encode(acldvppPicDesc *encodeInputDesc_, string out_file_name){
94 // 2.运行管理资源申请(依次申请Device、Context、Stream) 94 // 2.运行管理资源申请(依次申请Device、Context、Stream)
95 aclrtContext context_; 95 aclrtContext context_;
96 aclrtStream stream_; 96 aclrtStream stream_;
97 - aclrtSetDevice(0);  
98 aclrtCreateContext(&context_, 0); 97 aclrtCreateContext(&context_, 0);
99 aclrtCreateStream(&stream_); 98 aclrtCreateStream(&stream_);
100 99
@@ -138,7 +137,6 @@ void dvpp_jpeg_encode(acldvppPicDesc *encodeInputDesc_, string out_file_name){ @@ -138,7 +137,6 @@ void dvpp_jpeg_encode(acldvppPicDesc *encodeInputDesc_, string out_file_name){
138 // 11. 释放运行管理资源(依次释放Stream、Context、Device) 137 // 11. 释放运行管理资源(依次释放Stream、Context、Device)
139 aclrtDestroyStream(stream_); 138 aclrtDestroyStream(stream_);
140 aclrtDestroyContext(context_); 139 aclrtDestroyContext(context_);
141 - aclrtResetDevice(0);  
142 } 140 }
143 141
144 char* ReadBinFile(std::string fileName, uint32_t &fileSize) 142 char* ReadBinFile(std::string fileName, uint32_t &fileSize)
@@ -175,28 +173,23 @@ char* ReadBinFile(std::string fileName, uint32_t &fileSize) @@ -175,28 +173,23 @@ char* ReadBinFile(std::string fileName, uint32_t &fileSize)
175 void DestroyResource() 173 void DestroyResource()
176 { 174 {
177 aclError ret; 175 aclError ret;
178 - if (stream_ != nullptr) {  
179 - ret = aclrtDestroyStream(stream_);  
180 - if (ret != ACL_SUCCESS) {  
181 - ERROR_LOG("destroy stream failed"); 176 + if (context_ != nullptr) {
  177 + if (stream_ != nullptr) {
  178 + ret = aclrtDestroyStream(stream_);
  179 + if (ret != ACL_SUCCESS) {
  180 + ERROR_LOG("destroy stream failed");
  181 + }
  182 + stream_ = nullptr;
182 } 183 }
183 - stream_ = nullptr;  
184 - }  
185 - INFO_LOG("end to destroy stream"); 184 + INFO_LOG("end to destroy stream");
186 185
187 - if (context_ != nullptr) {  
188 ret = aclrtDestroyContext(context_); 186 ret = aclrtDestroyContext(context_);
189 if (ret != ACL_SUCCESS) { 187 if (ret != ACL_SUCCESS) {
190 ERROR_LOG("destroy context failed"); 188 ERROR_LOG("destroy context failed");
191 } 189 }
192 context_ = nullptr; 190 context_ = nullptr;
193 } 191 }
194 - INFO_LOG("end to destroy context");  
195 192
196 - ret = aclrtResetDevice(deviceId_);  
197 - if (ret != ACL_SUCCESS) {  
198 - ERROR_LOG("reset device failed");  
199 - }  
200 INFO_LOG("end to reset device is %d", deviceId_); 193 INFO_LOG("end to reset device is %d", deviceId_);
201 194
202 ret = aclFinalize(); 195 ret = aclFinalize();
@@ -213,7 +206,6 @@ int main(int argc, char *argv[]) @@ -213,7 +206,6 @@ int main(int argc, char *argv[])
213 aclInit(nullptr); 206 aclInit(nullptr);
214 207
215 /* 2.Run the management resource application, including Device, Context, Stream */ 208 /* 2.Run the management resource application, including Device, Context, Stream */
216 - aclrtSetDevice(deviceId_);  
217 aclrtCreateContext(&context_, deviceId_); 209 aclrtCreateContext(&context_, deviceId_);
218 aclrtCreateStream(&stream_); 210 aclrtCreateStream(&stream_);
219 aclrtGetRunMode(&runMode); 211 aclrtGetRunMode(&runMode);
test/vpc_test.cpp1
@@ -213,7 +213,6 @@ int vpc_crop(acldvppPicDesc *input){ @@ -213,7 +213,6 @@ int vpc_crop(acldvppPicDesc *input){
213 213
214 // 2.运行管理资源申请(依次申请Device、Context) 214 // 2.运行管理资源申请(依次申请Device、Context)
215 aclrtContext g_context; 215 aclrtContext g_context;
216 - aclRet = aclrtSetDevice(0);  
217 aclRet = aclrtCreateContext(&g_context, 0); 216 aclRet = aclrtCreateContext(&g_context, 0);
218 217
219 // 3.初始化媒体数据处理系统 218 // 3.初始化媒体数据处理系统
@@ -328,7 +327,6 @@ int vpc_crop(acldvppPicDesc *input){ @@ -328,7 +327,6 @@ int vpc_crop(acldvppPicDesc *input){
328 327
329 // 8. 释放运行管理资源(依次释放Context、Device) 328 // 8. 释放运行管理资源(依次释放Context、Device)
330 aclRet = aclrtDestroyContext(g_context); 329 aclRet = aclrtDestroyContext(g_context);
331 - aclRet = aclrtResetDevice(0);  
332 330
333 return 0; 331 return 0;
334 } 332 }
@@ -356,7 +354,6 @@ void dvpp_jpeg_encode(acldvppPicDesc *encodeInputDesc_, string out_file_name){ @@ -356,7 +354,6 @@ void dvpp_jpeg_encode(acldvppPicDesc *encodeInputDesc_, string out_file_name){
356 // 2.运行管理资源申请(依次申请Device、Context、Stream) 354 // 2.运行管理资源申请(依次申请Device、Context、Stream)
357 aclrtContext context_; 355 aclrtContext context_;
358 aclrtStream stream_; 356 aclrtStream stream_;
359 - aclrtSetDevice(0);  
360 aclrtCreateContext(&context_, 0); 357 aclrtCreateContext(&context_, 0);
361 aclrtCreateStream(&stream_); 358 aclrtCreateStream(&stream_);
362 359
@@ -400,7 +397,6 @@ void dvpp_jpeg_encode(acldvppPicDesc *encodeInputDesc_, string out_file_name){ @@ -400,7 +397,6 @@ void dvpp_jpeg_encode(acldvppPicDesc *encodeInputDesc_, string out_file_name){
400 // 11. 释放运行管理资源(依次释放Stream、Context、Device) 397 // 11. 释放运行管理资源(依次释放Stream、Context、Device)
401 aclrtDestroyStream(stream_); 398 aclrtDestroyStream(stream_);
402 aclrtDestroyContext(context_); 399 aclrtDestroyContext(context_);
403 - aclrtResetDevice(0);  
404 } 400 }
405 401
406 402
@@ -418,7 +414,6 @@ void dvpp_crop(acldvppPicDesc *input_pic_desc){ @@ -418,7 +414,6 @@ void dvpp_crop(acldvppPicDesc *input_pic_desc){
418 // 2.运行管理资源申请(依次申请Device、Context、Stream) 414 // 2.运行管理资源申请(依次申请Device、Context、Stream)
419 aclrtContext context_; 415 aclrtContext context_;
420 aclrtStream stream_; 416 aclrtStream stream_;
421 - ret = aclrtSetDevice(0);  
422 ret = aclrtCreateContext(&context_, 0); 417 ret = aclrtCreateContext(&context_, 0);
423 ret = aclrtCreateStream(&stream_); 418 ret = aclrtCreateStream(&stream_);
424 419
@@ -509,8 +504,6 @@ void dvpp_crop(acldvppPicDesc *input_pic_desc){ @@ -509,8 +504,6 @@ void dvpp_crop(acldvppPicDesc *input_pic_desc){
509 // 12. 释放运行管理资源(依次释放Stream、Context、Device) 504 // 12. 释放运行管理资源(依次释放Stream、Context、Device)
510 aclrtDestroyStream(stream_); 505 aclrtDestroyStream(stream_);
511 aclrtDestroyContext(context_); 506 aclrtDestroyContext(context_);
512 - aclrtResetDevice(0);  
513 -  
514 } 507 }
515 508
516 509