minor gpu tests fix

This commit is contained in:
Vladislav Vinogradov 2012-08-20 10:15:36 +04:00
parent a0aef244d6
commit ec7f9566e0
26 changed files with 134 additions and 195 deletions

View File

@ -73,7 +73,7 @@ void printCudaInfo()
int main(int argc, char** argv) int main(int argc, char** argv)
{ {
CommandLineParser cmd(argc, argv, CommandLineParser cmd(argc, (const char**) argv,
"{ print_info_only | print_info_only | false | Print information about system and exit }" "{ print_info_only | print_info_only | false | Print information about system and exit }"
"{ device | device | 0 | Device on which tests will be executed }" "{ device | device | 0 | Device on which tests will be executed }"
"{ cpu | cpu | false | Run tests on cpu }" "{ cpu | cpu | false | Run tests on cpu }"
@ -119,7 +119,7 @@ int main(int argc, char **argv)
cout << "Run tests on device " << device << " [" << info.name() << "] \n" << endl; cout << "Run tests on device " << device << " [" << info.name() << "] \n" << endl;
} }
testing::InitGoogleTest(&argc, argv); InitGoogleTest(&argc, argv);
perf::TestBase::Init(argc, argv); perf::TestBase::Init(argc, argv);
return RUN_ALL_TESTS(); return RUN_ALL_TESTS();
} }

View File

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

View File

@ -10,6 +10,8 @@ enum OutputLevel
OutputLevelFull OutputLevelFull
}; };
extern OutputLevel nvidiaTestOutputLevel;
bool nvidia_NPPST_Integral_Image(const std::string& test_data_path, OutputLevel outputLevel); 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_Squared_Integral_Image(const std::string& test_data_path, OutputLevel outputLevel);
bool nvidia_NPPST_RectStdDev(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*/ //M*/
#include "precomp.hpp" #include "test_precomp.hpp"
#ifdef HAVE_CUDA
namespace { namespace {
@ -343,3 +345,5 @@ INSTANTIATE_TEST_CASE_P(GPU_Calib3D, ReprojectImageTo3D, testing::Combine(
WHOLE_SUBMAT)); WHOLE_SUBMAT));
} // namespace } // namespace
#endif // HAVE_CUDA

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -59,6 +59,7 @@
#include <stdexcept> #include <stdexcept>
#include "cvconfig.h" #include "cvconfig.h"
#include "opencv2/core/core.hpp" #include "opencv2/core/core.hpp"
#include "opencv2/highgui/highgui.hpp" #include "opencv2/highgui/highgui.hpp"
#include "opencv2/calib3d/calib3d.hpp" #include "opencv2/calib3d/calib3d.hpp"
@ -72,6 +73,7 @@
#include "utility.hpp" #include "utility.hpp"
#include "interpolation.hpp" #include "interpolation.hpp"
#include "main_test_nvidia.h"
#ifdef HAVE_CUDA #ifdef HAVE_CUDA
#include <cuda.h> #include <cuda.h>

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -39,7 +39,7 @@
// //
//M*/ //M*/
#include "precomp.hpp" #include "test_precomp.hpp"
using namespace std; using namespace std;
using namespace cv; using namespace cv;
@ -182,105 +182,6 @@ void DeviceManager::loadAll()
} }
} }
class DevicesGenerator : public ParamGeneratorInterface<DeviceInfo>
{
public:
~DevicesGenerator();
ParamIteratorInterface<DeviceInfo>* Begin() const;
ParamIteratorInterface<DeviceInfo>* End() const;
private:
class Iterator : public ParamIteratorInterface<DeviceInfo>
{
public:
Iterator(const ParamGeneratorInterface<DeviceInfo>* base, vector<DeviceInfo>::const_iterator iterator);
virtual ~Iterator();
virtual const ParamGeneratorInterface<DeviceInfo>* BaseGenerator() const;
virtual void Advance();
virtual ParamIteratorInterface<DeviceInfo>* Clone() const;
virtual const DeviceInfo* Current() const;
virtual bool Equals(const ParamIteratorInterface<DeviceInfo>& other) const;
private:
Iterator(const Iterator& other);
const ParamGeneratorInterface<DeviceInfo>* const base_;
vector<DeviceInfo>::const_iterator iterator_;
mutable DeviceInfo value_;
};
};
DevicesGenerator::~DevicesGenerator()
{
}
ParamIteratorInterface<DeviceInfo>* DevicesGenerator::Begin() const
{
return new Iterator(this, DeviceManager::instance().values().begin());
}
ParamIteratorInterface<DeviceInfo>* DevicesGenerator::End() const
{
return new Iterator(this, DeviceManager::instance().values().end());
}
DevicesGenerator::Iterator::Iterator(const ParamGeneratorInterface<DeviceInfo>* base, vector<DeviceInfo>::const_iterator iterator)
: base_(base), iterator_(iterator)
{
}
DevicesGenerator::Iterator::~Iterator()
{
}
const ParamGeneratorInterface<DeviceInfo>* DevicesGenerator::Iterator::BaseGenerator() const
{
return base_;
}
void DevicesGenerator::Iterator::Advance()
{
++iterator_;
}
ParamIteratorInterface<DeviceInfo>* DevicesGenerator::Iterator::Clone() const
{
return new Iterator(*this);
}
const DeviceInfo* DevicesGenerator::Iterator::Current() const
{
value_ = *iterator_;
return &value_;
}
bool DevicesGenerator::Iterator::Equals(const ParamIteratorInterface<DeviceInfo>& other) const
{
GTEST_CHECK_(BaseGenerator() == other.BaseGenerator())
<< "The program attempted to compare iterators "
<< "from different generators." << endl;
return iterator_ == CheckedDowncastToActualType<const Iterator>(&other)->iterator_;
}
DevicesGenerator::Iterator::Iterator(const Iterator& other) :
ParamIteratorInterface<DeviceInfo>(), base_(other.base_), iterator_(other.iterator_)
{
}
ParamGenerator<DeviceInfo> DevicesGenerator_()
{
return ParamGenerator<DeviceInfo>(new DevicesGenerator);
}
////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////
// Additional assertion // Additional assertion

View File

@ -94,9 +94,7 @@ private:
std::vector<cv::gpu::DeviceInfo> devices_; std::vector<cv::gpu::DeviceInfo> devices_;
}; };
testing::internal::ParamGenerator<cv::gpu::DeviceInfo> DevicesGenerator_(); #define ALL_DEVICES testing::ValuesIn(DeviceManager::instance().values())
#define ALL_DEVICES DevicesGenerator_()
////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////
// Additional assertion // Additional assertion