mirror of https://github.com/opencv/opencv.git
parent
ece77e3930
commit
a9ab26f799
1 changed files with 137 additions and 137 deletions
@ -1,137 +1,137 @@ |
|||||||
#include "perf_precomp.hpp" |
#include "perf_precomp.hpp" |
||||||
|
|
||||||
using namespace std; |
using namespace std; |
||||||
using namespace cv; |
using namespace cv; |
||||||
using namespace cv::gpu; |
using namespace cv::gpu; |
||||||
using namespace cvtest; |
using namespace cvtest; |
||||||
using namespace testing; |
using namespace testing; |
||||||
|
|
||||||
void printOsInfo() |
void printOsInfo() |
||||||
{ |
{ |
||||||
#if defined _WIN32 |
#if defined _WIN32 |
||||||
# if defined _WIN64 |
# if defined _WIN64 |
||||||
cout << "OS: Windows x64 \n" << endl; |
cout << "OS: Windows x64 \n" << endl; |
||||||
# else |
# else |
||||||
cout << "OS: Windows x32 \n" << endl; |
cout << "OS: Windows x32 \n" << endl; |
||||||
# endif |
# endif |
||||||
#elif defined linux |
#elif defined linux |
||||||
# if defined _LP64 |
# if defined _LP64 |
||||||
cout << "OS: Linux x64 \n" << endl; |
cout << "OS: Linux x64 \n" << endl; |
||||||
# else |
# else |
||||||
cout << "OS: Linux x32 \n" << endl; |
cout << "OS: Linux x32 \n" << endl; |
||||||
# endif |
# endif |
||||||
#elif defined __APPLE__ |
#elif defined __APPLE__ |
||||||
# if defined _LP64 |
# if defined _LP64 |
||||||
cout << "OS: Apple x64 \n" << endl; |
cout << "OS: Apple x64 \n" << endl; |
||||||
# else |
# else |
||||||
cout << "OS: Apple x32 \n" << endl; |
cout << "OS: Apple x32 \n" << endl; |
||||||
# endif |
# endif |
||||||
#endif |
#endif |
||||||
} |
} |
||||||
|
|
||||||
void printCudaInfo() |
void printCudaInfo() |
||||||
{ |
{ |
||||||
#if !defined HAVE_CUDA || defined(CUDA_DISABLER) |
#if !defined HAVE_CUDA || defined(CUDA_DISABLER) |
||||||
cout << "OpenCV was built without CUDA support \n" << endl; |
cout << "OpenCV was built without CUDA support \n" << endl; |
||||||
#else |
#else |
||||||
int driver; |
int driver; |
||||||
cudaDriverGetVersion(&driver); |
cudaDriverGetVersion(&driver); |
||||||
|
|
||||||
cout << "CUDA Driver version: " << driver << '\n'; |
cout << "CUDA Driver version: " << driver << '\n'; |
||||||
cout << "CUDA Runtime version: " << CUDART_VERSION << '\n'; |
cout << "CUDA Runtime version: " << CUDART_VERSION << '\n'; |
||||||
|
|
||||||
cout << endl; |
cout << endl; |
||||||
|
|
||||||
cout << "GPU module was compiled for the following GPU archs:" << endl; |
cout << "GPU module was compiled for the following GPU archs:" << endl; |
||||||
cout << " BIN: " << CUDA_ARCH_BIN << '\n'; |
cout << " BIN: " << CUDA_ARCH_BIN << '\n'; |
||||||
cout << " PTX: " << CUDA_ARCH_PTX << '\n'; |
cout << " PTX: " << CUDA_ARCH_PTX << '\n'; |
||||||
|
|
||||||
cout << endl; |
cout << endl; |
||||||
|
|
||||||
int deviceCount = getCudaEnabledDeviceCount(); |
int deviceCount = getCudaEnabledDeviceCount(); |
||||||
cout << "CUDA device count: " << deviceCount << '\n'; |
cout << "CUDA device count: " << deviceCount << '\n'; |
||||||
|
|
||||||
cout << endl; |
cout << endl; |
||||||
|
|
||||||
for (int i = 0; i < deviceCount; ++i) |
for (int i = 0; i < deviceCount; ++i) |
||||||
{ |
{ |
||||||
DeviceInfo info(i); |
DeviceInfo info(i); |
||||||
|
|
||||||
cout << "Device [" << i << "] \n"; |
cout << "Device [" << i << "] \n"; |
||||||
cout << "\t Name: " << info.name() << '\n'; |
cout << "\t Name: " << info.name() << '\n'; |
||||||
cout << "\t Compute capability: " << info.majorVersion() << '.' << info.minorVersion()<< '\n'; |
cout << "\t Compute capability: " << info.majorVersion() << '.' << info.minorVersion()<< '\n'; |
||||||
cout << "\t Multi Processor Count: " << info.multiProcessorCount() << '\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 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"; |
cout << "\t Free memory: " << static_cast<int>(static_cast<int>(info.freeMemory() / 1024.0) / 1024.0) << " Mb \n"; |
||||||
if (!info.isCompatible()) |
if (!info.isCompatible()) |
||||||
cout << "\t !!! This device is NOT compatible with current GPU module build \n"; |
cout << "\t !!! This device is NOT compatible with current GPU module build \n"; |
||||||
|
|
||||||
cout << endl; |
cout << endl; |
||||||
} |
} |
||||||
#endif |
#endif |
||||||
} |
} |
||||||
|
|
||||||
int main(int argc, char** argv) |
int main(int argc, char** argv) |
||||||
{ |
{ |
||||||
const std::string keys = |
const std::string keys = |
||||||
"{ h help ? | | Print help}" |
"{ h help ? | | Print help}" |
||||||
"{ i info | | Print information about system and exit }" |
"{ i info | | Print information about system and exit }" |
||||||
"{ device | 0 | Device on which tests will be executed }" |
"{ device | 0 | Device on which tests will be executed }" |
||||||
"{ cpu | | Run tests on cpu }" |
"{ cpu | | Run tests on cpu }" |
||||||
; |
; |
||||||
|
|
||||||
CommandLineParser cmd(argc, (const char**) argv, keys); |
CommandLineParser cmd(argc, (const char**) argv, keys); |
||||||
|
|
||||||
if (cmd.has("help")) |
if (cmd.has("help")) |
||||||
{ |
{ |
||||||
cmd.printMessage(); |
cmd.printMessage(); |
||||||
return 0; |
return 0; |
||||||
} |
} |
||||||
|
|
||||||
printOsInfo(); |
printOsInfo(); |
||||||
printCudaInfo(); |
printCudaInfo(); |
||||||
|
|
||||||
|
|
||||||
if (cmd.has("info")) |
if (cmd.has("info")) |
||||||
{ |
{ |
||||||
return 0; |
return 0; |
||||||
} |
} |
||||||
|
|
||||||
int device = cmd.get<int>("device"); |
int device = cmd.get<int>("device"); |
||||||
bool cpu = cmd.has("cpu"); |
bool cpu = cmd.has("cpu"); |
||||||
#if !defined HAVE_CUDA || defined(CUDA_DISABLER) |
#if !defined HAVE_CUDA || defined(CUDA_DISABLER) |
||||||
cpu = true; |
cpu = true; |
||||||
#endif |
#endif |
||||||
|
|
||||||
if (cpu) |
if (cpu) |
||||||
{ |
{ |
||||||
runOnGpu = false; |
runOnGpu = false; |
||||||
|
|
||||||
cout << "Run tests on CPU \n" << endl; |
cout << "Run tests on CPU \n" << endl; |
||||||
} |
} |
||||||
else |
else |
||||||
{ |
{ |
||||||
runOnGpu = true; |
runOnGpu = true; |
||||||
|
|
||||||
if (device < 0 || device >= getCudaEnabledDeviceCount()) |
if (device < 0 || device >= getCudaEnabledDeviceCount()) |
||||||
{ |
{ |
||||||
cerr << "Incorrect device index - " << device << endl; |
cerr << "Incorrect device index - " << device << endl; |
||||||
return -1; |
return -1; |
||||||
} |
} |
||||||
|
|
||||||
DeviceInfo info(device); |
DeviceInfo info(device); |
||||||
if (!info.isCompatible()) |
if (!info.isCompatible()) |
||||||
{ |
{ |
||||||
cerr << "Device " << device << " [" << info.name() << "] is NOT compatible with current GPU module build" << endl; |
cerr << "Device " << device << " [" << info.name() << "] is NOT compatible with current GPU module build" << endl; |
||||||
return -1; |
return -1; |
||||||
} |
} |
||||||
|
|
||||||
setDevice(device); |
setDevice(device); |
||||||
|
|
||||||
cout << "Run tests on device " << device << " [" << info.name() << "] \n" << endl; |
cout << "Run tests on device " << device << " [" << info.name() << "] \n" << endl; |
||||||
} |
} |
||||||
|
|
||||||
InitGoogleTest(&argc, argv); |
InitGoogleTest(&argc, argv); |
||||||
perf::TestBase::Init(argc, argv); |
perf::TestBase::Init(argc, argv); |
||||||
return RUN_ALL_TESTS(); |
return RUN_ALL_TESTS(); |
||||||
} |
} |
Loading…
Reference in new issue