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