Path: blob/master/modules/core/perf/opencl/perf_matop.cpp
16358 views
// This file is part of OpenCV project.1// It is subject to the license terms in the LICENSE file found in the top-level directory2// of this distribution and at http://opencv.org/license.html.34// Copyright (C) 2014, Advanced Micro Devices, Inc., all rights reserved.5// Third party copyrights are property of their respective owners.67#include "../perf_precomp.hpp"8#include "opencv2/ts/ocl_perf.hpp"910#ifdef HAVE_OPENCL1112namespace opencv_test {13namespace ocl {1415///////////// SetTo ////////////////////////1617typedef Size_MatType SetToFixture;1819OCL_PERF_TEST_P(SetToFixture, SetTo,20::testing::Combine(OCL_TEST_SIZES, OCL_TEST_TYPES))21{22const Size_MatType_t params = GetParam();23const Size srcSize = get<0>(params);24const int type = get<1>(params);25const Scalar s = Scalar::all(17);2627checkDeviceMaxMemoryAllocSize(srcSize, type);2829UMat src(srcSize, type);30declare.in(src, WARMUP_RNG).out(src);3132OCL_TEST_CYCLE() src.setTo(s);3334SANITY_CHECK(src);35}3637///////////// SetTo with mask ////////////////////////3839typedef Size_MatType SetToFixture;4041OCL_PERF_TEST_P(SetToFixture, SetToWithMask,42::testing::Combine(OCL_TEST_SIZES, OCL_TEST_TYPES))43{44const Size_MatType_t params = GetParam();45const Size srcSize = get<0>(params);46const int type = get<1>(params);47const Scalar s = Scalar::all(17);4849checkDeviceMaxMemoryAllocSize(srcSize, type);5051UMat src(srcSize, type), mask(srcSize, CV_8UC1);52declare.in(src, mask, WARMUP_RNG).out(src);5354OCL_TEST_CYCLE() src.setTo(s, mask);5556SANITY_CHECK(src);57}5859///////////// ConvertTo ////////////////////////6061typedef Size_MatType ConvertToFixture;6263OCL_PERF_TEST_P(ConvertToFixture, ConvertTo,64::testing::Combine(OCL_TEST_SIZES, OCL_TEST_TYPES))65{66const Size_MatType_t params = GetParam();67const Size srcSize = get<0>(params);68const int type = get<1>(params), ddepth = CV_MAT_DEPTH(type) == CV_8U ? CV_32F : CV_8U,69cn = CV_MAT_CN(type), dtype = CV_MAKE_TYPE(ddepth, cn);7071checkDeviceMaxMemoryAllocSize(srcSize, type);72checkDeviceMaxMemoryAllocSize(srcSize, dtype);7374UMat src(srcSize, type), dst(srcSize, dtype);75declare.in(src, WARMUP_RNG).out(dst);7677OCL_TEST_CYCLE() src.convertTo(dst, dtype);7879SANITY_CHECK(dst);80}8182///////////// CopyTo ////////////////////////8384typedef Size_MatType CopyToFixture;8586OCL_PERF_TEST_P(CopyToFixture, CopyTo,87::testing::Combine(OCL_TEST_SIZES, OCL_TEST_TYPES))88{89const Size_MatType_t params = GetParam();90const Size srcSize = get<0>(params);91const int type = get<1>(params);9293checkDeviceMaxMemoryAllocSize(srcSize, type);9495UMat src(srcSize, type), dst(srcSize, type);96declare.in(src, WARMUP_RNG).out(dst);9798OCL_TEST_CYCLE() src.copyTo(dst);99100SANITY_CHECK(dst);101}102103///////////// CopyTo with mask ////////////////////////104105typedef Size_MatType CopyToFixture;106107OCL_PERF_TEST_P(CopyToFixture, CopyToWithMask,108::testing::Combine(OCL_TEST_SIZES, OCL_TEST_TYPES))109{110const Size_MatType_t params = GetParam();111const Size srcSize = get<0>(params);112const int type = get<1>(params);113114checkDeviceMaxMemoryAllocSize(srcSize, type);115116UMat src(srcSize, type), dst(srcSize, type), mask(srcSize, CV_8UC1);117declare.in(src, mask, WARMUP_RNG).out(dst);118119OCL_TEST_CYCLE() src.copyTo(dst, mask);120121SANITY_CHECK(dst);122}123124OCL_PERF_TEST_P(CopyToFixture, CopyToWithMaskUninit,125::testing::Combine(OCL_PERF_ENUM(OCL_SIZE_1, OCL_SIZE_2, OCL_SIZE_3), OCL_TEST_TYPES))126{127const Size_MatType_t params = GetParam();128const Size srcSize = get<0>(params);129const int type = get<1>(params);130131checkDeviceMaxMemoryAllocSize(srcSize, type);132133UMat src(srcSize, type), dst, mask(srcSize, CV_8UC1);134declare.in(src, mask, WARMUP_RNG);135136for ( ; next(); )137{138dst.release();139startTimer();140src.copyTo(dst, mask);141cvtest::ocl::perf::safeFinish();142stopTimer();143}144145SANITY_CHECK(dst);146}147148} } // namespace opencv_test::ocl149150#endif // HAVE_OPENCL151152153