Merge branch 'gpu-tests'

This commit is contained in:
Vladislav Vinogradov
2012-08-20 11:29:40 +04:00
57 changed files with 5056 additions and 7741 deletions

View File

@@ -39,7 +39,7 @@
//
//M*/
#include "precomp.hpp"
#include "test_precomp.hpp"
#ifdef HAVE_CUDA
@@ -49,87 +49,128 @@ using namespace cv::gpu;
using namespace cvtest;
using namespace testing;
void print_info()
void printOsInfo()
{
printf("\n");
#if defined _WIN32
# if defined _WIN64
puts("OS: Windows 64");
cout << "OS: Windows x64 \n" << endl;
# else
puts("OS: Windows 32");
cout << "OS: Windows x32 \n" << endl;
# endif
#elif defined linux
# if defined _LP64
puts("OS: Linux 64");
cout << "OS: Linux x64 \n" << endl;
# else
puts("OS: Linux 32");
cout << "OS: Linux x32 \n" << endl;
# endif
#elif defined __APPLE__
# if defined _LP64
puts("OS: Apple 64");
cout << "OS: Apple x64 \n" << endl;
# else
puts("OS: Apple 32");
cout << "OS: Apple x32 \n" << endl;
# endif
#endif
}
int deviceCount = getCudaEnabledDeviceCount();
void printCudaInfo()
{
#ifndef HAVE_CUDA
cout << "OpenCV was built without CUDA support \n" << endl;
#else
int driver;
cudaDriverGetVersion(&driver);
printf("CUDA Driver version: %d\n", driver);
printf("CUDA Runtime version: %d\n", CUDART_VERSION);
printf("CUDA device count: %d\n\n", deviceCount);
cout << "CUDA Driver version: " << driver << '\n';
cout << "CUDA Runtime version: " << CUDART_VERSION << '\n';
cout << endl;
cout << "GPU module was compiled for the following GPU archs:" << endl;
cout << " BIN: " << CUDA_ARCH_BIN << '\n';
cout << " PTX: " << CUDA_ARCH_PTX << '\n';
cout << endl;
int deviceCount = getCudaEnabledDeviceCount();
cout << "CUDA device count: " << deviceCount << '\n';
cout << endl;
for (int i = 0; i < deviceCount; ++i)
{
DeviceInfo info(i);
printf("Device %d:\n", i);
printf(" Name: %s\n", info.name().c_str());
printf(" Compute capability version: %d.%d\n", info.majorVersion(), info.minorVersion());
printf(" Total memory: %d Mb\n", static_cast<int>(static_cast<int>(info.totalMemory() / 1024.0) / 1024.0));
printf(" Free memory: %d Mb\n", static_cast<int>(static_cast<int>(info.freeMemory() / 1024.0) / 1024.0));
if (info.isCompatible())
puts(" This device is compatible with current GPU module build\n");
else
puts(" This device is NOT compatible with current GPU module build\n");
cout << "Device [" << i << "] \n";
cout << "\t Name: " << info.name() << '\n';
cout << "\t Compute capability: " << info.majorVersion() << '.' << info.minorVersion()<< '\n';
cout << "\t Multi Processor Count: " << info.multiProcessorCount() << '\n';
cout << "\t Total memory: " << static_cast<int>(static_cast<int>(info.totalMemory() / 1024.0) / 1024.0) << " Mb \n";
cout << "\t Free memory: " << static_cast<int>(static_cast<int>(info.freeMemory() / 1024.0) / 1024.0) << " Mb \n";
if (!info.isCompatible())
cout << "\t !!! This device is NOT compatible with current GPU module build \n";
cout << endl;
}
puts("GPU module was compiled for the following GPU archs:");
printf(" BIN: %s\n", CUDA_ARCH_BIN);
printf(" PTX: %s\n\n", CUDA_ARCH_PTX);
#endif
}
enum OutputLevel
{
OutputLevelNone,
OutputLevelCompact,
OutputLevelFull
};
extern OutputLevel nvidiaTestOutputLevel;
int main(int argc, char** argv)
{
TS::ptr()->init("gpu");
InitGoogleTest(&argc, argv);
try
{
CommandLineParser cmd(argc, (const char**)argv,
"{ print_info_only | print_info_only | false | Print information about system and exit }"
"{ device | device | -1 | Device on which tests will be executed (-1 means all devices) }"
"{ nvtest_output_level | nvtest_output_level | compact | NVidia test verbosity level }"
);
const char* keys ="{ nvtest_output_level | nvtest_output_level | compact | NVidia test verbosity level }";
printOsInfo();
printCudaInfo();
CommandLineParser parser(argc, (const char**)argv, keys);
if (cmd.get<bool>("print_info_only"))
return 0;
string outputLevel = parser.get<string>("nvtest_output_level", "none");
int device = cmd.get<int>("device");
if (device < 0)
{
DeviceManager::instance().loadAll();
if (outputLevel == "none")
nvidiaTestOutputLevel = OutputLevelNone;
else if (outputLevel == "compact")
nvidiaTestOutputLevel = OutputLevelCompact;
else if (outputLevel == "full")
nvidiaTestOutputLevel = OutputLevelFull;
cout << "Run tests on all supported devices \n" << endl;
}
else
{
DeviceManager::instance().load(device);
print_info();
DeviceInfo info(device);
cout << "Run tests on device " << device << " [" << info.name() << "] \n" << endl;
}
return RUN_ALL_TESTS();
string outputLevel = cmd.get<string>("nvtest_output_level");
if (outputLevel == "none")
nvidiaTestOutputLevel = OutputLevelNone;
else if (outputLevel == "compact")
nvidiaTestOutputLevel = OutputLevelCompact;
else if (outputLevel == "full")
nvidiaTestOutputLevel = OutputLevelFull;
TS::ptr()->init("gpu");
InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}
catch (const exception& e)
{
cerr << e.what() << endl;
return -1;
}
catch (...)
{
cerr << "Unknown error" << endl;
return -1;
}
return 0;
}
#else // HAVE_CUDA

