2011-09-07 21:16:07 +08:00
|
|
|
#include "perf_precomp.hpp"
|
|
|
|
|
2012-08-17 19:14:14 +08:00
|
|
|
using namespace std;
|
|
|
|
using namespace cv;
|
|
|
|
using namespace cv::gpu;
|
|
|
|
using namespace cvtest;
|
|
|
|
using namespace testing;
|
|
|
|
|
2012-08-17 20:12:32 +08:00
|
|
|
void printOsInfo()
|
2012-08-17 19:14:14 +08:00
|
|
|
{
|
|
|
|
#if defined _WIN32
|
|
|
|
# if defined _WIN64
|
2012-08-17 20:12:32 +08:00
|
|
|
cout << "OS: Windows x64 \n" << endl;
|
2012-08-17 19:14:14 +08:00
|
|
|
# else
|
2012-08-17 20:12:32 +08:00
|
|
|
cout << "OS: Windows x32 \n" << endl;
|
2012-08-17 19:14:14 +08:00
|
|
|
# endif
|
|
|
|
#elif defined linux
|
|
|
|
# if defined _LP64
|
2012-08-17 20:12:32 +08:00
|
|
|
cout << "OS: Linux x64 \n" << endl;
|
2012-08-17 19:14:14 +08:00
|
|
|
# else
|
2012-08-17 20:12:32 +08:00
|
|
|
cout << "OS: Linux x32 \n" << endl;
|
2012-08-17 19:14:14 +08:00
|
|
|
# endif
|
|
|
|
#elif defined __APPLE__
|
|
|
|
# if defined _LP64
|
2012-08-17 20:12:32 +08:00
|
|
|
cout << "OS: Apple x64 \n" << endl;
|
2012-08-17 19:14:14 +08:00
|
|
|
# else
|
2012-08-17 20:12:32 +08:00
|
|
|
cout << "OS: Apple x32 \n" << endl;
|
2012-08-17 19:14:14 +08:00
|
|
|
# endif
|
|
|
|
#endif
|
2012-08-17 20:12:32 +08:00
|
|
|
}
|
2012-08-17 19:14:14 +08:00
|
|
|
|
2012-08-17 20:12:32 +08:00
|
|
|
void printCudaInfo()
|
|
|
|
{
|
2012-10-02 02:37:20 +08:00
|
|
|
#if !defined HAVE_CUDA || defined(CUDA_DISABLER)
|
2012-08-17 20:12:32 +08:00
|
|
|
cout << "OpenCV was built without CUDA support \n" << endl;
|
|
|
|
#else
|
2012-08-17 19:14:14 +08:00
|
|
|
int driver;
|
|
|
|
cudaDriverGetVersion(&driver);
|
|
|
|
|
2012-08-17 20:12:32 +08:00
|
|
|
cout << "CUDA Driver version: " << driver << '\n';
|
|
|
|
cout << "CUDA Runtime version: " << CUDART_VERSION << '\n';
|
2012-08-17 19:14:14 +08:00
|
|
|
|
2012-08-17 20:12:32 +08:00
|
|
|
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;
|
2012-08-17 19:14:14 +08:00
|
|
|
|
|
|
|
int deviceCount = getCudaEnabledDeviceCount();
|
2012-08-17 20:12:32 +08:00
|
|
|
cout << "CUDA device count: " << deviceCount << '\n';
|
|
|
|
|
|
|
|
cout << endl;
|
2012-08-17 19:14:14 +08:00
|
|
|
|
|
|
|
for (int i = 0; i < deviceCount; ++i)
|
|
|
|
{
|
|
|
|
DeviceInfo info(i);
|
|
|
|
|
2012-08-17 20:12:32 +08:00
|
|
|
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";
|
2012-08-17 19:14:14 +08:00
|
|
|
if (!info.isCompatible())
|
2012-08-17 20:12:32 +08:00
|
|
|
cout << "\t !!! This device is NOT compatible with current GPU module build \n";
|
|
|
|
|
|
|
|
cout << endl;
|
2012-08-17 19:14:14 +08:00
|
|
|
}
|
2012-08-17 20:12:32 +08:00
|
|
|
#endif
|
2012-08-17 19:14:14 +08:00
|
|
|
}
|
|
|
|
|
2012-08-20 14:15:36 +08:00
|
|
|
int main(int argc, char** argv)
|
2011-09-07 21:16:07 +08:00
|
|
|
{
|
2012-09-07 17:24:48 +08:00
|
|
|
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;
|
|
|
|
}
|
2012-08-17 19:14:14 +08:00
|
|
|
|
2012-08-17 20:12:32 +08:00
|
|
|
printOsInfo();
|
|
|
|
printCudaInfo();
|
2012-08-17 19:14:14 +08:00
|
|
|
|
2012-09-07 17:24:48 +08:00
|
|
|
|
|
|
|
if (cmd.has("info"))
|
|
|
|
{
|
2012-08-17 19:14:14 +08:00
|
|
|
return 0;
|
2012-09-07 17:24:48 +08:00
|
|
|
}
|
2012-08-17 19:14:14 +08:00
|
|
|
|
2012-08-17 20:12:32 +08:00
|
|
|
int device = cmd.get<int>("device");
|
2012-09-07 17:24:48 +08:00
|
|
|
bool cpu = cmd.has("cpu");
|
2012-10-02 02:37:20 +08:00
|
|
|
#if !defined HAVE_CUDA || defined(CUDA_DISABLER)
|
2012-08-17 20:12:32 +08:00
|
|
|
cpu = true;
|
|
|
|
#endif
|
2012-08-17 19:14:14 +08:00
|
|
|
|
2012-08-17 20:12:32 +08:00
|
|
|
if (cpu)
|
2012-08-17 19:14:14 +08:00
|
|
|
{
|
2012-08-17 20:12:32 +08:00
|
|
|
runOnGpu = false;
|
2012-08-17 19:14:14 +08:00
|
|
|
|
2012-08-17 20:12:32 +08:00
|
|
|
cout << "Run tests on CPU \n" << endl;
|
2012-08-17 19:14:14 +08:00
|
|
|
}
|
2012-08-17 20:12:32 +08:00
|
|
|
else
|
|
|
|
{
|
|
|
|
runOnGpu = true;
|
2012-08-17 19:14:14 +08:00
|
|
|
|
2012-08-17 20:12:32 +08:00
|
|
|
if (device < 0 || device >= getCudaEnabledDeviceCount())
|
|
|
|
{
|
|
|
|
cerr << "Incorrect device index - " << device << endl;
|
|
|
|
return -1;
|
|
|
|
}
|
2012-08-17 19:14:14 +08:00
|
|
|
|
2012-08-17 20:12:32 +08:00
|
|
|
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;
|
|
|
|
}
|
2012-08-17 19:14:14 +08:00
|
|
|
|
2012-08-20 14:15:36 +08:00
|
|
|
InitGoogleTest(&argc, argv);
|
2011-12-28 20:53:08 +08:00
|
|
|
perf::TestBase::Init(argc, argv);
|
2011-09-07 21:16:07 +08:00
|
|
|
return RUN_ALL_TESTS();
|
|
|
|
}
|