2014-02-24 14:44:54 +08:00
|
|
|
#include "test_precomp.hpp"
|
|
|
|
#include "opencv2/ts/ocl_test.hpp"
|
|
|
|
|
2014-03-27 21:40:50 +08:00
|
|
|
#ifdef HAVE_IPP_A
|
2014-02-24 14:44:54 +08:00
|
|
|
#include "opencv2/core/ippasync.hpp"
|
|
|
|
|
|
|
|
using namespace cv;
|
|
|
|
using namespace std;
|
|
|
|
using namespace cvtest;
|
|
|
|
|
|
|
|
namespace cvtest {
|
|
|
|
namespace ocl {
|
|
|
|
|
|
|
|
PARAM_TEST_CASE(IPPAsync, MatDepth, Channels, hppAccelType)
|
|
|
|
{
|
|
|
|
int type;
|
|
|
|
int cn;
|
|
|
|
int depth;
|
|
|
|
hppAccelType accelType;
|
|
|
|
|
|
|
|
Mat matrix, result;
|
2014-03-27 21:40:50 +08:00
|
|
|
hppiMatrix * hppMat;
|
2014-02-24 14:44:54 +08:00
|
|
|
hppAccel accel;
|
|
|
|
hppiVirtualMatrix * virtMatrix;
|
|
|
|
hppStatus sts;
|
|
|
|
|
|
|
|
virtual void SetUp()
|
|
|
|
{
|
|
|
|
type = CV_MAKE_TYPE(GET_PARAM(0), GET_PARAM(1));
|
|
|
|
depth = GET_PARAM(0);
|
|
|
|
cn = GET_PARAM(1);
|
|
|
|
accelType = GET_PARAM(2);
|
|
|
|
}
|
|
|
|
|
2016-10-07 23:49:52 +08:00
|
|
|
void generateTestData()
|
2014-02-24 14:44:54 +08:00
|
|
|
{
|
|
|
|
Size matrix_Size = randomSize(2, 100);
|
|
|
|
const double upValue = 100;
|
|
|
|
|
|
|
|
matrix = randomMat(matrix_Size, type, -upValue, upValue);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Near(double threshold = 0.0)
|
|
|
|
{
|
|
|
|
EXPECT_MAT_NEAR(matrix, result, threshold);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
TEST_P(IPPAsync, accuracy)
|
|
|
|
{
|
|
|
|
sts = hppCreateInstance(accelType, 0, &accel);
|
2014-04-04 16:08:22 +08:00
|
|
|
if (sts!=HPP_STATUS_NO_ERROR) printf("hppStatus = %d\n",sts);
|
2014-02-24 14:44:54 +08:00
|
|
|
CV_Assert(sts==HPP_STATUS_NO_ERROR);
|
2014-03-27 21:40:50 +08:00
|
|
|
|
2014-02-24 14:44:54 +08:00
|
|
|
virtMatrix = hppiCreateVirtualMatrices(accel, 2);
|
|
|
|
|
|
|
|
for (int j = 0; j < test_loop_times; j++)
|
|
|
|
{
|
|
|
|
generateTestData();
|
2014-03-27 21:40:50 +08:00
|
|
|
hppMat = hpp::getHpp(matrix,accel);
|
2014-02-24 14:44:54 +08:00
|
|
|
|
|
|
|
hppScalar a = 3;
|
|
|
|
|
|
|
|
sts = hppiAddC(accel, hppMat, a, 0, virtMatrix[0]);
|
|
|
|
CV_Assert(sts==HPP_STATUS_NO_ERROR);
|
|
|
|
sts = hppiSubC(accel, virtMatrix[0], a, 0, virtMatrix[1]);
|
|
|
|
CV_Assert(sts==HPP_STATUS_NO_ERROR);
|
|
|
|
|
|
|
|
sts = hppWait(accel, HPP_TIME_OUT_INFINITE);
|
|
|
|
CV_Assert(sts==HPP_STATUS_NO_ERROR);
|
2014-03-27 21:40:50 +08:00
|
|
|
|
2014-02-24 14:44:54 +08:00
|
|
|
result = hpp::getMat(virtMatrix[1], accel, cn);
|
|
|
|
|
|
|
|
Near(5.0e-6);
|
2014-03-27 21:40:50 +08:00
|
|
|
|
|
|
|
sts = hppiFreeMatrix(hppMat);
|
|
|
|
CV_Assert(sts==HPP_STATUS_NO_ERROR);
|
2014-02-24 14:44:54 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
sts = hppiDeleteVirtualMatrices(accel, virtMatrix);
|
|
|
|
CV_Assert(sts==HPP_STATUS_NO_ERROR);
|
|
|
|
sts = hppDeleteInstance(accel);
|
|
|
|
CV_Assert(sts==HPP_STATUS_NO_ERROR);
|
|
|
|
}
|
|
|
|
|
2014-03-27 21:40:50 +08:00
|
|
|
PARAM_TEST_CASE(IPPAsyncShared, Channels, hppAccelType)
|
|
|
|
{
|
|
|
|
int cn;
|
|
|
|
int type;
|
|
|
|
hppAccelType accelType;
|
|
|
|
|
|
|
|
Mat matrix, result;
|
|
|
|
hppiMatrix* hppMat;
|
|
|
|
hppAccel accel;
|
|
|
|
hppiVirtualMatrix * virtMatrix;
|
|
|
|
hppStatus sts;
|
|
|
|
|
|
|
|
virtual void SetUp()
|
|
|
|
{
|
|
|
|
cn = GET_PARAM(0);
|
|
|
|
accelType = GET_PARAM(1);
|
|
|
|
type=CV_MAKE_TYPE(CV_8U, GET_PARAM(0));
|
|
|
|
}
|
|
|
|
|
2016-10-07 23:49:52 +08:00
|
|
|
void generateTestData()
|
2014-03-27 21:40:50 +08:00
|
|
|
{
|
|
|
|
Size matrix_Size = randomSize(2, 100);
|
|
|
|
hpp32u pitch, size;
|
|
|
|
const int upValue = 100;
|
|
|
|
|
|
|
|
sts = hppQueryMatrixAllocParams(accel, (hpp32u)(matrix_Size.width*cn), (hpp32u)matrix_Size.height, HPP_DATA_TYPE_8U, &pitch, &size);
|
|
|
|
|
|
|
|
matrix = randomMat(matrix_Size, type, 0, upValue);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Near(double threshold = 0.0)
|
|
|
|
{
|
|
|
|
EXPECT_MAT_NEAR(matrix, result, threshold);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
TEST_P(IPPAsyncShared, accuracy)
|
2014-02-24 14:44:54 +08:00
|
|
|
{
|
|
|
|
sts = hppCreateInstance(accelType, 0, &accel);
|
2014-04-04 16:08:22 +08:00
|
|
|
if (sts!=HPP_STATUS_NO_ERROR) printf("hppStatus = %d\n",sts);
|
2014-02-24 14:44:54 +08:00
|
|
|
CV_Assert(sts==HPP_STATUS_NO_ERROR);
|
2014-03-27 21:40:50 +08:00
|
|
|
|
|
|
|
virtMatrix = hppiCreateVirtualMatrices(accel, 2);
|
2014-02-24 14:44:54 +08:00
|
|
|
|
|
|
|
for (int j = 0; j < test_loop_times; j++)
|
|
|
|
{
|
|
|
|
generateTestData();
|
2014-03-27 21:40:50 +08:00
|
|
|
hppMat = hpp::getHpp(matrix,accel);
|
2014-02-24 14:44:54 +08:00
|
|
|
|
2014-03-27 21:40:50 +08:00
|
|
|
hppScalar a = 3;
|
|
|
|
|
|
|
|
sts = hppiAddC(accel, hppMat, a, 0, virtMatrix[0]);
|
|
|
|
CV_Assert(sts==HPP_STATUS_NO_ERROR);
|
|
|
|
sts = hppiSubC(accel, virtMatrix[0], a, 0, virtMatrix[1]);
|
2014-02-24 14:44:54 +08:00
|
|
|
CV_Assert(sts==HPP_STATUS_NO_ERROR);
|
|
|
|
|
|
|
|
sts = hppWait(accel, HPP_TIME_OUT_INFINITE);
|
|
|
|
CV_Assert(sts==HPP_STATUS_NO_ERROR);
|
|
|
|
|
2014-03-27 21:40:50 +08:00
|
|
|
result = hpp::getMat(virtMatrix[1], accel, cn);
|
|
|
|
|
|
|
|
Near(0);
|
|
|
|
|
|
|
|
sts = hppiFreeMatrix(hppMat);
|
|
|
|
CV_Assert(sts==HPP_STATUS_NO_ERROR);
|
2014-02-24 14:44:54 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
sts = hppiDeleteVirtualMatrices(accel, virtMatrix);
|
|
|
|
CV_Assert(sts==HPP_STATUS_NO_ERROR);
|
|
|
|
sts = hppDeleteInstance(accel);
|
|
|
|
CV_Assert(sts==HPP_STATUS_NO_ERROR);
|
|
|
|
}
|
|
|
|
|
2014-03-27 21:40:50 +08:00
|
|
|
INSTANTIATE_TEST_CASE_P(IppATest, IPPAsyncShared, Combine(Values(1, 2, 3, 4),
|
|
|
|
Values( HPP_ACCEL_TYPE_CPU, HPP_ACCEL_TYPE_GPU)));
|
|
|
|
|
|
|
|
INSTANTIATE_TEST_CASE_P(IppATest, IPPAsync, Combine(Values(CV_8U, CV_16U, CV_16S, CV_32F),
|
2014-02-24 14:44:54 +08:00
|
|
|
Values(1, 2, 3, 4),
|
|
|
|
Values( HPP_ACCEL_TYPE_CPU, HPP_ACCEL_TYPE_GPU)));
|
|
|
|
|
|
|
|
}
|
2014-03-27 21:40:50 +08:00
|
|
|
}
|
|
|
|
#endif
|