From be79c3e5c3971f0679365667ce964200c447722d Mon Sep 17 00:00:00 2001 From: luoliang Date: Sun, 9 Oct 2022 14:18:04 +0800 Subject: [PATCH] update new version --- acl/src/matrices.cpp | 6 +++-- acl/test/acl.cpp | 17 +++--------- acl/test/test_acl.cpp | 14 +++++----- acl/test/test_gemm.cpp | 6 ++--- acl/test/test_mathfuncs.cpp | 53 ++++++++++++++++++++----------------- acl/test/test_matrices.cpp | 23 +++++++++------- acl/test/test_perf.hpp | 4 --- 7 files changed, 60 insertions(+), 63 deletions(-) diff --git a/acl/src/matrices.cpp b/acl/src/matrices.cpp index fa59d6e..80fec64 100644 --- a/acl/src/matrices.cpp +++ b/acl/src/matrices.cpp @@ -246,8 +246,9 @@ namespace cv AclSafeCall(aclDestroyDataBuffer(inputBuffers_host[0])); AclSafeCall(aclDestroyDataBuffer(inputBuffers_host[1])); AclSafeCall(aclDestroyDataBuffer(outputBuffers_[0])); - aclrtFreeHost(perm); - aclrtFreeHost(host_data); + AclSafeCall(aclrtFree(dev)); + AclSafeCall(aclrtFreeHost(perm)); + AclSafeCall(aclrtFreeHost(host_data)); } @@ -460,6 +461,7 @@ namespace cv AclSafeCall(aclDestroyDataBuffer(inputBuffers_[0])); AclSafeCall(aclDestroyDataBuffer(inputBuffers_[1])); AclSafeCall(aclDestroyDataBuffer(outputBuffers_[0])); + AclSafeCall(aclrtFree(dev)); } void flip(const aclMat& src, aclMat& dest, int filpCode, int stream_id) diff --git a/acl/test/acl.cpp b/acl/test/acl.cpp index c71d32a..bd26327 100644 --- a/acl/test/acl.cpp +++ b/acl/test/acl.cpp @@ -7,9 +7,8 @@ namespace opencv_test { namespace { - aclCxt *acl_context_0 = set_device("../../modules/acl/test/acl.json", 0, 3); + aclCxt *acl_context_0 = set_device("../../modules/acl/test/acl.json", 2, 3); ////////////////////////////////////////////////////Correctness_test//////////////////////////////////////////////////////// -#if 0 /* range: rows: 1 ~ 64, cols: 1 ~ 64, type: 0 ~ 7 * test function: * config: MEMORY_ALIGN @@ -178,7 +177,7 @@ namespace opencv_test AclMat_Test test; test.Test_operator_div(acl_context_0); } -#endif + ////////////////////////////////////////////////////Perf_test//////////////////////////////////////////////////////// TEST(Operator, add) @@ -282,13 +281,7 @@ namespace opencv_test PERF_TEST test; test.Test_Split(acl_context_0); } -/* - TEST(Matrices, lookuptable) - { - PERF_TEST test; - test.Test_Lookuptable(acl_context_0); - } -*/ + TEST(Matrices, transpose) { @@ -299,10 +292,8 @@ namespace opencv_test TEST(Matrices, flip) { PERF_TEST test; - test.Test_Flip(acl_context_0); + test.Test_Flip(acl_context_0); release_device(acl_context_0); } - - } } \ No newline at end of file diff --git a/acl/test/test_acl.cpp b/acl/test/test_acl.cpp index c09975f..d6cad03 100644 --- a/acl/test/test_acl.cpp +++ b/acl/test/test_acl.cpp @@ -6,7 +6,7 @@ void PERF_TEST::Test_operator_add_perf(aclCxt *acl_context) { int val, n; int valmax = 8192; - int cycle_index = 100; + int cycle_index = 10; double begin, end, time, acltime; Common_Test test; @@ -59,11 +59,12 @@ void PERF_TEST::Test_operator_sub_perf(aclCxt *acl_context) { int val, n; int valmax = 8192; - int cycle_index = 100; + int cycle_index = 10; double begin, end, time, acltime; Common_Test test; - vector type{CV_8UC1, CV_32FC1, CV_32SC1}; + vector type{CV_8UC1, CV_32FC1, CV_32SC1,CV_64FC1}; + //vector type{CV_64FC1}; for (size_t i = 0; i < type.size(); ++i) { test.PrintLog("Perf test : Function: operator-=()", type[i]); @@ -113,11 +114,12 @@ void PERF_TEST::Test_operator_div_perf(aclCxt *acl_context) { int val, n; int valmax = 8192; - int cycle_index = 100; + int cycle_index = 10; double begin, end, time, acltime; Common_Test test; - vector type{CV_32FC1}; + //vector type{CV_32FC1}; + vector type{CV_8UC1,CV_32FC1, CV_32SC1, CV_64FC1}; for (size_t i = 0; i < type.size(); ++i) { test.PrintLog("Perf test : Function: operator/=()", type[i]); @@ -164,7 +166,7 @@ void PERF_TEST::Test_operator_mul_perf(aclCxt *acl_context) { int val, n; int valmax = 4096; - int cycle_index = 100; + int cycle_index = 10; double begin, end, time, acltime; Common_Test test; vector type{CV_32FC1}; diff --git a/acl/test/test_gemm.cpp b/acl/test/test_gemm.cpp index 6b1118d..4332c56 100644 --- a/acl/test/test_gemm.cpp +++ b/acl/test/test_gemm.cpp @@ -5,7 +5,7 @@ void PERF_TEST::Test_MatMul(aclCxt *acl_context) { int val, n; int valmax = 4096; - int cycle_index = 100; + int cycle_index = 10;//100; double begin, end, time, acltime; Common_Test test; vector type{CV_32FC1}; @@ -61,7 +61,7 @@ void PERF_TEST::Test_Convolution(aclCxt *acl_context) { int val, n; int valmax = 4096; - int cycle_index = 100; + int cycle_index = 10; double begin, end, time, acltime; Common_Test test; vector type{CV_32FC1}; @@ -110,4 +110,4 @@ void PERF_TEST::Test_Convolution(aclCxt *acl_context) cout << "CpuTimes: " << time << "\tAclTimes: " << acltime << "\tRate: " << time / acltime << endl; } } -} +} \ No newline at end of file diff --git a/acl/test/test_mathfuncs.cpp b/acl/test/test_mathfuncs.cpp index 24325f6..5f100b4 100644 --- a/acl/test/test_mathfuncs.cpp +++ b/acl/test/test_mathfuncs.cpp @@ -5,11 +5,12 @@ void PERF_TEST::Test_Abs(aclCxt *acl_context) { int val, n; int valmax = 8192; - int cycle_index = 100; + int cycle_index = 10; double begin, end, time, acltime; Common_Test test; - vector type{CV_32FC1}; + //vector type{CV_32FC1}; + vector type{CV_32FC1,CV_32SC1}; for (size_t i = 0; i < type.size(); ++i) { test.PrintLog("Perf test : Function: Abs()", type[i]); @@ -55,11 +56,12 @@ void PERF_TEST::Test_Pow(aclCxt *acl_context) { int val, n; int valmax = 8192; - int cycle_index = 100; + int cycle_index = 10; double begin, end, time, acltime; Common_Test test; - vector type{CV_32FC1}; + //vector type{CV_32FC1}; + vector type{CV_8UC1, CV_32FC1,CV_32SC1}; for (size_t i = 0; i < type.size(); ++i) { test.PrintLog("Perf test : Function: Pow()", type[i]); @@ -106,11 +108,11 @@ void PERF_TEST::Test_Sqrt(aclCxt *acl_context) { int val, n; int valmax = 8192; - int cycle_index = 100; + int cycle_index = 10; double begin, end, time, acltime; Common_Test test; - vector type{CV_32FC1}; - + //vector type{CV_32FC1}; + vector type{CV_32FC1,CV_64FC1}; for (size_t i = 0; i < type.size(); ++i) { for (val = 8; val <= valmax; val *= 2) @@ -157,11 +159,11 @@ void PERF_TEST::Test_Add(aclCxt *acl_context) { int val, n; int valmax = 8192; - int cycle_index = 100; + int cycle_index = 10; double begin, end, time, acltime; Common_Test test; - vector type{CV_32FC1}; - + //vector type{CV_32FC1}; + vector type{CV_8UC1,CV_32FC1, CV_32SC1, CV_64FC1}; for (size_t i = 0; i < type.size(); ++i) { for (val = 8; val <= valmax; val *= 2) @@ -213,11 +215,11 @@ void PERF_TEST::Test_Divide(aclCxt *acl_context) { int val, n; int valmax = 8192; - int cycle_index = 100; + int cycle_index = 10; double begin, end, time, acltime; Common_Test test; - vector type{CV_32FC1}; - + //vector type{CV_32FC1}; + vector type{CV_8UC1,CV_32FC1, CV_32SC1}; for (size_t i = 0; i < type.size(); ++i) { for (val = 8; val <= valmax; val *= 2) @@ -268,11 +270,12 @@ void PERF_TEST::Test_Exp(aclCxt *acl_context) { int val, n; int valmax = 8192; - int cycle_index = 100; + int cycle_index = 10; double begin, end, time, acltime; Common_Test test; - vector type{CV_32FC1}; + //vector type{CV_32FC1}; + vector type{CV_32FC1,CV_64FC1}; for (size_t i = 0; i < type.size(); ++i) { for (val = 8; val <= valmax; val *= 2) @@ -319,11 +322,11 @@ void PERF_TEST::Test_Log(aclCxt *acl_context) { int val, n; int valmax = 8192; - int cycle_index = 100; + int cycle_index = 10; double begin, end, time, acltime; Common_Test test; - vector type{CV_32FC1}; - + //vector type{CV_32FC1}; + vector type{CV_32FC1,CV_64FC1}; for (size_t i = 0; i < type.size(); ++i) { for (val = 8; val <= valmax; val *= 2) @@ -370,11 +373,11 @@ void PERF_TEST::Test_Max(aclCxt *acl_context) { int val, n; int valmax = 8192; - int cycle_index = 100; + int cycle_index = 10; double begin, end, time, acltime; Common_Test test; - vector type{CV_32FC2}; - + // vector type{CV_32FC2}; + vector type{CV_32FC2,CV_32SC2, CV_64FC2}; for (size_t i = 0; i < type.size(); ++i) { for (val = 8; val <= valmax; val *= 2) @@ -425,16 +428,16 @@ void PERF_TEST::Test_Min(aclCxt *acl_context) { int val, n; int valmax = 8192; - int cycle_index = 100; + int cycle_index = 10; double begin, end, time, acltime; Common_Test test; - vector type{CV_32FC3}; - + //vector type{CV_32FC3}; + vector type{CV_32FC3,CV_32SC3, CV_64FC3}; for (size_t i = 0; i < type.size(); ++i) { for (val = 8; val <= valmax; val *= 2) { - int n = cycle_index; + n = cycle_index; Mat mat_src1(val, val, type[i]); Mat mat_src2(val, val, type[i]); Mat mat_dest(val, val, type[i]); diff --git a/acl/test/test_matrices.cpp b/acl/test/test_matrices.cpp index 3f4dcf7..e2df35f 100644 --- a/acl/test/test_matrices.cpp +++ b/acl/test/test_matrices.cpp @@ -30,13 +30,15 @@ void PERF_TEST::Test_Merge(aclCxt *acl_context) { int val, n; int valmax = 8192; - int cycle_index = 100; + int cycle_index = 10; double begin, end, time, acltime; Common_Test test; - vector srcType{CV_32FC1}; - vector destType{CV_32FC3}; - + + vector srcType{CV_8UC1,CV_32FC1, CV_32SC1}; + + //vector destType{CV_32FC3}; + vector destType{CV_8UC3,CV_32FC3, CV_32SC3}; for (size_t i = 0; i < srcType.size(); ++i) { test.PrintLog("Perf test : Function: merge()", srcType[i]); @@ -100,11 +102,12 @@ void PERF_TEST::Test_Transpose(aclCxt *acl_context) { int val, n; int valmax = 8192; - int cycle_index = 100; + int cycle_index = 10; double begin, end, time, acltime; Common_Test test; - vector type{CV_32FC1}; + //vector type{CV_32FC1}; + vector type{CV_32FC1,CV_32SC1}; for (size_t i = 0; i < type.size(); ++i) { test.PrintLog("Perf test : Function: transpose()", type[i]); @@ -152,13 +155,13 @@ void PERF_TEST::Test_Split(aclCxt *acl_context) { int val, n; int valmax = 8192; - int cycle_index = 100; + int cycle_index = 10; double begin, end, time, acltime; Common_Test test; - vector srcType{CV_32FC3}; - vector destType{CV_32FC1}; - + //vector srcType{CV_32FC3}; + vector srcType{CV_8UC3,CV_32FC3, CV_32SC3}; + vector destType{CV_8UC1,CV_32FC1, CV_32SC1}; for (size_t i = 0; i < srcType.size(); ++i) { test.PrintLog("Perf test : Function: split()", srcType[i]); diff --git a/acl/test/test_perf.hpp b/acl/test/test_perf.hpp index e1cd305..4c47b11 100644 --- a/acl/test/test_perf.hpp +++ b/acl/test/test_perf.hpp @@ -28,10 +28,6 @@ public: CV_EXPORTS void Test_Split(aclCxt *acl_context); CV_EXPORTS void Test_Transpose(aclCxt *acl_context); CV_EXPORTS void Test_Flip(aclCxt *acl_context); - - CV_EXPORTS void Test_other(aclCxt *acl_context); - CV_EXPORTS void Test_other1(aclCxt *acl_context); - CV_EXPORTS void Test_other2(); }; #endif \ No newline at end of file