Commit 1680c040e3b8b0e45268f4d82612d3da1196b63f
1 parent
d17eebb2
setDevice改用Context
Showing
9 changed files
with
38 additions
and
60 deletions
src/ai_platform/MultiSourceProcess.cpp
@@ -818,7 +818,6 @@ int CMultiSourceProcess::algorthim_process_thread(){ | @@ -818,7 +818,6 @@ int CMultiSourceProcess::algorthim_process_thread(){ | ||
818 | } | 818 | } |
819 | 819 | ||
820 | aclrtDestroyContext(ctx); | 820 | aclrtDestroyContext(ctx); |
821 | - aclrtResetDevice(m_devId); | ||
822 | LOG_INFO("algorthim_process_thread exit."); | 821 | LOG_INFO("algorthim_process_thread exit."); |
823 | 822 | ||
824 | return 0; | 823 | return 0; |
src/decoder/dvpp/DvppDecoder.cpp
@@ -332,6 +332,12 @@ int DvppDecoder::getVdecType(int videoType, int profile) | @@ -332,6 +332,12 @@ int DvppDecoder::getVdecType(int videoType, int profile) | ||
332 | post_decoded_cbk = cfg.post_decoded_cbk; | 332 | post_decoded_cbk = cfg.post_decoded_cbk; |
333 | 333 | ||
334 | do{ | 334 | do{ |
335 | + aclError ret = aclrtCreateContext(&m_context, m_dvpp_deviceId); | ||
336 | + if (ret != ACL_ERROR_NONE) { | ||
337 | + LOG_ERROR("[{}]-aclrtCreateContext failed !", m_dec_name); | ||
338 | + break; | ||
339 | + } | ||
340 | + | ||
335 | // DvppSourceManager 创建时包含 aclInit,析构时包含 aclFinalize | 341 | // DvppSourceManager 创建时包含 aclInit,析构时包含 aclFinalize |
336 | DvppSourceManager* pSrcMgr = DvppSourceManager::getInstance(); | 342 | DvppSourceManager* pSrcMgr = DvppSourceManager::getInstance(); |
337 | m_dvpp_channel = pSrcMgr->getChannel(m_dvpp_deviceId); | 343 | m_dvpp_channel = pSrcMgr->getChannel(m_dvpp_deviceId); |
@@ -434,9 +440,9 @@ static int snap_count = 0; | @@ -434,9 +440,9 @@ static int snap_count = 0; | ||
434 | 440 | ||
435 | DeviceMemory* DvppDecoder::snapshot(){ | 441 | DeviceMemory* DvppDecoder::snapshot(){ |
436 | 442 | ||
437 | - aclError ret = aclrtSetDevice(m_dvpp_deviceId); | 443 | + int ret = aclrtSetCurrentContext(m_context); |
438 | if(ret != ACL_ERROR_NONE){ | 444 | if(ret != ACL_ERROR_NONE){ |
439 | - LOG_ERROR("[{}]-aclrtSetDevice failed !", m_dec_name); | 445 | + LOG_ERROR("[{}]- aclrtSetCurrentContext failed", m_dec_name); |
440 | return nullptr; | 446 | return nullptr; |
441 | } | 447 | } |
442 | 448 | ||
@@ -465,12 +471,6 @@ DeviceMemory* DvppDecoder::snapshot(){ | @@ -465,12 +471,6 @@ DeviceMemory* DvppDecoder::snapshot(){ | ||
465 | break; | 471 | break; |
466 | } | 472 | } |
467 | 473 | ||
468 | - ret = aclrtResetDevice(m_dvpp_deviceId); | ||
469 | - if(ret != ACL_ERROR_NONE){ | ||
470 | - LOG_ERROR("[{}]-aclrtResetDevice failed !", m_dec_name); | ||
471 | - return nullptr; | ||
472 | - } | ||
473 | - | ||
474 | return snapshot_mem; | 474 | return snapshot_mem; |
475 | } | 475 | } |
476 | 476 | ||
@@ -515,11 +515,15 @@ void DvppDecoder::read_thread() { | @@ -515,11 +515,15 @@ void DvppDecoder::read_thread() { | ||
515 | this | 515 | this |
516 | ); | 516 | ); |
517 | 517 | ||
518 | - CHECK_AND_RETURN_NOVALUE(aclrtSetDevice(m_dvpp_deviceId), "aclrtSetDevice failed!"); | ||
519 | - | ||
520 | aclvdecChannelDesc *vdecChannelDesc = nullptr; | 518 | aclvdecChannelDesc *vdecChannelDesc = nullptr; |
521 | 519 | ||
522 | do { | 520 | do { |
521 | + int ret = aclrtSetCurrentContext(m_context); | ||
522 | + if(ret != ACL_ERROR_NONE){ | ||
523 | + LOG_ERROR("[{}]- aclrtSetCurrentContext failed", m_dec_name); | ||
524 | + break; | ||
525 | + } | ||
526 | + | ||
523 | vdecChannelDesc = aclvdecCreateChannelDesc(); | 527 | vdecChannelDesc = aclvdecCreateChannelDesc(); |
524 | if (vdecChannelDesc == nullptr) { | 528 | if (vdecChannelDesc == nullptr) { |
525 | LOG_ERROR("[{}]- aclvdecCreateChannelDesc failed", m_dec_name); | 529 | LOG_ERROR("[{}]- aclvdecCreateChannelDesc failed", m_dec_name); |
@@ -639,8 +643,6 @@ void DvppDecoder::read_thread() { | @@ -639,8 +643,6 @@ void DvppDecoder::read_thread() { | ||
639 | vdecChannelDesc = nullptr; | 643 | vdecChannelDesc = nullptr; |
640 | } | 644 | } |
641 | 645 | ||
642 | - CHECK_NOT_RETURN(aclrtResetDevice(m_dvpp_deviceId), "aclrtResetDevice failed"); | ||
643 | - | ||
644 | m_bRunning=false; | 646 | m_bRunning=false; |
645 | 647 | ||
646 | m_bExitReportThd = true; | 648 | m_bExitReportThd = true; |
@@ -783,7 +785,7 @@ void DvppDecoder::doVdppVdecCallBack(acldvppStreamDesc *input, acldvppPicDesc *o | @@ -783,7 +785,7 @@ void DvppDecoder::doVdppVdecCallBack(acldvppStreamDesc *input, acldvppPicDesc *o | ||
783 | 785 | ||
784 | m_out_count++; | 786 | m_out_count++; |
785 | 787 | ||
786 | - CHECK_AND_RETURN_NOVALUE(aclrtSetDevice(m_dvpp_deviceId), "aclrtSetDevice failed"); | 788 | + CHECK_AND_RETURN_NOVALUE(aclrtSetCurrentContext(m_context), "aclrtSetCurrentContext failed"); |
787 | 789 | ||
788 | void *inputDataDev = acldvppGetStreamDescData(input); | 790 | void *inputDataDev = acldvppGetStreamDescData(input); |
789 | acldvppFree(inputDataDev); | 791 | acldvppFree(inputDataDev); |
@@ -857,8 +859,6 @@ void DvppDecoder::doVdppVdecCallBack(acldvppStreamDesc *input, acldvppPicDesc *o | @@ -857,8 +859,6 @@ void DvppDecoder::doVdppVdecCallBack(acldvppStreamDesc *input, acldvppPicDesc *o | ||
857 | 859 | ||
858 | CHECK_NOT_RETURN(acldvppDestroyStreamDesc(input), "acldvppDestroyStreamDesc failed"); | 860 | CHECK_NOT_RETURN(acldvppDestroyStreamDesc(input), "acldvppDestroyStreamDesc failed"); |
859 | CHECK_NOT_RETURN(acldvppDestroyPicDesc(output), "acldvppDestroyPicDesc failed"); | 861 | CHECK_NOT_RETURN(acldvppDestroyPicDesc(output), "acldvppDestroyPicDesc failed"); |
860 | - | ||
861 | - CHECK_NOT_RETURN(aclrtResetDevice(m_dvpp_deviceId), "aclrtResetDevice failed"); | ||
862 | } | 862 | } |
863 | 863 | ||
864 | bool DvppDecoder::sendVdecEos(aclvdecChannelDesc *vdecChannelDesc) { | 864 | bool DvppDecoder::sendVdecEos(aclvdecChannelDesc *vdecChannelDesc) { |
@@ -930,6 +930,14 @@ void DvppDecoder::display_thread() { | @@ -930,6 +930,14 @@ void DvppDecoder::display_thread() { | ||
930 | } | 930 | } |
931 | 931 | ||
932 | void DvppDecoder::release_dvpp(){ | 932 | void DvppDecoder::release_dvpp(){ |
933 | + if(m_context){ | ||
934 | + aclError ret = aclrtDestroyContext(m_context); | ||
935 | + if(ret != ACL_ERROR_NONE){ | ||
936 | + LOG_ERROR("[{}]- aclrtDestroyContext failed !", m_dec_name); | ||
937 | + } | ||
938 | + m_context = nullptr; | ||
939 | + } | ||
940 | + | ||
933 | if(m_dvpp_channel >= 0){ | 941 | if(m_dvpp_channel >= 0){ |
934 | DvppSourceManager* pSrcMgr = DvppSourceManager::getInstance(); | 942 | DvppSourceManager* pSrcMgr = DvppSourceManager::getInstance(); |
935 | pSrcMgr->releaseChannel(m_dvpp_deviceId, m_dvpp_channel); | 943 | pSrcMgr->releaseChannel(m_dvpp_deviceId, m_dvpp_channel); |
src/decoder/dvpp/DvppDecoder.h
@@ -117,6 +117,7 @@ private: | @@ -117,6 +117,7 @@ private: | ||
117 | // 解码 | 117 | // 解码 |
118 | int m_dvpp_deviceId {-1}; | 118 | int m_dvpp_deviceId {-1}; |
119 | int m_dvpp_channel {-1}; | 119 | int m_dvpp_channel {-1}; |
120 | + aclrtContext m_context{nullptr}; | ||
120 | acldvppStreamFormat m_enType; | 121 | acldvppStreamFormat m_enType; |
121 | 122 | ||
122 | const void * m_postDecArg {nullptr}; | 123 | const void * m_postDecArg {nullptr}; |
src/decoder/dvpp/DvppStreamDecoder.cpp
@@ -120,7 +120,7 @@ int DvppStreamDecoder::getVdecType(int videoType) | @@ -120,7 +120,7 @@ int DvppStreamDecoder::getVdecType(int videoType) | ||
120 | void DvppStreamDecoder::doProcessReport(){ | 120 | void DvppStreamDecoder::doProcessReport(){ |
121 | 121 | ||
122 | aclrtContext ctx; | 122 | aclrtContext ctx; |
123 | - ret = aclrtCreateContext(&ctx, m_deviceId); | 123 | + aclError ret = aclrtCreateContext(&ctx, m_deviceId); |
124 | if (ret != ACL_ERROR_NONE) { | 124 | if (ret != ACL_ERROR_NONE) { |
125 | // cout << "aclrtCreateContext failed " << endl; | 125 | // cout << "aclrtCreateContext failed " << endl; |
126 | LOG_ERROR("aclrtCreateContext failed !"); | 126 | LOG_ERROR("aclrtCreateContext failed !"); |
@@ -152,7 +152,7 @@ void DvppStreamDecoder::doVdppVdecCallBack(acldvppStreamDesc *input, acldvppPicD | @@ -152,7 +152,7 @@ void DvppStreamDecoder::doVdppVdecCallBack(acldvppStreamDesc *input, acldvppPicD | ||
152 | 152 | ||
153 | m_out_count++; | 153 | m_out_count++; |
154 | 154 | ||
155 | - CHECK_AND_RETURN_NOVALUE(aclrtSetDevice(m_dvpp_deviceId), "aclrtSetDevice failed"); | 155 | + CHECK_AND_RETURN_NOVALUE(aclrtSetDevice(m_deviceId), "aclrtSetDevice failed"); |
156 | 156 | ||
157 | void *inputDataDev = acldvppGetStreamDescData(input); | 157 | void *inputDataDev = acldvppGetStreamDescData(input); |
158 | acldvppFree(inputDataDev); | 158 | acldvppFree(inputDataDev); |
@@ -238,7 +238,7 @@ void DvppStreamDecoder::doVdppVdecCallBack(acldvppStreamDesc *input, acldvppPicD | @@ -238,7 +238,7 @@ void DvppStreamDecoder::doVdppVdecCallBack(acldvppStreamDesc *input, acldvppPicD | ||
238 | CHECK_NOT_RETURN(acldvppDestroyStreamDesc(input), "acldvppDestroyStreamDesc failed"); | 238 | CHECK_NOT_RETURN(acldvppDestroyStreamDesc(input), "acldvppDestroyStreamDesc failed"); |
239 | CHECK_NOT_RETURN(acldvppDestroyPicDesc(output), "acldvppDestroyPicDesc failed"); | 239 | CHECK_NOT_RETURN(acldvppDestroyPicDesc(output), "acldvppDestroyPicDesc failed"); |
240 | 240 | ||
241 | - CHECK_NOT_RETURN(aclrtResetDevice(m_dvpp_deviceId), "aclrtResetDevice failed"); | 241 | + CHECK_NOT_RETURN(aclrtResetDevice(m_deviceId), "aclrtResetDevice failed"); |
242 | } | 242 | } |
243 | 243 | ||
244 | DvppDataMemory* DvppStreamDecoder::GetFrame() { | 244 | DvppDataMemory* DvppStreamDecoder::GetFrame() { |
src/util/JpegUtil.cpp
@@ -12,9 +12,7 @@ int JpegUtil::jpeg_init(int32_t devId){ | @@ -12,9 +12,7 @@ int JpegUtil::jpeg_init(int32_t devId){ | ||
12 | 12 | ||
13 | aclError ret; | 13 | aclError ret; |
14 | /* 2.Run the management resource application, including Device, Context, Stream */ | 14 | /* 2.Run the management resource application, including Device, Context, Stream */ |
15 | - aclrtSetDevice(deviceId_); | ||
16 | aclrtCreateContext(&context_, deviceId_); | 15 | aclrtCreateContext(&context_, deviceId_); |
17 | - aclrtCreateStream(&stream_); | ||
18 | 16 | ||
19 | // channel 准备 | 17 | // channel 准备 |
20 | dvppChannelDesc_ = acldvppCreateChannelDesc(); | 18 | dvppChannelDesc_ = acldvppCreateChannelDesc(); |
@@ -28,21 +26,12 @@ int JpegUtil::jpeg_init(int32_t devId){ | @@ -28,21 +26,12 @@ int JpegUtil::jpeg_init(int32_t devId){ | ||
28 | 26 | ||
29 | void JpegUtil::jpeg_release(){ | 27 | void JpegUtil::jpeg_release(){ |
30 | aclError ret; | 28 | aclError ret; |
31 | - ret = aclrtSetDevice(deviceId_); | ||
32 | aclrtSetCurrentContext(context_); | 29 | aclrtSetCurrentContext(context_); |
33 | 30 | ||
34 | ret = acldvppDestroyChannel(dvppChannelDesc_); | 31 | ret = acldvppDestroyChannel(dvppChannelDesc_); |
35 | ret = acldvppDestroyChannelDesc(dvppChannelDesc_); | 32 | ret = acldvppDestroyChannelDesc(dvppChannelDesc_); |
36 | dvppChannelDesc_ = nullptr; | 33 | dvppChannelDesc_ = nullptr; |
37 | 34 | ||
38 | - if (stream_ != nullptr) { | ||
39 | - ret = aclrtDestroyStream(stream_); | ||
40 | - if (ret != ACL_SUCCESS) { | ||
41 | - LOG_ERROR("destroy stream failed"); | ||
42 | - } | ||
43 | - stream_ = nullptr; | ||
44 | - } | ||
45 | - | ||
46 | acldvppDestroyJpegeConfig(jpegeConfig_); | 35 | acldvppDestroyJpegeConfig(jpegeConfig_); |
47 | 36 | ||
48 | if (context_ != nullptr) { | 37 | if (context_ != nullptr) { |
@@ -52,11 +41,6 @@ void JpegUtil::jpeg_release(){ | @@ -52,11 +41,6 @@ void JpegUtil::jpeg_release(){ | ||
52 | } | 41 | } |
53 | context_ = nullptr; | 42 | context_ = nullptr; |
54 | } | 43 | } |
55 | - | ||
56 | - ret = aclrtResetDevice(deviceId_); | ||
57 | - if (ret != ACL_SUCCESS) { | ||
58 | - LOG_ERROR("reset device failed"); | ||
59 | - } | ||
60 | } | 44 | } |
61 | 45 | ||
62 | int32_t JpegUtil::jpege_save(char* pcData , uint32_t dataLen, string out_file_name) | 46 | int32_t JpegUtil::jpege_save(char* pcData , uint32_t dataLen, string out_file_name) |
@@ -78,7 +62,6 @@ int32_t JpegUtil::jpege_save(char* pcData , uint32_t dataLen, string out_file_na | @@ -78,7 +62,6 @@ int32_t JpegUtil::jpege_save(char* pcData , uint32_t dataLen, string out_file_na | ||
78 | bool JpegUtil::jpeg_encode(acldvppPicDesc *encodeInputDesc_, string out_file_name) { | 62 | bool JpegUtil::jpeg_encode(acldvppPicDesc *encodeInputDesc_, string out_file_name) { |
79 | 63 | ||
80 | aclError aclRet ; | 64 | aclError aclRet ; |
81 | - aclRet = aclrtSetDevice(deviceId_); | ||
82 | aclrtSetCurrentContext(context_); | 65 | aclrtSetCurrentContext(context_); |
83 | 66 | ||
84 | // 8. 申请输出内存,申请Device内存encodeOutBufferDev_,存放编码后的输出数据 | 67 | // 8. 申请输出内存,申请Device内存encodeOutBufferDev_,存放编码后的输出数据 |
@@ -96,6 +79,8 @@ bool JpegUtil::jpeg_encode(acldvppPicDesc *encodeInputDesc_, string out_file_nam | @@ -96,6 +79,8 @@ bool JpegUtil::jpeg_encode(acldvppPicDesc *encodeInputDesc_, string out_file_nam | ||
96 | } | 79 | } |
97 | 80 | ||
98 | bool bRet = false; | 81 | bool bRet = false; |
82 | + aclrtStream stream_; | ||
83 | + aclrtCreateStream(&stream_); | ||
99 | do { | 84 | do { |
100 | // 9. 执行异步编码,再调用aclrtSynchronizeStream接口阻塞程序运行,直到指定Stream中的所有任务都完成 | 85 | // 9. 执行异步编码,再调用aclrtSynchronizeStream接口阻塞程序运行,直到指定Stream中的所有任务都完成 |
101 | aclRet = acldvppJpegEncodeAsync(dvppChannelDesc_, encodeInputDesc_, encodeOutBufferDev_, &outBufferSize, jpegeConfig_, stream_); | 86 | aclRet = acldvppJpegEncodeAsync(dvppChannelDesc_, encodeInputDesc_, encodeOutBufferDev_, &outBufferSize, jpegeConfig_, stream_); |
@@ -136,10 +121,17 @@ bool JpegUtil::jpeg_encode(acldvppPicDesc *encodeInputDesc_, string out_file_nam | @@ -136,10 +121,17 @@ bool JpegUtil::jpeg_encode(acldvppPicDesc *encodeInputDesc_, string out_file_nam | ||
136 | 121 | ||
137 | bRet = true; | 122 | bRet = true; |
138 | } while (0); | 123 | } while (0); |
124 | + | ||
125 | + if (stream_ != nullptr) { | ||
126 | + ret = aclrtDestroyStream(stream_); | ||
127 | + if (ret != ACL_SUCCESS) { | ||
128 | + LOG_ERROR("destroy stream failed"); | ||
129 | + } | ||
130 | + stream_ = nullptr; | ||
131 | + } | ||
139 | 132 | ||
140 | // 释放掉输入输出的device内存 | 133 | // 释放掉输入输出的device内存 |
141 | (void)acldvppFree(encodeOutBufferDev_); | 134 | (void)acldvppFree(encodeOutBufferDev_); |
142 | encodeOutBufferDev_ = nullptr; | 135 | encodeOutBufferDev_ = nullptr; |
143 | - aclRet = aclrtResetDevice(deviceId_); | ||
144 | return bRet; | 136 | return bRet; |
145 | } | 137 | } |
146 | \ No newline at end of file | 138 | \ No newline at end of file |
src/util/JpegUtil.h
@@ -23,7 +23,6 @@ private: | @@ -23,7 +23,6 @@ private: | ||
23 | private: | 23 | private: |
24 | int32_t deviceId_; | 24 | int32_t deviceId_; |
25 | aclrtContext context_; | 25 | aclrtContext context_; |
26 | - aclrtStream stream_; | ||
27 | acldvppChannelDesc *dvppChannelDesc_; | 26 | acldvppChannelDesc *dvppChannelDesc_; |
28 | acldvppJpegeConfig *jpegeConfig_ ; | 27 | acldvppJpegeConfig *jpegeConfig_ ; |
29 | }; | 28 | }; |
src/util/vpc_util.cpp
@@ -29,8 +29,7 @@ static uint32_t AlignSize(uint32_t origSize, uint32_t alignment){ | @@ -29,8 +29,7 @@ static uint32_t AlignSize(uint32_t origSize, uint32_t alignment){ | ||
29 | void VPCUtil::release() | 29 | void VPCUtil::release() |
30 | { | 30 | { |
31 | aclError ret; | 31 | aclError ret; |
32 | - // ret = aclrtSetDevice(deviceId_); | ||
33 | - // aclrtSetCurrentContext(context_); | 32 | + aclrtSetCurrentContext(context_); |
34 | 33 | ||
35 | ret = acldvppDestroyChannel(dvppChannelDesc_); | 34 | ret = acldvppDestroyChannel(dvppChannelDesc_); |
36 | ret = acldvppDestroyChannelDesc(dvppChannelDesc_); | 35 | ret = acldvppDestroyChannelDesc(dvppChannelDesc_); |
@@ -44,10 +43,6 @@ void VPCUtil::release() | @@ -44,10 +43,6 @@ void VPCUtil::release() | ||
44 | } | 43 | } |
45 | LOG_INFO("end to destroy context"); | 44 | LOG_INFO("end to destroy context"); |
46 | 45 | ||
47 | - ret = aclrtResetDevice(deviceId_); | ||
48 | - if (ret != ACL_SUCCESS) { | ||
49 | - LOG_ERROR("reset device failed"); | ||
50 | - } | ||
51 | LOG_INFO("end to reset device is %d", deviceId_); | 46 | LOG_INFO("end to reset device is %d", deviceId_); |
52 | } | 47 | } |
53 | 48 | ||
@@ -108,7 +103,6 @@ vpc_img_info VPCUtil::crop(DeviceMemory *devMem, video_object_info obj) { | @@ -108,7 +103,6 @@ vpc_img_info VPCUtil::crop(DeviceMemory *devMem, video_object_info obj) { | ||
108 | } | 103 | } |
109 | 104 | ||
110 | aclError ret; | 105 | aclError ret; |
111 | - aclrtSetDevice(deviceId_); | ||
112 | ret = aclrtSetCurrentContext(context_); | 106 | ret = aclrtSetCurrentContext(context_); |
113 | if (ret != ACL_SUCCESS) { | 107 | if (ret != ACL_SUCCESS) { |
114 | LOG_ERROR("aclrtSetCurrentContext failed"); | 108 | LOG_ERROR("aclrtSetCurrentContext failed"); |
@@ -194,7 +188,6 @@ int VPCUtil::init(int32_t devId){ | @@ -194,7 +188,6 @@ int VPCUtil::init(int32_t devId){ | ||
194 | deviceId_ = devId; | 188 | deviceId_ = devId; |
195 | 189 | ||
196 | aclError ret; | 190 | aclError ret; |
197 | - aclrtSetDevice(deviceId_); | ||
198 | aclrtCreateContext(&context_, deviceId_); | 191 | aclrtCreateContext(&context_, deviceId_); |
199 | 192 | ||
200 | // channel 准备 | 193 | // channel 准备 |
@@ -212,7 +205,6 @@ vector<vpc_img_info> VPCUtil::crop_batch(DeviceMemory *devMem, vector<video_obje | @@ -212,7 +205,6 @@ vector<vpc_img_info> VPCUtil::crop_batch(DeviceMemory *devMem, vector<video_obje | ||
212 | } | 205 | } |
213 | 206 | ||
214 | aclError ret; | 207 | aclError ret; |
215 | - aclrtSetDevice(deviceId_); | ||
216 | ret = aclrtSetCurrentContext(context_); | 208 | ret = aclrtSetCurrentContext(context_); |
217 | 209 | ||
218 | // 输入 | 210 | // 输入 |
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) |
@@ -193,10 +191,6 @@ void DestroyResource() | @@ -193,10 +191,6 @@ void DestroyResource() | ||
193 | } | 191 | } |
194 | INFO_LOG("end to destroy context"); | 192 | INFO_LOG("end to destroy context"); |
195 | 193 | ||
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_); | 194 | INFO_LOG("end to reset device is %d", deviceId_); |
201 | 195 | ||
202 | ret = aclFinalize(); | 196 | ret = aclFinalize(); |
@@ -213,7 +207,6 @@ int main(int argc, char *argv[]) | @@ -213,7 +207,6 @@ int main(int argc, char *argv[]) | ||
213 | aclInit(nullptr); | 207 | aclInit(nullptr); |
214 | 208 | ||
215 | /* 2.Run the management resource application, including Device, Context, Stream */ | 209 | /* 2.Run the management resource application, including Device, Context, Stream */ |
216 | - aclrtSetDevice(deviceId_); | ||
217 | aclrtCreateContext(&context_, deviceId_); | 210 | aclrtCreateContext(&context_, deviceId_); |
218 | aclrtCreateStream(&stream_); | 211 | aclrtCreateStream(&stream_); |
219 | aclrtGetRunMode(&runMode); | 212 | 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,7 +504,6 @@ void dvpp_crop(acldvppPicDesc *input_pic_desc){ | @@ -509,7 +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 | 507 | ||
514 | } | 508 | } |
515 | 509 |