list(APPEND __dispatch_modes ${CPU_DISPATCH_${OPT}_FORCE} ${OPT})
endforeach()
list(REMOVE_DUPLICATES __dispatch_modes)
- set(OPENCV_CPU_DISPATCH_DEFINITIONS_CONFIGMAKE "")
foreach(OPT ${__dispatch_modes})
set(OPENCV_CPU_DISPATCH_DEFINITIONS_CONFIGMAKE "${OPENCV_CPU_DISPATCH_DEFINITIONS_CONFIGMAKE}
#define CV_CPU_DISPATCH_COMPILE_${OPT} 1")
endforeach()
+ set(OPENCV_CPU_DISPATCH_DEFINITIONS_CONFIGMAKE "${OPENCV_CPU_DISPATCH_DEFINITIONS_CONFIGMAKE}
+\n\n#define CV_CPU_DISPATCH_FEATURES 0 \\")
+ foreach(OPT ${__dispatch_modes})
+ if(NOT DEFINED CPU_${OPT}_FEATURE_ALIAS OR NOT "x${CPU_${OPT}_FEATURE_ALIAS}" STREQUAL "x")
+ set(OPENCV_CPU_DISPATCH_DEFINITIONS_CONFIGMAKE "${OPENCV_CPU_DISPATCH_DEFINITIONS_CONFIGMAKE}
+ , CV_CPU_${OPT} \\")
+ endif()
+ endforeach()
+ set(OPENCV_CPU_DISPATCH_DEFINITIONS_CONFIGMAKE "${OPENCV_CPU_DISPATCH_DEFINITIONS_CONFIGMAKE}\n")
+
set(OPENCV_CPU_CONTROL_DEFINITIONS_CONFIGMAKE "// AUTOGENERATED, DO NOT EDIT\n")
foreach(OPT ${CPU_ALL_OPTIMIZATIONS})
if(NOT DEFINED CPU_${OPT}_FEATURE_ALIAS OR NOT "x${CPU_${OPT}_FEATURE_ALIAS}" STREQUAL "x")
*/
CV_EXPORTS_W String getHardwareFeatureName(int feature);
+/** @brief Returns list of CPU features enabled during compilation.
+
+Returned value is a string containing space separated list of CPU features with following markers:
+
+- no markers - baseline features
+- prefix `*` - features enabled in dispatcher
+- suffix `?` - features enabled but not available in HW
+
+Example: `SSE SSE2 SSE3 *SSE4.1 *SSE4.2 *FP16 *AVX *AVX2 *AVX512-SKX?`
+*/
+CV_EXPORTS std::string getCPUFeaturesLine();
+
/** @brief Returns the number of logical CPUs available for the process.
*/
CV_EXPORTS_W int getNumberOfCPUs();
return name ? String(name) : String();
}
+std::string getCPUFeaturesLine()
+{
+ const int features[] = { CV_CPU_BASELINE_FEATURES, CV_CPU_DISPATCH_FEATURES };
+ const int sz = sizeof(features) / sizeof(features[0]);
+ std::string result;
+ std::string prefix;
+ for (int i = 1; i < sz; ++i)
+ {
+ if (features[i] == 0)
+ {
+ prefix = "*";
+ continue;
+ }
+ if (i != 1) result.append(" ");
+ result.append(prefix);
+ result.append(getHWFeatureNameSafe(features[i]));
+ if (!checkHardwareSupport(features[i])) result.append("?");
+ }
+ return result;
+}
+
volatile bool useOptimizedFlag = true;
void setUseOptimized( bool flag )
class TS
{
-public:
- // constructor(s) and destructor
TS();
virtual ~TS();
+public:
enum
{
SKIPPED=1
};
- // get file storage
- CvFileStorage* get_file_storage();
-
// get RNG to generate random input data for a test
RNG& get_rng() { return rng; }
void fillGradient(Mat& img, int delta = 5);
void smoothBorder(Mat& img, const Scalar& color, int delta = 3);
-void printVersionInfo(bool useStdOut = true);
-
-
// Utility functions
void addDataSearchPath(const std::string& path);
*/
std::string findDataDirectory(const std::string& relative_path, bool required = true);
+// Test definitions
+
+class SystemInfoCollector : public testing::EmptyTestEventListener
+{
+private:
+ virtual void OnTestProgramStart(const testing::UnitTest&);
+};
#ifndef __CV_TEST_EXEC_ARGS
#if defined(_MSC_VER) && (_MSC_VER <= 1400)
#endif
#endif
-#ifdef HAVE_OPENCL
-namespace ocl {
-void dumpOpenCLDevice();
-}
-#define TEST_DUMP_OCL_INFO cvtest::ocl::dumpOpenCLDevice();
-#else
-#define TEST_DUMP_OCL_INFO
-#endif
-
void parseCustomOptions(int argc, char **argv);
#define CV_TEST_INIT0_NOOP (void)0
ts->init(resourcesubdir); \
__CV_TEST_EXEC_ARGS(CV_TEST_INIT0_ ## INIT0) \
::testing::InitGoogleTest(&argc, argv); \
- cvtest::printVersionInfo(); \
- TEST_DUMP_OCL_INFO \
+ ::testing::UnitTest::GetInstance()->listeners().Append(new SystemInfoCollector); \
__CV_TEST_EXEC_ARGS(__VA_ARGS__) \
parseCustomOptions(argc, argv); \
} \
#endif
#endif
-#ifdef HAVE_OPENCL
-namespace cvtest { namespace ocl {
-void dumpOpenCLDevice();
-}}
-#define TEST_DUMP_OCL_INFO cvtest::ocl::dumpOpenCLDevice();
-#else
-#define TEST_DUMP_OCL_INFO
-#endif
-
#define CV_PERF_TEST_MAIN_INTERNALS(modulename, impls, ...) \
CV_TRACE_FUNCTION(); \
::perf::TestBase::Init(std::vector<std::string>(impls, impls + sizeof impls / sizeof *impls), \
argc, argv); \
::testing::InitGoogleTest(&argc, argv); \
- cvtest::printVersionInfo(); \
+ ::testing::UnitTest::GetInstance()->listeners().Append(new cvtest::SystemInfoCollector); \
::testing::Test::RecordProperty("cv_module_name", #modulename); \
::perf::TestBase::RecordRunParameters(); \
__CV_TEST_EXEC_ARGS(__VA_ARGS__) \
- TEST_DUMP_OCL_INFO \
} \
return RUN_ALL_TESTS();
#include "opencv2/ts/ocl_test.hpp"
-#ifdef HAVE_OPENCL
-
-#define DUMP_CONFIG_PROPERTY(propertyName, propertyValue) \
- do { \
- std::stringstream ssName, ssValue;\
- ssName << propertyName;\
- ssValue << (propertyValue); \
- ::testing::Test::RecordProperty(ssName.str(), ssValue.str()); \
- } while (false)
-
-#define DUMP_MESSAGE_STDOUT(msg) \
- do { \
- std::cout << msg << std::endl; \
- } while (false)
-
-#include <opencv2/core/opencl/opencl_info.hpp>
-
-#endif // HAVE_OPENCL
-
namespace cvtest {
namespace ocl {
int test_loop_times = 1; // TODO Read from command line / environment
-#ifdef HAVE_OPENCL
-void dumpOpenCLDevice()
-{
- cv::dumpOpenCLInformation();
-}
-#endif // HAVE_OPENCL
-
Mat TestUtils::readImage(const String &fileName, int flags)
{
return cv::imread(cvtest::TS::ptr()->get_data_path() + fileName, flags);
# include <sys/stat.h>
#endif
+#ifdef HAVE_OPENCL
+#define DUMP_CONFIG_PROPERTY(propertyName, propertyValue) \
+ do { \
+ std::stringstream ssName, ssValue;\
+ ssName << propertyName;\
+ ssValue << (propertyValue); \
+ ::testing::Test::RecordProperty(ssName.str(), ssValue.str()); \
+ } while (false)
+
+#define DUMP_MESSAGE_STDOUT(msg) \
+ do { \
+ std::cout << msg << std::endl; \
+ } while (false)
+
+#include "opencv2/core/opencl/opencl_info.hpp"
+
+#endif // HAVE_OPENCL
+
+#include "opencv2/core/utility.hpp"
#include "opencv_tests_config.hpp"
namespace opencv_test {
void BaseTest::safe_run( int start_from )
{
CV_TRACE_FUNCTION();
- read_params( ts->get_file_storage() );
ts->update_context( 0, -1, true );
ts->update_context( this, -1, true );
}
-CvFileStorage* TS::get_file_storage() { return 0; }
-
void TS::update_context( BaseTest* test, int test_case_idx, bool update_ts_context )
{
if( current_test_info.test != test )
}
-static TS ts;
-TS* TS::ptr() { return &ts; }
+TS* TS::ptr()
+{
+ static TS ts;
+ return &ts;
+}
void fillGradient(Mat& img, int delta)
{
return findData(relative_path, required, true);
}
+inline static std::string getSnippetFromConfig(const std::string & start, const std::string & end)
+{
+ const std::string buildInfo = cv::getBuildInformation();
+ size_t pos1 = buildInfo.find(start);
+ if (pos1 != std::string::npos)
+ {
+ pos1 += start.length();
+ pos1 = buildInfo.find_first_not_of(" \t\n\r", pos1);
+ }
+ size_t pos2 = buildInfo.find(end, pos1);
+ if (pos2 != std::string::npos)
+ {
+ pos2 = buildInfo.find_last_not_of(" \t\n\r", pos2);
+ }
+ if (pos1 != std::string::npos && pos2 != std::string::npos && pos1 < pos2)
+ {
+ return buildInfo.substr(pos1, pos2 - pos1 + 1);
+ }
+ return std::string();
+}
+
+inline static void recordPropertyVerbose(const std::string & property,
+ const std::string & msg,
+ const std::string & value,
+ const std::string & build_value = std::string())
+{
+ ::testing::Test::RecordProperty(property, value);
+ std::cout << msg << ": " << (value.empty() ? std::string("N/A") : value) << std::endl;
+ if (!build_value.empty())
+ {
+ ::testing::Test::RecordProperty(property + "_build", build_value);
+ if (build_value != value)
+ std::cout << "WARNING: build value differs from runtime: " << build_value << endl;
+ }
+}
+
+#ifdef _DEBUG
+#define CV_TEST_BUILD_CONFIG "Debug"
+#else
+#define CV_TEST_BUILD_CONFIG "Release"
+#endif
+
+void SystemInfoCollector::OnTestProgramStart(const testing::UnitTest&)
+{
+ std::cout << "CTEST_FULL_OUTPUT" << std::endl; // Tell CTest not to discard any output
+ recordPropertyVerbose("cv_version", "OpenCV version", cv::getVersionString(), CV_VERSION);
+ recordPropertyVerbose("cv_vcs_version", "OpenCV VCS version", getSnippetFromConfig("Version control:", "\n"));
+ recordPropertyVerbose("cv_build_type", "Build type", getSnippetFromConfig("Configuration:", "\n"), CV_TEST_BUILD_CONFIG);
+ recordPropertyVerbose("cv_compiler", "Compiler", getSnippetFromConfig("C++ Compiler:", "\n"));
+ recordPropertyVerbose("cv_parallel_framework", "Parallel framework", cv::currentParallelFramework());
+ recordPropertyVerbose("cv_cpu_features", "CPU features", cv::getCPUFeaturesLine());
+#ifdef HAVE_IPP
+ recordPropertyVerbose("cv_ipp_version", "Intel(R) IPP version", cv::ipp::useIPP() ? cv::ipp::getIppVersion() : "disabled");
+#endif
+#ifdef HAVE_OPENCL
+ cv::dumpOpenCLInformation();
+#endif
+}
+
} //namespace cvtest
/* End of file. */
#include <limits.h>
#include "opencv2/imgproc/types_c.h"
-#ifdef HAVE_TEGRA_OPTIMIZATION
-#include "tegra.hpp"
-#endif
-
using namespace cv;
namespace cvtest
<< "- " << expr2 << ":\n" << MatPart(m2part, border > 0 ? &loc : 0) << ".\n";
}
-void printVersionInfo(bool useStdOut)
-{
- // Tell CTest not to discard any output
- if(useStdOut) std::cout << "CTEST_FULL_OUTPUT" << std::endl;
-
- ::testing::Test::RecordProperty("cv_version", CV_VERSION);
- if(useStdOut) std::cout << "OpenCV version: " << CV_VERSION << std::endl;
-
- std::string buildInfo( cv::getBuildInformation() );
-
- size_t pos1 = buildInfo.find("Version control");
- size_t pos2 = buildInfo.find('\n', pos1);
- if(pos1 != std::string::npos && pos2 != std::string::npos)
- {
- size_t value_start = buildInfo.rfind(' ', pos2) + 1;
- std::string ver( buildInfo.substr(value_start, pos2 - value_start) );
- ::testing::Test::RecordProperty("cv_vcs_version", ver);
- if (useStdOut) std::cout << "OpenCV VCS version: " << ver << std::endl;
- }
-
- pos1 = buildInfo.find("inner version");
- pos2 = buildInfo.find('\n', pos1);
- if(pos1 != std::string::npos && pos2 != std::string::npos)
- {
- size_t value_start = buildInfo.rfind(' ', pos2) + 1;
- std::string ver( buildInfo.substr(value_start, pos2 - value_start) );
- ::testing::Test::RecordProperty("cv_inner_vcs_version", ver);
- if(useStdOut) std::cout << "Inner VCS version: " << ver << std::endl;
- }
-
- const char * build_type =
-#ifdef _DEBUG
- "debug";
-#else
- "release";
-#endif
-
- ::testing::Test::RecordProperty("cv_build_type", build_type);
- if (useStdOut) std::cout << "Build type: " << build_type << std::endl;
-
- const char* parallel_framework = currentParallelFramework();
-
- if (parallel_framework) {
- ::testing::Test::RecordProperty("cv_parallel_framework", parallel_framework);
- if (useStdOut) std::cout << "Parallel framework: " << parallel_framework << std::endl;
- }
-
- std::string cpu_features;
-
-#if CV_POPCNT
- if (checkHardwareSupport(CV_CPU_POPCNT)) cpu_features += " popcnt";
-#endif
-#if CV_MMX
- if (checkHardwareSupport(CV_CPU_MMX)) cpu_features += " mmx";
-#endif
-#if CV_SSE
- if (checkHardwareSupport(CV_CPU_SSE)) cpu_features += " sse";
-#endif
-#if CV_SSE2
- if (checkHardwareSupport(CV_CPU_SSE2)) cpu_features += " sse2";
-#endif
-#if CV_SSE3
- if (checkHardwareSupport(CV_CPU_SSE3)) cpu_features += " sse3";
-#endif
-#if CV_SSSE3
- if (checkHardwareSupport(CV_CPU_SSSE3)) cpu_features += " ssse3";
-#endif
-#if CV_SSE4_1
- if (checkHardwareSupport(CV_CPU_SSE4_1)) cpu_features += " sse4.1";
-#endif
-#if CV_SSE4_2
- if (checkHardwareSupport(CV_CPU_SSE4_2)) cpu_features += " sse4.2";
-#endif
-#if CV_AVX
- if (checkHardwareSupport(CV_CPU_AVX)) cpu_features += " avx";
-#endif
-#if CV_AVX2
- if (checkHardwareSupport(CV_CPU_AVX2)) cpu_features += " avx2";
-#endif
-#if CV_FMA3
- if (checkHardwareSupport(CV_CPU_FMA3)) cpu_features += " fma3";
-#endif
-#if CV_AVX_512F
- if (checkHardwareSupport(CV_CPU_AVX_512F)) cpu_features += " avx-512f";
-#endif
-#if CV_AVX_512BW
- if (checkHardwareSupport(CV_CPU_AVX_512BW)) cpu_features += " avx-512bw";
-#endif
-#if CV_AVX_512CD
- if (checkHardwareSupport(CV_CPU_AVX_512CD)) cpu_features += " avx-512cd";
-#endif
-#if CV_AVX_512DQ
- if (checkHardwareSupport(CV_CPU_AVX_512DQ)) cpu_features += " avx-512dq";
-#endif
-#if CV_AVX_512ER
- if (checkHardwareSupport(CV_CPU_AVX_512ER)) cpu_features += " avx-512er";
-#endif
-#if CV_AVX_512IFMA512
- if (checkHardwareSupport(CV_CPU_AVX_512IFMA512)) cpu_features += " avx-512ifma512";
-#endif
-#if CV_AVX_512PF
- if (checkHardwareSupport(CV_CPU_AVX_512PF)) cpu_features += " avx-512pf";
-#endif
-#if CV_AVX_512VBMI
- if (checkHardwareSupport(CV_CPU_AVX_512VBMI)) cpu_features += " avx-512vbmi";
-#endif
-#if CV_AVX_512VL
- if (checkHardwareSupport(CV_CPU_AVX_512VL)) cpu_features += " avx-512vl";
-#endif
-#if CV_NEON
- if (checkHardwareSupport(CV_CPU_NEON)) cpu_features += " neon";
-#endif
-#if CV_FP16
- if (checkHardwareSupport(CV_CPU_FP16)) cpu_features += " fp16";
-#endif
-#if CV_VSX
- if (checkHardwareSupport(CV_CPU_VSX)) cpu_features += " VSX";
-#endif
-
- cpu_features.erase(0, 1); // erase initial space
-
- ::testing::Test::RecordProperty("cv_cpu_features", cpu_features);
- if (useStdOut) std::cout << "CPU features: " << cpu_features << std::endl;
-
-#ifdef HAVE_TEGRA_OPTIMIZATION
- const char * tegra_optimization = tegra::useTegra() && tegra::isDeviceSupported() ? "enabled" : "disabled";
- ::testing::Test::RecordProperty("cv_tegra_optimization", tegra_optimization);
- if (useStdOut) std::cout << "Tegra optimization: " << tegra_optimization << std::endl;
-#endif
-
-#ifdef HAVE_IPP
- const char * ipp_optimization = cv::ipp::useIPP()? "enabled" : "disabled";
- ::testing::Test::RecordProperty("cv_ipp_optimization", ipp_optimization);
- if (useStdOut) std::cout << "Intel(R) IPP optimization: " << ipp_optimization << std::endl;
-
- cv::String ippVer = cv::ipp::getIppVersion();
- ::testing::Test::RecordProperty("cv_ipp_version", ippVer);
- if(useStdOut) std::cout << "Intel(R) IPP version: " << ippVer.c_str() << std::endl;
-#endif
-}
-
-
-
void threshold( const Mat& _src, Mat& _dst,
double thresh, double maxval, int thresh_type )
{