perf_accumulate.cpp 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. /*M///////////////////////////////////////////////////////////////////////////////////////
  2. //
  3. // IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
  4. //
  5. // By downloading, copying, installing or using the software you agree to this license.
  6. // If you do not agree to this license, do not download, install,
  7. // copy or use the software.
  8. //
  9. //
  10. // License Agreement
  11. // For Open Source Computer Vision Library
  12. //
  13. // Copyright (C) 2010-2012, Multicoreware, Inc., all rights reserved.
  14. // Copyright (C) 2010-2012, Advanced Micro Devices, Inc., all rights reserved.
  15. // Third party copyrights are property of their respective owners.
  16. //
  17. // @Authors
  18. // Nathan, liujun@multicorewareinc.com
  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 documentation
  28. // and/or other materials provided with the distribution.
  29. //
  30. // * The name of the copyright holders may not be used to endorse or promote products
  31. // derived from this software without specific prior written permission.
  32. //
  33. // This software is provided by the copyright holders and contributors as is and
  34. // any express or implied warranties, including, but not limited to, the implied
  35. // 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 damages
  38. // (including, but not limited to, procurement of substitute goods or services;
  39. // loss of use, data, or profits; or business interruption) however caused
  40. // and on any theory of liability, whether in contract, strict liability,
  41. // or tort (including negligence or otherwise) arising in any way out of
  42. // the use of this software, even if advised of the possibility of such damage.
  43. //
  44. //M*/
  45. #include "../perf_precomp.hpp"
  46. #include "opencv2/ts/ocl_perf.hpp"
  47. #ifdef HAVE_OPENCL
  48. namespace opencv_test {
  49. namespace ocl {
  50. /////////////////////////////////// Accumulate ///////////////////////////////////
  51. typedef Size_MatType AccumulateFixture;
  52. OCL_PERF_TEST_P(AccumulateFixture, Accumulate,
  53. ::testing::Combine(OCL_TEST_SIZES, OCL_TEST_TYPES))
  54. {
  55. Size_MatType_t params = GetParam();
  56. const Size srcSize = get<0>(params);
  57. const int srcType = get<1>(params), cn = CV_MAT_CN(srcType), dstType = CV_32FC(cn);
  58. checkDeviceMaxMemoryAllocSize(srcSize, dstType);
  59. UMat src(srcSize, srcType), dst(srcSize, dstType);
  60. declare.in(src, dst, WARMUP_RNG).out(dst);
  61. OCL_TEST_CYCLE() cv::accumulate(src, dst);
  62. SANITY_CHECK_NOTHING();
  63. }
  64. /////////////////////////////////// AccumulateSquare ///////////////////////////////////
  65. typedef Size_MatType AccumulateSquareFixture;
  66. OCL_PERF_TEST_P(AccumulateSquareFixture, AccumulateSquare,
  67. ::testing::Combine(OCL_TEST_SIZES, OCL_TEST_TYPES))
  68. {
  69. Size_MatType_t params = GetParam();
  70. const Size srcSize = get<0>(params);
  71. const int srcType = get<1>(params), cn = CV_MAT_CN(srcType), dstType = CV_32FC(cn);
  72. checkDeviceMaxMemoryAllocSize(srcSize, dstType);
  73. UMat src(srcSize, srcType), dst(srcSize, dstType);
  74. declare.in(src, dst, WARMUP_RNG);
  75. OCL_TEST_CYCLE() cv::accumulateSquare(src, dst);
  76. SANITY_CHECK_NOTHING();
  77. }
  78. /////////////////////////////////// AccumulateProduct ///////////////////////////////////
  79. typedef Size_MatType AccumulateProductFixture;
  80. OCL_PERF_TEST_P(AccumulateProductFixture, AccumulateProduct,
  81. ::testing::Combine(OCL_TEST_SIZES, OCL_TEST_TYPES))
  82. {
  83. Size_MatType_t params = GetParam();
  84. const Size srcSize = get<0>(params);
  85. const int srcType = get<1>(params), cn = CV_MAT_CN(srcType), dstType = CV_32FC(cn);
  86. checkDeviceMaxMemoryAllocSize(srcSize, dstType);
  87. UMat src1(srcSize, srcType), src2(srcSize, srcType), dst(srcSize, dstType);
  88. declare.in(src1, src2, dst, WARMUP_RNG);
  89. OCL_TEST_CYCLE() cv::accumulateProduct(src1, src2, dst);
  90. SANITY_CHECK_NOTHING();
  91. }
  92. /////////////////////////////////// AccumulateWeighted ///////////////////////////////////
  93. typedef Size_MatType AccumulateWeightedFixture;
  94. OCL_PERF_TEST_P(AccumulateWeightedFixture, AccumulateWeighted,
  95. ::testing::Combine(OCL_TEST_SIZES, OCL_TEST_TYPES))
  96. {
  97. Size_MatType_t params = GetParam();
  98. const Size srcSize = get<0>(params);
  99. const int srcType = get<1>(params), cn = CV_MAT_CN(srcType), dstType = CV_32FC(cn);
  100. checkDeviceMaxMemoryAllocSize(srcSize, dstType);
  101. UMat src(srcSize, srcType), dst(srcSize, dstType);
  102. declare.in(src, dst, WARMUP_RNG);
  103. OCL_TEST_CYCLE() cv::accumulateWeighted(src, dst, 2.0);
  104. SANITY_CHECK_NOTHING();
  105. }
  106. } } // namespace opencv_test::ocl
  107. #endif