View File

@@ -1,7 +1,7 @@
#ifndef __main_test_nvidia_h__
#define __main_test_nvidia_h__
#include<string>
#include <string>
enum OutputLevel
{
@@ -10,6 +10,8 @@ enum OutputLevel
OutputLevelFull
};
extern OutputLevel nvidiaTestOutputLevel;
bool nvidia_NPPST_Integral_Image(const std::string& test_data_path, OutputLevel outputLevel);
bool nvidia_NPPST_Squared_Integral_Image(const std::string& test_data_path, OutputLevel outputLevel);
bool nvidia_NPPST_RectStdDev(const std::string& test_data_path, OutputLevel outputLevel);

View File

@@ -39,7 +39,9 @@
//
//M*/
#include "precomp.hpp"
#include "test_precomp.hpp"
#ifdef HAVE_CUDA
namespace {
@@ -329,7 +331,7 @@ TEST_P(ReprojectImageTo3D, Accuracy)
cv::gpu::GpuMat dst;
cv::gpu::reprojectImageTo3D(loadMat(disp, useRoi), dst, Q, 3);
cv::Mat dst_gold;
cv::reprojectImageTo3D(disp, dst_gold, Q, false);
@@ -343,3 +345,5 @@ INSTANTIATE_TEST_CASE_P(GPU_Calib3D, ReprojectImageTo3D, testing::Combine(
WHOLE_SUBMAT));
} // namespace
#endif // HAVE_CUDA

View File

@@ -39,7 +39,7 @@
//
//M*/
#include "precomp.hpp"
#include "test_precomp.hpp"
#ifdef HAVE_CUDA

View File

