1 #include "test_precomp.hpp"
2 #include "opencv2/ts/ocl_test.hpp"
5 #include "opencv2/core/ippasync.hpp"
9 using namespace cvtest;
14 PARAM_TEST_CASE(IPPAsync, MatDepth, Channels, hppAccelType)
19 hppAccelType accelType;
24 hppiVirtualMatrix * virtMatrix;
29 type = CV_MAKE_TYPE(GET_PARAM(0), GET_PARAM(1));
32 accelType = GET_PARAM(2);
35 virtual void generateTestData()
37 Size matrix_Size = randomSize(2, 100);
38 const double upValue = 100;
40 matrix = randomMat(matrix_Size, type, -upValue, upValue);
43 void Near(double threshold = 0.0)
45 EXPECT_MAT_NEAR(matrix, result, threshold);
49 TEST_P(IPPAsync, accuracy)
51 sts = hppCreateInstance(accelType, 0, &accel);
52 if (sts!=HPP_STATUS_NO_ERROR) printf("hppStatus= %d\n",sts);
53 CV_Assert(sts==HPP_STATUS_NO_ERROR);
55 virtMatrix = hppiCreateVirtualMatrices(accel, 2);
57 for (int j = 0; j < test_loop_times; j++)
60 hppMat = hpp::getHpp(matrix,accel);
64 sts = hppiAddC(accel, hppMat, a, 0, virtMatrix[0]);
65 CV_Assert(sts==HPP_STATUS_NO_ERROR);
66 sts = hppiSubC(accel, virtMatrix[0], a, 0, virtMatrix[1]);
67 CV_Assert(sts==HPP_STATUS_NO_ERROR);
69 sts = hppWait(accel, HPP_TIME_OUT_INFINITE);
70 CV_Assert(sts==HPP_STATUS_NO_ERROR);
72 result = hpp::getMat(virtMatrix[1], accel, cn);
76 sts = hppiFreeMatrix(hppMat);
77 CV_Assert(sts==HPP_STATUS_NO_ERROR);
80 sts = hppiDeleteVirtualMatrices(accel, virtMatrix);
81 CV_Assert(sts==HPP_STATUS_NO_ERROR);
82 sts = hppDeleteInstance(accel);
83 CV_Assert(sts==HPP_STATUS_NO_ERROR);
86 PARAM_TEST_CASE(IPPAsyncShared, Channels, hppAccelType)
90 hppAccelType accelType;
95 hppiVirtualMatrix * virtMatrix;
101 accelType = GET_PARAM(1);
102 type=CV_MAKE_TYPE(CV_8U, GET_PARAM(0));
105 virtual void generateTestData()
107 Size matrix_Size = randomSize(2, 100);
109 const int upValue = 100;
111 sts = hppQueryMatrixAllocParams(accel, (hpp32u)(matrix_Size.width*cn), (hpp32u)matrix_Size.height, HPP_DATA_TYPE_8U, &pitch, &size);
113 if (pitch!=0 && size!=0)
115 uchar *pData = (uchar*)_aligned_malloc(size, 4096);
117 for (int j=0; j<matrix_Size.height; j++)
118 for(int i=0; i<matrix_Size.width*cn; i++)
119 pData[i+j*pitch] = rand()%upValue;
121 matrix = Mat(matrix_Size.height, matrix_Size.width, type, pData, pitch);
124 matrix = randomMat(matrix_Size, type, 0, upValue);
127 void Near(double threshold = 0.0)
129 EXPECT_MAT_NEAR(matrix, result, threshold);
133 TEST_P(IPPAsyncShared, accuracy)
135 sts = hppCreateInstance(accelType, 0, &accel);
136 if (sts!=HPP_STATUS_NO_ERROR) printf("hppStatus= %d\n",sts);
137 CV_Assert(sts==HPP_STATUS_NO_ERROR);
139 virtMatrix = hppiCreateVirtualMatrices(accel, 2);
141 for (int j = 0; j < test_loop_times; j++)
144 hppMat = hpp::getHpp(matrix,accel);
148 sts = hppiAddC(accel, hppMat, a, 0, virtMatrix[0]);
149 CV_Assert(sts==HPP_STATUS_NO_ERROR);
150 sts = hppiSubC(accel, virtMatrix[0], a, 0, virtMatrix[1]);
151 CV_Assert(sts==HPP_STATUS_NO_ERROR);
153 sts = hppWait(accel, HPP_TIME_OUT_INFINITE);
154 CV_Assert(sts==HPP_STATUS_NO_ERROR);
156 result = hpp::getMat(virtMatrix[1], accel, cn);
160 sts = hppiFreeMatrix(hppMat);
161 CV_Assert(sts==HPP_STATUS_NO_ERROR);
164 sts = hppiDeleteVirtualMatrices(accel, virtMatrix);
165 CV_Assert(sts==HPP_STATUS_NO_ERROR);
166 sts = hppDeleteInstance(accel);
167 CV_Assert(sts==HPP_STATUS_NO_ERROR);
170 INSTANTIATE_TEST_CASE_P(IppATest, IPPAsyncShared, Combine(Values(1, 2, 3, 4),
171 Values( HPP_ACCEL_TYPE_CPU, HPP_ACCEL_TYPE_GPU)));
173 INSTANTIATE_TEST_CASE_P(IppATest, IPPAsync, Combine(Values(CV_8U, CV_16U, CV_16S, CV_32F),
175 Values( HPP_ACCEL_TYPE_CPU, HPP_ACCEL_TYPE_GPU)));