提交 fbdb4f4a 编写于 作者: A Anatoly Baksheev

1) gpu test refactoring.

2) fixed gpu bm test fail
3) CMAKE_MINIMUM_REQUIRED(VERSION 2.8.3)

上级 7e2cc1be
......@@ -7,8 +7,8 @@
# CUDA_NPP_LIBRARIES -- NPP libraries.
# NPP_VERSION -- NPP version in format "major.minor.build".
#
# If not found automatically, please set CUDA_NPP_LIBRARY_ROOT_DIR or
# set enviroment varivabe $CUDA_NPP_ROOT
# If not found automatically, please set CUDA_NPP_LIBRARY_ROOT_DIR
# in CMake or set enviroment varivabe $CUDA_NPP_ROOT
#
# Author: Anatoly Baksheev, Itseez Ltd.
#
......@@ -35,89 +35,88 @@
#
###############################################################################
# We need to have at least this version to support the VERSION_LESS argument to 'if' (2.6.2) and unset (2.6.3)
cmake_policy(PUSH)
cmake_minimum_required(VERSION 2.6.3)
cmake_minimum_required(VERSION 2.8.3)
cmake_policy(POP)
if(NOT "${CUDA_NPP_LIBRARY_ROOT_DIR}" STREQUAL "${CUDA_NPP_LIBRARY_ROOT_DIR_INTERNAL}")
unset(CUDA_NPP_INCLUDES CACHE)
unset(CUDA_NPP_LIBRARIES CACHE)
unset(CUDA_NPP_INCLUDES CACHE)
unset(CUDA_NPP_LIBRARIES CACHE)
endif()
if(CMAKE_SIZEOF_VOID_P EQUAL 4)
if (UNIX OR APPLE)
set(NPP_SUFFIX "32")
else()
set(NPP_SUFFIX "-mt")
endif()
if (UNIX OR APPLE)
set(NPP_SUFFIX "32")
else()
set(NPP_SUFFIX "-mt")
endif()
else(CMAKE_SIZEOF_VOID_P EQUAL 4)
if (UNIX OR APPLE)
set(NPP_SUFFIX "64")
else()
set(NPP_SUFFIX "-mt-x64")
endif()
if (UNIX OR APPLE)
set(NPP_SUFFIX "64")
else()
set(NPP_SUFFIX "-mt-x64")
endif()
endif(CMAKE_SIZEOF_VOID_P EQUAL 4)
if(NOT CUDA_NPP_LIBRARY_ROOT_DIR OR CUDA_NPP_LIBRARY_ROOT_DIR STREQUAL "")
unset(CUDA_NPP_LIBRARY_ROOT_DIR CACHE)
find_path(CUDA_NPP_LIBRARY_ROOT_DIR "common/npp/include/npp.h" PATHS ENV CUDA_NPP_ROOT DOC "NPP root directory.")
MESSAGE(STATUS "NPP root directory: " ${CUDA_NPP_LIBRARY_ROOT_DIR})
unset(CUDA_NPP_LIBRARY_ROOT_DIR CACHE)
find_path(CUDA_NPP_LIBRARY_ROOT_DIR "common/npp/include/npp.h" PATHS ENV CUDA_NPP_ROOT DOC "NPP root directory.")
MESSAGE(STATUS "NPP root directory: " ${CUDA_NPP_LIBRARY_ROOT_DIR})
endif()
# Search includes in our own paths.
find_path(CUDA_NPP_INCLUDES npp.h PATHS "${CUDA_NPP_LIBRARY_ROOT_DIR}/common/npp/include")
# Search default search paths, after we search our own set of paths.
find_path(CUDA_NPP_INCLUDES device_functions.h)
mark_as_advanced(CUDA_NPP_INCLUDES)
mark_as_advanced(CUDA_NPP_INCLUDES)
# Find NPP library
find_library(CUDA_NPP_LIBRARIES
NAMES "npp" "npp${NPP_SUFFIX}" "libnpp${NPP_SUFFIX}"
PATHS "${CUDA_NPP_LIBRARY_ROOT_DIR}"
PATH_SUFFIXES "common/lib" "common/npp/lib"
DOC "NPP library"
)
NAMES "npp" "npp${NPP_SUFFIX}" "libnpp${NPP_SUFFIX}"
PATHS "${CUDA_NPP_LIBRARY_ROOT_DIR}"
PATH_SUFFIXES "common/lib" "common/npp/lib"
DOC "NPP library"
)
# Search default search paths, after we search our own set of paths.
find_library(CUDA_NPP_LIBRARIES NAMES npp${NPP_SUFFIX} libnpp${NPP_SUFFIX} DOC "NPP library")
mark_as_advanced(CUDA_NPP_LIBRARIES)
if(EXISTS ${CUDA_NPP_INCLUDES}/nppversion.h)
file( STRINGS ${CUDA_NPP_INCLUDES}/nppversion.h npp_major REGEX "#define NPP_VERSION_MAJOR.*")
file( STRINGS ${CUDA_NPP_INCLUDES}/nppversion.h npp_minor REGEX "#define NPP_VERSION_MINOR.*")
file( STRINGS ${CUDA_NPP_INCLUDES}/nppversion.h npp_build REGEX "#define NPP_VERSION_BUILD.*")
string( REGEX REPLACE "#define NPP_VERSION_MAJOR[ \t]+|//.*" "" npp_major ${npp_major})
string( REGEX REPLACE "#define NPP_VERSION_MINOR[ \t]+|//.*" "" npp_minor ${npp_minor})
string( REGEX REPLACE "#define NPP_VERSION_BUILD[ \t]+|//.*" "" npp_build ${npp_build})
string( REGEX MATCH "[0-9]+" npp_major ${npp_major} )
string( REGEX MATCH "[0-9]+" npp_minor ${npp_minor} )
string( REGEX MATCH "[0-9]+" npp_build ${npp_build} )
set( NPP_VERSION "${npp_major}.${npp_minor}.${npp_build}")
file( STRINGS ${CUDA_NPP_INCLUDES}/nppversion.h npp_major REGEX "#define NPP_VERSION_MAJOR.*")
file( STRINGS ${CUDA_NPP_INCLUDES}/nppversion.h npp_minor REGEX "#define NPP_VERSION_MINOR.*")
file( STRINGS ${CUDA_NPP_INCLUDES}/nppversion.h npp_build REGEX "#define NPP_VERSION_BUILD.*")
string( REGEX REPLACE "#define NPP_VERSION_MAJOR[ \t]+|//.*" "" npp_major ${npp_major})
string( REGEX REPLACE "#define NPP_VERSION_MINOR[ \t]+|//.*" "" npp_minor ${npp_minor})
string( REGEX REPLACE "#define NPP_VERSION_BUILD[ \t]+|//.*" "" npp_build ${npp_build})
string( REGEX MATCH "[0-9]+" npp_major ${npp_major} )
string( REGEX MATCH "[0-9]+" npp_minor ${npp_minor} )
string( REGEX MATCH "[0-9]+" npp_build ${npp_build} )
set( NPP_VERSION "${npp_major}.${npp_minor}.${npp_build}")
endif()
if(NOT EXISTS ${CUDA_NPP_LIBRARIES} OR NOT EXISTS ${CUDA_NPP_INCLUDES}/npp.h)
set(CUDA_NPP_FOUND FALSE)
message(FATAL_ERROR "NPP headers/libraries are not found. Please specify CUDA_NPP_LIBRARY_ROOT_DIR in CMake or set $NPP_ROOT_DIR.")
set(CUDA_NPP_FOUND FALSE)
message(FATAL_ERROR "NPP headers/libraries are not found. Please specify CUDA_NPP_LIBRARY_ROOT_DIR in CMake or set $NPP_ROOT_DIR.")
endif()
include( FindPackageHandleStandardArgs )
find_package_handle_standard_args( NPP
REQUIRED_VARS
CUDA_NPP_INCLUDES
CUDA_NPP_LIBRARIES
# Don't remove!!! Please update your CMake.
VERSION_VAR
NPP_VERSION)
REQUIRED_VARS
CUDA_NPP_INCLUDES
CUDA_NPP_LIBRARIES
# Don't remove!!! Please update your CMake.
VERSION_VAR
NPP_VERSION)
if(APPLE)
# We need to add the path to cudart to the linker using rpath, since the library name for the cuda libraries is prepended with @rpath.
get_filename_component(_cuda_path_to_npp "${CUDA_NPP_LIBRARIES}" PATH)
if(_cuda_path_to_npp)
list(APPEND CUDA_NPP_LIBRARIES -Wl,-rpath "-Wl,${_cuda_path_to_npp}")
endif()
# We need to add the path to cudart to the linker using rpath, since the library name for the cuda libraries is prepended with @rpath.
get_filename_component(_cuda_path_to_npp "${CUDA_NPP_LIBRARIES}" PATH)
if(_cuda_path_to_npp)
list(APPEND CUDA_NPP_LIBRARIES -Wl,-rpath "-Wl,${_cuda_path_to_npp}")
endif()
endif()
set(CUDA_NPP_FOUND TRUE)
......
......@@ -117,13 +117,13 @@ void CV_GpuArithmTest::run( int )
try
{
const int types[] = {CV_8UC1, CV_8UC3, CV_8UC4, CV_32FC1};
const char* type_names[] = {"CV_8UC1", "CV_8UC3", "CV_8UC4", "CV_32FC1"};
const char* type_names[] = {"CV_8UC1 ", "CV_8UC3 ", "CV_8UC4 ", "CV_32FC1"};
const int type_count = sizeof(types)/sizeof(types[0]);
//run tests
for (int t = 0; t < type_count; ++t)
{
ts->printf(CvTS::LOG, "========Start test %s========\n", type_names[t]);
ts->printf(CvTS::LOG, "Start testing %s", type_names[t]);
if (CvTS::OK == test(types[t]))
ts->printf(CvTS::LOG, "SUCCESS\n");
......@@ -155,7 +155,7 @@ struct CV_GpuNppImageAddTest : public CV_GpuArithmTest
{
if (mat1.type() != CV_8UC1 && mat1.type() != CV_8UC4 && mat1.type() != CV_32FC1)
{
ts->printf(CvTS::LOG, "\nUnsupported type\n");
ts->printf(CvTS::LOG, "\tUnsupported type\t");
return CvTS::OK;
}
......@@ -181,7 +181,7 @@ struct CV_GpuNppImageSubtractTest : public CV_GpuArithmTest
{
if (mat1.type() != CV_8UC1 && mat1.type() != CV_8UC4 && mat1.type() != CV_32FC1)
{
ts->printf(CvTS::LOG, "\nUnsupported type\n");
ts->printf(CvTS::LOG, "\tUnsupported type\t");
return CvTS::OK;
}
......@@ -207,7 +207,7 @@ struct CV_GpuNppImageMultiplyTest : public CV_GpuArithmTest
{
if (mat1.type() != CV_8UC1 && mat1.type() != CV_8UC4 && mat1.type() != CV_32FC1)
{
ts->printf(CvTS::LOG, "\nUnsupported type\n");
ts->printf(CvTS::LOG, "\tUnsupported type\t");
return CvTS::OK;
}
......@@ -233,7 +233,7 @@ struct CV_GpuNppImageDivideTest : public CV_GpuArithmTest
{
if (mat1.type() != CV_8UC1 && mat1.type() != CV_8UC4 && mat1.type() != CV_32FC1)
{
ts->printf(CvTS::LOG, "\nUnsupported type\n");
ts->printf(CvTS::LOG, "\tUnsupported type\t");
return CvTS::OK;
}
......@@ -259,7 +259,7 @@ struct CV_GpuNppImageTransposeTest : public CV_GpuArithmTest
{
if (mat1.type() != CV_8UC1)
{
ts->printf(CvTS::LOG, "\nUnsupported type\n");
ts->printf(CvTS::LOG, "\tUnsupported type\t");
return CvTS::OK;
}
......@@ -284,7 +284,7 @@ struct CV_GpuNppImageAbsdiffTest : public CV_GpuArithmTest
{
if (mat1.type() != CV_8UC1 && mat1.type() != CV_8UC4 && mat1.type() != CV_32FC1)
{
ts->printf(CvTS::LOG, "\nUnsupported type\n");
ts->printf(CvTS::LOG, "\tUnsupported type\t");
return CvTS::OK;
}
......@@ -310,7 +310,7 @@ struct CV_GpuNppImageCompareTest : public CV_GpuArithmTest
{
if (mat1.type() != CV_32FC1)
{
ts->printf(CvTS::LOG, "\nUnsupported type\n");
ts->printf(CvTS::LOG, "\tUnsupported type\t");
return CvTS::OK;
}
......@@ -350,7 +350,7 @@ struct CV_GpuNppImageMeanStdDevTest : public CV_GpuArithmTest
{
if (mat1.type() != CV_8UC1)
{
ts->printf(CvTS::LOG, "\nUnsupported type\n");
ts->printf(CvTS::LOG, "\tUnsupported type\t");
return CvTS::OK;
}
......@@ -391,7 +391,7 @@ struct CV_GpuNppImageNormTest : public CV_GpuArithmTest
{
if (mat1.type() != CV_8UC1)
{
ts->printf(CvTS::LOG, "\nUnsupported type\n");
ts->printf(CvTS::LOG, "\tUnsupported type\t");
return CvTS::OK;
}
......@@ -429,7 +429,7 @@ struct CV_GpuNppImageFlipTest : public CV_GpuArithmTest
{
if (mat1.type() != CV_8UC1 && mat1.type() != CV_8UC4)
{
ts->printf(CvTS::LOG, "\nUnsupported type\n");
ts->printf(CvTS::LOG, "\tUnsupported type\t");
return CvTS::OK;
}
......@@ -468,7 +468,7 @@ struct CV_GpuNppImageSumTest : public CV_GpuArithmTest
{
if (mat1.type() != CV_8UC1 && mat1.type() != CV_8UC4)
{
ts->printf(CvTS::LOG, "\nUnsupported type\n");
ts->printf(CvTS::LOG, "\tUnsupported type\t");
return CvTS::OK;
}
......@@ -491,7 +491,7 @@ struct CV_GpuNppImageLUTTest : public CV_GpuArithmTest
{
if (mat1.type() != CV_8UC1 && mat1.type() != CV_8UC3)
{
ts->printf(CvTS::LOG, "\nUnsupported type\n");
ts->printf(CvTS::LOG, "\tUnsupported type\t");
return CvTS::OK;
}
......@@ -519,7 +519,7 @@ struct CV_GpuNppImageExpTest : public CV_GpuArithmTest
{
if (mat1.type() != CV_32FC1)
{
ts->printf(CvTS::LOG, "\nUnsupported type\n");
ts->printf(CvTS::LOG, "\tUnsupported type\t");
return CvTS::OK;
}
......@@ -544,7 +544,7 @@ struct CV_GpuNppImageLogTest : public CV_GpuArithmTest
{
if (mat1.type() != CV_32FC1)
{
ts->printf(CvTS::LOG, "\nUnsupported type\n");
ts->printf(CvTS::LOG, "\tUnsupported type\t");
return CvTS::OK;
}
......@@ -569,7 +569,7 @@ struct CV_GpuNppImageMagnitudeTest : public CV_GpuArithmTest
{
if (mat1.type() != CV_32FC1)
{
ts->printf(CvTS::LOG, "\nUnsupported type\n");
ts->printf(CvTS::LOG, "\tUnsupported type\t");
return CvTS::OK;
}
......@@ -595,7 +595,7 @@ struct CV_GpuNppImagePhaseTest : public CV_GpuArithmTest
{
if (mat1.type() != CV_32FC1)
{
ts->printf(CvTS::LOG, "\nUnsupported type\n");
ts->printf(CvTS::LOG, "\tUnsupported type\t");
return CvTS::OK;
}
......@@ -621,7 +621,7 @@ struct CV_GpuNppImageCartToPolarTest : public CV_GpuArithmTest
{
if (mat1.type() != CV_32FC1)
{
ts->printf(CvTS::LOG, "\nUnsupported type\n");
ts->printf(CvTS::LOG, "\tUnsupported type\t");
return CvTS::OK;
}
......@@ -650,7 +650,7 @@ struct CV_GpuNppImagePolarToCartTest : public CV_GpuArithmTest
{
if (mat1.type() != CV_32FC1)
{
ts->printf(CvTS::LOG, "\nUnsupported type\n");
ts->printf(CvTS::LOG, "\tUnsupported type\t");
return CvTS::OK;
}
......
......@@ -83,7 +83,7 @@ protected:
if (res <= 1)
return CvTS::OK;
ts->printf(CvTS::LOG, "\nNorm: %f\n", res);
ts->printf(CvTS::LOG, "Norm: %f\n", res);
return CvTS::FAIL_GENERIC;
}
};
......@@ -244,7 +244,7 @@ struct CV_GpuNppImageGaussianBlurTest : public CV_GpuNppFilterTest
{
cv::Size ksize(ksizes[i], ksizes[j]);
ts->printf(CvTS::LOG, "\nksize = (%dx%d)\n", ksizes[i], ksizes[j]);
ts->printf(CvTS::LOG, "ksize = (%dx%d)\t", ksizes[i], ksizes[j]);
Mat cpudst;
cv::GaussianBlur(img, cpudst, ksize, sigma1);
......
......@@ -45,7 +45,7 @@ CvTS test_system("gpu");
const char* blacklist[] =
{
"GPU-MatOperatorAsyncCall", // crash
"GPU-AsyncGpuMatOperator", // crash
"GPU-NppImageSum", // crash, probably npp bug
......
......@@ -112,7 +112,7 @@ int CV_GpuImageProcTest::CheckNorm(const Mat& m1, const Mat& m2)
}
else
{
ts->printf(CvTS::LOG, "\nNorm: %f\n", ret);
ts->printf(CvTS::LOG, "Norm: %f\n", ret);
return CvTS::FAIL_GENERIC;
}
}
......@@ -134,37 +134,37 @@ void CV_GpuImageProcTest::run( int )
//run tests
ts->printf(CvTS::LOG, "\n========Start test 8UC1========\n");
if (test8UC1(img) == CvTS::OK)
ts->printf(CvTS::LOG, "\nSUCCESS\n");
ts->printf(CvTS::LOG, "SUCCESS\n");
else
{
ts->printf(CvTS::LOG, "\nFAIL\n");
ts->printf(CvTS::LOG, "FAIL\n");
testResult = CvTS::FAIL_GENERIC;
}
ts->printf(CvTS::LOG, "\n========Start test 8UC4========\n");
if (test8UC4(img) == CvTS::OK)
ts->printf(CvTS::LOG, "\nSUCCESS\n");
ts->printf(CvTS::LOG, "SUCCESS\n");
else
{
ts->printf(CvTS::LOG, "\nFAIL\n");
ts->printf(CvTS::LOG, "FAIL\n");
testResult = CvTS::FAIL_GENERIC;
}
ts->printf(CvTS::LOG, "\n========Start test 32SC1========\n");
if (test32SC1(img) == CvTS::OK)
ts->printf(CvTS::LOG, "\nSUCCESS\n");
ts->printf(CvTS::LOG, "SUCCESS\n");
else
{
ts->printf(CvTS::LOG, "\nFAIL\n");
ts->printf(CvTS::LOG, "FAIL\n");
testResult = CvTS::FAIL_GENERIC;
}
ts->printf(CvTS::LOG, "\n========Start test 32FC1========\n");
if (test32FC1(img) == CvTS::OK)
ts->printf(CvTS::LOG, "\nSUCCESS\n");
ts->printf(CvTS::LOG, "SUCCESS\n");
else
{
ts->printf(CvTS::LOG, "\nFAIL\n");
ts->printf(CvTS::LOG, "FAIL\n");
testResult = CvTS::FAIL_GENERIC;
}
}
......@@ -216,7 +216,7 @@ struct CV_GpuNppImageResizeTest : public CV_GpuImageProcTest
{
if (img.type() != CV_8UC1 && img.type() != CV_8UC4)
{
ts->printf(CvTS::LOG, "\nUnsupported type\n");
ts->printf(CvTS::LOG, "Unsupported type\n");
return CvTS::OK;
}
......@@ -228,7 +228,7 @@ struct CV_GpuNppImageResizeTest : public CV_GpuImageProcTest
for (int i = 0; i < interpolations_num; ++i)
{
ts->printf(CvTS::LOG, "\nInterpolation type: %s\n", interpolations_str[i]);
ts->printf(CvTS::LOG, "Interpolation: %s\n", interpolations_str[i]);
Mat cpu_res;
cv::resize(img, cpu_res, Size(), 0.5, 0.5, interpolations[i]);
......
......@@ -52,16 +52,16 @@ using namespace cv;
using namespace std;
using namespace gpu;
class CV_GpuMatAsyncCallTest : public CvTest
class CV_AsyncGpuMatTest : public CvTest
{
public:
CV_GpuMatAsyncCallTest() : CvTest( "GPU-MatOperatorAsyncCall", "async" )
CV_AsyncGpuMatTest() : CvTest( "GPU-AsyncGpuMatOperator", "async" )
{
rows = 234;
cols = 123;
}
~CV_GpuMatAsyncCallTest() {}
~CV_AsyncGpuMatTest() {}
protected:
void run(int);
......@@ -75,9 +75,9 @@ class CV_GpuMatAsyncCallTest : public CvTest
};
template<typename T>
void CV_GpuMatAsyncCallTest::print_mat(const T & mat, const std::string & name) const { cv::imshow(name, mat); }
void CV_AsyncGpuMatTest::print_mat(const T & mat, const std::string & name) const { cv::imshow(name, mat); }
bool CV_GpuMatAsyncCallTest::compare_matrix(cv::Mat & cpumat)
bool CV_AsyncGpuMatTest::compare_matrix(cv::Mat & cpumat)
{
Mat cmat(cpumat.size(), cpumat.type(), Scalar::all(0));
GpuMat gmat0(cmat);
......@@ -125,7 +125,7 @@ bool CV_GpuMatAsyncCallTest::compare_matrix(cv::Mat & cpumat)
}
}
void CV_GpuMatAsyncCallTest::run( int /* start_from */)
void CV_AsyncGpuMatTest::run( int /* start_from */)
{
bool is_test_good = true;
......@@ -155,4 +155,4 @@ void CV_GpuMatAsyncCallTest::run( int /* start_from */)
/////////////////////////////////////////////////////////////////////////////
CV_GpuMatAsyncCallTest CV_GpuMatAsyncCall_test;
CV_AsyncGpuMatTest CV_AsyncGpuMatTest_test;
......@@ -43,6 +43,7 @@
#include <iostream>
#include <string>
#include "opencv2/highgui/highgui.hpp"
struct CV_GpuStereoBMTest : public CvTest
{
......@@ -70,6 +71,15 @@ struct CV_GpuStereoBMTest : public CvTest
disp.convertTo(disp, img_reference.type());
double norm = cv::norm(disp, img_reference, cv::NORM_INF);
//cv::imwrite(std::string(ts->get_data_path()) + "stereobm/aloe-disp.png", disp);
/*cv::imshow("disp", disp);
cv::imshow("img_reference", img_reference);
cv::Mat diff = (cv::Mat)disp - (cv::Mat)img_reference;
cv::imshow("diff", diff);
cv::waitKey();*/
if (norm >= 100)
{
ts->printf(CvTS::LOG, "\nStereoBM norm = %f\n", norm);
......
......@@ -44,11 +44,11 @@
using namespace cv;
using namespace std;
struct CV_GpuMatAsyncCallStereoBMTest : public CvTest
struct CV_AsyncStereoBMTest : public CvTest
{
public:
CV_GpuMatAsyncCallStereoBMTest() : CvTest( "GPU-MatAsyncCallStereoBM", "asyncStereoBM" ) {}
~CV_GpuMatAsyncCallStereoBMTest() {}
CV_AsyncStereoBMTest() : CvTest( "GPU-AsyncStereoBM", "asyncStereoBM" ) {}
~CV_AsyncStereoBMTest() {}
void run( int /* start_from */)
{
......@@ -100,4 +100,4 @@ struct CV_GpuMatAsyncCallStereoBMTest : public CvTest
/////////////////// tests registration /////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
CV_GpuMatAsyncCallStereoBMTest CV_GpuMatAsyncCallStereoBMTest_test;
CV_AsyncStereoBMTest CV_AsyncStereoBMTest_test;
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册