@@ -39,7 +39,9 @@
//
//M*/
#include "precomp.hpp"
#include "test_precomp.hpp"
#ifdef HAVE_CUDA
namespace {
@@ -98,3 +100,5 @@ INSTANTIATE_TEST_CASE_P(GPU_ImgProc, CopyMakeBorder, testing::Combine(
WHOLE_SUBMAT));
} // namespace
#endif // HAVE_CUDA

View File

@@ -39,7 +39,9 @@
//
//M*/
#include "precomp.hpp"
#include "test_precomp.hpp"
#ifdef HAVE_CUDA
namespace {
@@ -3396,3 +3398,5 @@ INSTANTIATE_TEST_CASE_P(GPU_Core, Reduce, testing::Combine(
WHOLE_SUBMAT));
} // namespace
#endif // HAVE_CUDA

View File

@@ -39,7 +39,9 @@
//
//M*/
#include "precomp.hpp"
#include "test_precomp.hpp"
#ifdef HAVE_CUDA
namespace {
@@ -984,3 +986,5 @@ INSTANTIATE_TEST_CASE_P(GPU_Features2D, BruteForceMatcher, testing::Combine(
testing::Values(UseMask(false), UseMask(true))));
} // namespace
#endif // HAVE_CUDA

View File

@@ -39,7 +39,9 @@
//
//M*/
#include "precomp.hpp"
#include "test_precomp.hpp"
#ifdef HAVE_CUDA
namespace {
@@ -552,3 +554,5 @@ INSTANTIATE_TEST_CASE_P(GPU_Filter, Filter2D, testing::Combine(
WHOLE_SUBMAT));
} // namespace
#endif // HAVE_CUDA

View File

@@ -39,11 +39,11 @@
//
//M*/
#include "precomp.hpp"
#include "test_precomp.hpp"
#ifdef HAVE_CUDA
#include <iostream>
using namespace std;
using namespace cv;
struct CompactPoints : testing::TestWithParam<gpu::DeviceInfo>
@@ -85,3 +85,5 @@ TEST_P(CompactPoints, CanCompactizeSmallInput)
}
INSTANTIATE_TEST_CASE_P(GPU_GlobalMotion, CompactPoints, ALL_DEVICES);
#endif // HAVE_CUDA

View File

@@ -40,7 +40,9 @@
//
//M*/
#include "precomp.hpp"
#include "test_precomp.hpp"
#ifdef HAVE_CUDA
namespace {
@@ -323,3 +325,5 @@ INSTANTIATE_TEST_CASE_P(GPU_GpuMat, ConvertTo, testing::Combine(
WHOLE_SUBMAT));
} // namespace
#endif // HAVE_CUDA

View File

@@ -39,7 +39,9 @@
//
//M*/
#include "precomp.hpp"
#include "test_precomp.hpp"
#ifdef HAVE_CUDA
namespace {
@@ -1186,3 +1188,5 @@ INSTANTIATE_TEST_CASE_P(GPU_ImgProc, HoughLines, testing::Combine(
std::string("../cv/shared/pic6.png"))));
} // namespace
#endif // HAVE_CUDA

View File

@@ -39,9 +39,7 @@
// the use of this software, even if advised of the possibility of such damage.
//M*/
#include "precomp.hpp"
#include <string>
#include <iostream>
#include "test_precomp.hpp"
#ifdef HAVE_CUDA
@@ -199,4 +197,4 @@ TEST_P(Labeling, ConnectedComponents)
INSTANTIATE_TEST_CASE_P(ConnectedComponents, Labeling, ALL_DEVICES);
#endif
#endif // HAVE_CUDA

View File

