Path: blob/master/modules/core/perf/opencl/perf_dxt.cpp
16358 views
/*M///////////////////////////////////////////////////////////////////////////////////////1//2// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.3//4// By downloading, copying, installing or using the software you agree to this license.5// If you do not agree to this license, do not download, install,6// copy or use the software.7//8//9// License Agreement10// For Open Source Computer Vision Library11//12// Copyright (C) 2010-2012, Multicoreware, Inc., all rights reserved.13// Copyright (C) 2010-2012, Advanced Micro Devices, Inc., all rights reserved.14// Third party copyrights are property of their respective owners.15//16// @Authors17// Fangfang Bai, [email protected]18// Jin Ma, [email protected]19//20// Redistribution and use in source and binary forms, with or without modification,21// are permitted provided that the following conditions are met:22//23// * Redistribution's of source code must retain the above copyright notice,24// this list of conditions and the following disclaimer.25//26// * Redistribution's in binary form must reproduce the above copyright notice,27// this list of conditions and the following disclaimer in the documentation28// and/or other materials provided with the distribution.29//30// * The name of the copyright holders may not be used to endorse or promote products31// derived from this software without specific prior written permission.32//33// This software is provided by the copyright holders and contributors as is and34// any express or implied warranties, including, but not limited to, the implied35// warranties of merchantability and fitness for a particular purpose are disclaimed.36// In no event shall the Intel Corporation or contributors be liable for any direct,37// indirect, incidental, special, exemplary, or consequential damages38// (including, but not limited to, procurement of substitute goods or services;39// loss of use, data, or profits; or business interruption) however caused40// and on any theory of liability, whether in contract, strict liability,41// or tort (including negligence or otherwise) arising in any way out of42// the use of this software, even if advised of the possibility of such damage.43//44//M*/4546#include "../perf_precomp.hpp"47#include "opencv2/ts/ocl_perf.hpp"4849#ifdef HAVE_OPENCL5051namespace opencv_test {52namespace ocl {5354///////////// dft ////////////////////////5556enum OCL_FFT_TYPE57{58R2R = 0,59C2R = 1,60R2C = 2,61C2C = 362};6364typedef tuple<OCL_FFT_TYPE, Size, int> DftParams;65typedef TestBaseWithParam<DftParams> DftFixture;6667OCL_PERF_TEST_P(DftFixture, Dft, ::testing::Combine(Values(C2C, R2R, C2R, R2C),68Values(OCL_SIZE_1, OCL_SIZE_2, OCL_SIZE_3, Size(512, 512), Size(1024, 1024), Size(2048, 2048)),69Values((int) 0, (int)DFT_ROWS, (int)DFT_SCALE, (int)DFT_INVERSE,70(int)DFT_INVERSE | DFT_SCALE, (int)DFT_ROWS | DFT_INVERSE)))71{72const DftParams params = GetParam();73const int dft_type = get<0>(params);74const Size srcSize = get<1>(params);75int flags = get<2>(params);7677int in_cn = 0, out_cn = 0;78switch (dft_type)79{80case R2R: flags |= cv::DFT_REAL_OUTPUT; in_cn = 1; out_cn = 1; break;81case C2R: flags |= cv::DFT_REAL_OUTPUT; in_cn = 2; out_cn = 2; break;82case R2C: flags |= cv::DFT_COMPLEX_OUTPUT; in_cn = 1; out_cn = 2; break;83case C2C: flags |= cv::DFT_COMPLEX_OUTPUT; in_cn = 2; out_cn = 2; break;84}8586UMat src(srcSize, CV_MAKE_TYPE(CV_32F, in_cn)), dst(srcSize, CV_MAKE_TYPE(CV_32F, out_cn));87declare.in(src, WARMUP_RNG).out(dst);8889OCL_TEST_CYCLE() cv::dft(src, dst, flags);9091SANITY_CHECK(dst, 1e-5, ERROR_RELATIVE);92}9394///////////// MulSpectrums ////////////////////////9596typedef tuple<Size, bool> MulSpectrumsParams;97typedef TestBaseWithParam<MulSpectrumsParams> MulSpectrumsFixture;9899OCL_PERF_TEST_P(MulSpectrumsFixture, MulSpectrums,100::testing::Combine(Values(OCL_SIZE_1, OCL_SIZE_2, OCL_SIZE_3),101Bool()))102{103const MulSpectrumsParams params = GetParam();104const Size srcSize = get<0>(params);105const bool conj = get<1>(params);106107UMat src1(srcSize, CV_32FC2), src2(srcSize, CV_32FC2), dst(srcSize, CV_32FC2);108declare.in(src1, src2, WARMUP_RNG).out(dst);109110OCL_TEST_CYCLE() cv::mulSpectrums(src1, src2, dst, 0, conj);111112SANITY_CHECK(dst, 1e-3);113}114115} } // namespace opencv_test::ocl116117#endif // HAVE_OPENCL118119120