GPU module performance tests are aligned with other OpenCV pefrofmance tests
This commit is contained in:
parent
10f1004465
commit
f5d6367ea1
@ -106,7 +106,7 @@ PERF_TEST_P(Image, Labeling_ConnectedComponents, Values<string>("gpu/labeling/al
|
|||||||
|
|
||||||
cv::Mat image = readImage(GetParam(), cv::IMREAD_GRAYSCALE);
|
cv::Mat image = readImage(GetParam(), cv::IMREAD_GRAYSCALE);
|
||||||
|
|
||||||
if (runOnGpu)
|
if (PERF_RUN_GPU())
|
||||||
{
|
{
|
||||||
cv::gpu::GpuMat mask;
|
cv::gpu::GpuMat mask;
|
||||||
mask.create(image.rows, image.cols, CV_8UC1);
|
mask.create(image.rows, image.cols, CV_8UC1);
|
||||||
@ -122,6 +122,8 @@ PERF_TEST_P(Image, Labeling_ConnectedComponents, Values<string>("gpu/labeling/al
|
|||||||
{
|
{
|
||||||
cv::gpu::labelComponents(mask, components);
|
cv::gpu::labelComponents(mask, components);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GPU_SANITY_CHECK(components);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -135,6 +137,8 @@ PERF_TEST_P(Image, Labeling_ConnectedComponents, Values<string>("gpu/labeling/al
|
|||||||
{
|
{
|
||||||
host(host._labels);
|
host(host._labels);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CPU_SANITY_CHECK(host._labels);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,72 +1,3 @@
|
|||||||
#include "perf_precomp.hpp"
|
#include "perf_precomp.hpp"
|
||||||
|
|
||||||
using namespace std;
|
CV_PERF_TEST_MAIN(gpu)
|
||||||
using namespace cv;
|
|
||||||
using namespace cv::gpu;
|
|
||||||
using namespace cvtest;
|
|
||||||
using namespace testing;
|
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
|
||||||
{
|
|
||||||
const std::string keys =
|
|
||||||
"{ h help ? | | Print help}"
|
|
||||||
"{ i info | | Print information about system and exit }"
|
|
||||||
"{ device | 0 | Device on which tests will be executed }"
|
|
||||||
"{ cpu | | Run tests on cpu }"
|
|
||||||
;
|
|
||||||
|
|
||||||
CommandLineParser cmd(argc, (const char**) argv, keys);
|
|
||||||
|
|
||||||
if (cmd.has("help"))
|
|
||||||
{
|
|
||||||
cmd.printMessage();
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
ts::printOsInfo();
|
|
||||||
ts::printCudaInfo();
|
|
||||||
|
|
||||||
|
|
||||||
if (cmd.has("info"))
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int device = cmd.get<int>("device");
|
|
||||||
bool cpu = cmd.has("cpu");
|
|
||||||
#if !defined HAVE_CUDA || defined(CUDA_DISABLER)
|
|
||||||
cpu = true;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (cpu)
|
|
||||||
{
|
|
||||||
runOnGpu = false;
|
|
||||||
|
|
||||||
cout << "Run tests on CPU \n" << endl;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
runOnGpu = true;
|
|
||||||
|
|
||||||
if (device < 0 || device >= getCudaEnabledDeviceCount())
|
|
||||||
{
|
|
||||||
cerr << "Incorrect device index - " << device << endl;
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
DeviceInfo info(device);
|
|
||||||
if (!info.isCompatible())
|
|
||||||
{
|
|
||||||
cerr << "Device " << device << " [" << info.name() << "] is NOT compatible with current GPU module build" << endl;
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
setDevice(device);
|
|
||||||
|
|
||||||
cout << "Run tests on device " << device << " [" << info.name() << "] \n" << endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
InitGoogleTest(&argc, argv);
|
|
||||||
perf::TestBase::Init(argc, argv);
|
|
||||||
return RUN_ALL_TESTS();
|
|
||||||
}
|
|
@ -53,4 +53,15 @@ namespace ts {
|
|||||||
void printCudaInfo();
|
void printCudaInfo();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define GPU_SANITY_CHECK(dmat, ...) \
|
||||||
|
do{ \
|
||||||
|
cv::Mat d##dmat(dmat); \
|
||||||
|
SANITY_CHECK(d##dmat, ## __VA_ARGS__); \
|
||||||
|
} while(0);
|
||||||
|
|
||||||
|
#define CPU_SANITY_CHECK(cmat, ...) \
|
||||||
|
do{ \
|
||||||
|
SANITY_CHECK(cmat, ## __VA_ARGS__); \
|
||||||
|
} while(0);
|
||||||
|
|
||||||
#endif // __OPENCV_PERF_GPU_UTILITY_HPP__
|
#endif // __OPENCV_PERF_GPU_UTILITY_HPP__
|
||||||
|
@ -205,6 +205,19 @@ private:
|
|||||||
#define SANITY_CHECK_KEYPOINTS(array, ...) ::perf::Regression::addKeypoints(this, #array, array , ## __VA_ARGS__)
|
#define SANITY_CHECK_KEYPOINTS(array, ...) ::perf::Regression::addKeypoints(this, #array, array , ## __VA_ARGS__)
|
||||||
#define SANITY_CHECK_MATCHES(array, ...) ::perf::Regression::addMatches(this, #array, array , ## __VA_ARGS__)
|
#define SANITY_CHECK_MATCHES(array, ...) ::perf::Regression::addMatches(this, #array, array , ## __VA_ARGS__)
|
||||||
|
|
||||||
|
#ifdef HAVE_CUDA
|
||||||
|
//#error "CUDA"
|
||||||
|
class CV_EXPORTS GpuPerf
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static bool targetDevice();
|
||||||
|
};
|
||||||
|
|
||||||
|
# define PERF_RUN_GPU() ::perf::GpuPerf::targetDevice()
|
||||||
|
#else
|
||||||
|
# define PERF_RUN_GPU()
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/*****************************************************************************************\
|
/*****************************************************************************************\
|
||||||
* Container for performance metrics *
|
* Container for performance metrics *
|
||||||
|
@ -26,6 +26,9 @@ const std::string command_line_keys =
|
|||||||
#endif
|
#endif
|
||||||
"{ perf_max_deviation |1.0 |}"
|
"{ perf_max_deviation |1.0 |}"
|
||||||
"{ help h | |print help info}"
|
"{ help h | |print help info}"
|
||||||
|
#ifdef HAVE_CUDA
|
||||||
|
"{ perf_run_cpu |false |run GPU performance tests for analogy CPU functions}"
|
||||||
|
#endif
|
||||||
;
|
;
|
||||||
|
|
||||||
static double param_max_outliers;
|
static double param_max_outliers;
|
||||||
@ -36,10 +39,15 @@ static uint64 param_seed;
|
|||||||
static double param_time_limit;
|
static double param_time_limit;
|
||||||
static int param_tbb_nthreads;
|
static int param_tbb_nthreads;
|
||||||
static bool param_write_sanity;
|
static bool param_write_sanity;
|
||||||
|
#ifdef HAVE_CUDA
|
||||||
|
static bool param_run_cpu;
|
||||||
|
#endif
|
||||||
#ifdef ANDROID
|
#ifdef ANDROID
|
||||||
static int param_affinity_mask;
|
static int param_affinity_mask;
|
||||||
static bool log_power_checkpoints;
|
static bool log_power_checkpoints;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#include <sys/syscall.h>
|
#include <sys/syscall.h>
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
static void setCurrentThreadAffinityMask(int mask)
|
static void setCurrentThreadAffinityMask(int mask)
|
||||||
@ -608,6 +616,10 @@ void TestBase::Init(int argc, const char* const argv[])
|
|||||||
log_power_checkpoints = args.has("perf_log_power_checkpoints");
|
log_power_checkpoints = args.has("perf_log_power_checkpoints");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE_CUDA
|
||||||
|
param_run_cpu = args.has("perf_run_cpu");
|
||||||
|
#endif
|
||||||
|
|
||||||
if (!args.check())
|
if (!args.check())
|
||||||
{
|
{
|
||||||
args.printErrors();
|
args.printErrors();
|
||||||
@ -1185,6 +1197,17 @@ TestBase::_declareHelper::_declareHelper(TestBase* t) : test(t)
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************************\
|
||||||
|
* ::perf::GpuPerf
|
||||||
|
\*****************************************************************************************/
|
||||||
|
#ifdef HAVE_CUDA
|
||||||
|
bool perf::GpuPerf::targetDevice()
|
||||||
|
{
|
||||||
|
return !param_run_cpu;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/*****************************************************************************************\
|
/*****************************************************************************************\
|
||||||
* ::perf::PrintTo
|
* ::perf::PrintTo
|
||||||
\*****************************************************************************************/
|
\*****************************************************************************************/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user