@@ -39,21 +39,15 @@
//
//M*/
#include <main_test_nvidia.h>
#include "precomp.hpp"
#include "test_precomp.hpp"
OutputLevel nvidiaTestOutputLevel = OutputLevelCompact;
#ifdef HAVE_CUDA
using namespace cvtest;
using namespace testing;
//enum OutputLevel
//{
// OutputLevelNone,
// OutputLevelCompact,
// OutputLevelFull
//};
struct NVidiaTest : TestWithParam<cv::gpu::DeviceInfo>
{
cv::gpu::DeviceInfo devInfo;
@@ -73,8 +67,6 @@ struct NVidiaTest : TestWithParam<cv::gpu::DeviceInfo>
struct NPPST : NVidiaTest {};
struct NCV : NVidiaTest {};
OutputLevel nvidiaTestOutputLevel = OutputLevelCompact;
//TEST_P(NPPST, Integral)
//{
// bool res = nvidia_NPPST_Integral_Image(path, nvidiaTestOutputLevel);

View File

@@ -39,8 +39,9 @@
//
//M*/
#include "precomp.hpp"
#include <string>
#include "test_precomp.hpp"
#ifdef HAVE_CUDA
namespace {
@@ -373,3 +374,5 @@ INSTANTIATE_TEST_CASE_P(GPU_ObjDetect, LBP_classify,
testing::Combine(ALL_DEVICES, testing::Values<int>(0)));
} // namespace
#endif // HAVE_CUDA

View File

@@ -39,4 +39,4 @@
//
//M*/
#include "precomp.hpp"
#include "test_precomp.hpp"

View File

@@ -57,8 +57,10 @@
#include <limits>
#include <algorithm>
#include <iterator>
#include <stdexcept>
#include "cvconfig.h"
#include "opencv2/core/core.hpp"
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/calib3d/calib3d.hpp"
@@ -72,6 +74,7 @@
#include "utility.hpp"
#include "interpolation.hpp"
#include "main_test_nvidia.h"
#ifdef HAVE_CUDA
#include <cuda.h>

View File

@@ -39,7 +39,7 @@
//
//M*/
#include "precomp.hpp"
#include "test_precomp.hpp"
#ifdef HAVE_CUDA

View File

@@ -39,7 +39,7 @@
//
//M*/
#include "precomp.hpp"
#include "test_precomp.hpp"
#ifdef HAVE_CUDA

View File

@@ -39,8 +39,7 @@
//
//M*/
#include "precomp.hpp"
#include <iostream>
#include "test_precomp.hpp"
#ifdef HAVE_CUDA

View File

@@ -39,7 +39,7 @@
//
//M*/
#include "precomp.hpp"
#include "test_precomp.hpp"
#ifdef HAVE_CUDA

View File

@@ -39,7 +39,9 @@
//
//M*/
#include "precomp.hpp"
#include "test_precomp.hpp"
#ifdef HAVE_CUDA
//#define DUMP
@@ -865,3 +867,5 @@ TEST_P(VideoReader, Regression)
INSTANTIATE_TEST_CASE_P(GPU_Video, VideoReader, testing::Combine(
ALL_DEVICES,
testing::Values(std::string("768x576.avi"), std::string("1920x1080.avi"))));
#endif // HAVE_CUDA

View File

@@ -39,7 +39,7 @@
//
//M*/
#include "precomp.hpp"
#include "test_precomp.hpp"
#ifdef HAVE_CUDA

View File

@@ -39,7 +39,7 @@
//
//M*/
#include "precomp.hpp"
#include "test_precomp.hpp"
#ifdef HAVE_CUDA

View File

@@ -39,13 +39,14 @@
//
//M*/
#include "precomp.hpp"
#include "test_precomp.hpp"
using namespace std;
using namespace cv;
using namespace cv::gpu;
using namespace cvtest;
using namespace testing;
using namespace testing::internal;
//////////////////////////////////////////////////////////////////////
// random generators
@@ -108,12 +109,12 @@ GpuMat loadMat(const Mat& m, bool useRoi)
//////////////////////////////////////////////////////////////////////
// Image load
Mat readImage(const string& fileName, int flags)
Mat readImage(const std::string& fileName, int flags)
{
return imread(string(cvtest::TS::ptr()->get_data_path()) + fileName, flags);
return imread(TS::ptr()->get_data_path() + fileName, flags);
}
Mat readImageType(const string& fname, int type)
Mat readImageType(const std::string& fname, int type)
{
Mat src = readImage(fname, CV_MAT_CN(type) == 1 ? IMREAD_GRAYSCALE : IMREAD_COLOR);
if (CV_MAT_CN(type) == 4)
@@ -134,50 +135,51 @@ bool supportFeature(const DeviceInfo& info, FeatureSet feature)
return TargetArchs::builtWith(feature) && info.supports(feature);
}
const vector<DeviceInfo>& devices()
DeviceManager& DeviceManager::instance()
{
static vector<DeviceInfo> devs;
static bool first = true;
if (first)
{
int deviceCount = getCudaEnabledDeviceCount();
devs.reserve(deviceCount);
for (int i = 0; i < deviceCount; ++i)
{
DeviceInfo info(i);
if (info.isCompatible())
devs.push_back(info);
}
first = false;
}
return devs;
static DeviceManager obj;
return obj;
}
vector<DeviceInfo> devices(FeatureSet feature)
void DeviceManager::load(int i)
{
const vector<DeviceInfo>& d = devices();
devices_.clear();
devices_.reserve(1);
vector<DeviceInfo> devs_filtered;
ostringstream msg;
if (TargetArchs::builtWith(feature))
if (i < 0 || i >= getCudaEnabledDeviceCount())
{
devs_filtered.reserve(d.size());
for (size_t i = 0, size = d.size(); i < size; ++i)
{
const DeviceInfo& info = d[i];
if (info.supports(feature))
devs_filtered.push_back(info);
}
msg << "Incorrect device number - " << i;
throw runtime_error(msg.str());
}
return devs_filtered;
DeviceInfo info(i);
if (!info.isCompatible())
{
msg << "Device " << i << " [" << info.name() << "] is NOT compatible with current GPU module build";
throw runtime_error(msg.str());
}
devices_.push_back(info);
}
void DeviceManager::loadAll()
{
int deviceCount = getCudaEnabledDeviceCount();
devices_.clear();
devices_.reserve(deviceCount);
for (int i = 0; i < deviceCount; ++i)
{
DeviceInfo info(i);
if (info.isCompatible())
{
devices_.push_back(info);
}
}
}
//////////////////////////////////////////////////////////////////////
@@ -250,7 +252,7 @@ void minMaxLocGold(const Mat& src, double* minVal_, double* maxVal_, Point* minL
namespace
{
template <typename T, typename OutT> string printMatValImpl(const Mat& m, Point p)
template <typename T, typename OutT> std::string printMatValImpl(const Mat& m, Point p)
{
const int cn = m.channels();
@@ -269,9 +271,9 @@ namespace
return ostr.str();
}
string printMatVal(const Mat& m, Point p)
std::string printMatVal(const Mat& m, Point p)
{
typedef string (*func_t)(const Mat& m, Point p);
typedef std::string (*func_t)(const Mat& m, Point p);
static const func_t funcs[] =
{

View File

@@ -80,14 +80,21 @@ cv::Mat readImageType(const std::string& fname, int type);
//! return true if device supports specified feature and gpu module was built with support the feature.
bool supportFeature(const cv::gpu::DeviceInfo& info, cv::gpu::FeatureSet feature);
//! return all devices compatible with current gpu module build.
const std::vector<cv::gpu::DeviceInfo>& devices();
class DeviceManager
{
public:
static DeviceManager& instance();
//! return all devices compatible with current gpu module build which support specified feature.
std::vector<cv::gpu::DeviceInfo> devices(cv::gpu::FeatureSet feature);
void load(int i);
void loadAll();
#define ALL_DEVICES testing::ValuesIn(devices())
#define DEVICES(feature) testing::ValuesIn(devices(feature))
const std::vector<cv::gpu::DeviceInfo>& values() const { return devices_; }
private:
std::vector<cv::gpu::DeviceInfo> devices_;
};
#define ALL_DEVICES testing::ValuesIn(DeviceManager::instance().values())
//////////////////////////////////////////////////////////////////////
// Additional assertion