f8eb23d098f401d61cd25e0aebcba6510e20d1b5
[profile/ivi/opencv.git] / modules / gpu / perf / perf_main.cpp
1 #include "perf_precomp.hpp"
2
3 namespace{
4
5 static void printOsInfo()
6 {
7 #if defined _WIN32
8 #   if defined _WIN64
9         printf("[----------]\n[ GPU INFO ] \tRun on OS Windows x64.\n[----------]\n"), fflush(stdout);
10 #   else
11         printf("[----------]\n[ GPU INFO ] \tRun on OS Windows x32.\n[----------]\n"), fflush(stdout);
12 #   endif
13 #elif defined linux
14 #   if defined _LP64
15         printf("[----------]\n[ GPU INFO ] \tRun on OS Linux x64.\n[----------]\n"), fflush(stdout);
16 #   else
17         printf("[----------]\n[ GPU INFO ] \tRun on OS Linux x32.\n[----------]\n"), fflush(stdout);
18 #   endif
19 #elif defined __APPLE__
20 #   if defined _LP64
21         printf("[----------]\n[ GPU INFO ] \tRun on OS Apple x64.\n[----------]\n"), fflush(stdout);
22 #   else
23         printf("[----------]\n[ GPU INFO ] \tRun on OS Apple x32.\n[----------]\n"), fflush(stdout);
24 #   endif
25 #endif
26
27 }
28
29 static void printCudaInfo()
30 {
31     printOsInfo();
32 #ifndef HAVE_CUDA
33     printf("[----------]\n[ GPU INFO ] \tOpenCV was built without CUDA support.\n[----------]\n"), fflush(stdout);
34 #else
35     int driver;
36     cudaDriverGetVersion(&driver);
37
38     printf("[----------]\n"), fflush(stdout);
39     printf("[ GPU INFO ] \tCUDA Driver  version: %d.\n", driver), fflush(stdout);
40     printf("[ GPU INFO ] \tCUDA Runtime version: %d.\n", CUDART_VERSION), fflush(stdout);
41     printf("[----------]\n"), fflush(stdout);
42
43     printf("[----------]\n"), fflush(stdout);
44     printf("[ GPU INFO ] \tGPU module was compiled for the following GPU archs.\n"), fflush(stdout);
45     printf("[      BIN ] \t%s.\n", CUDA_ARCH_BIN), fflush(stdout);
46     printf("[      PTX ] \t%s.\n", CUDA_ARCH_PTX), fflush(stdout);
47     printf("[----------]\n"), fflush(stdout);
48
49     printf("[----------]\n"), fflush(stdout);
50     int deviceCount = cv::gpu::getCudaEnabledDeviceCount();
51     printf("[ GPU INFO ] \tCUDA device count:: %d.\n", deviceCount), fflush(stdout);
52     printf("[----------]\n"), fflush(stdout);
53
54     for (int i = 0; i < deviceCount; ++i)
55     {
56         cv::gpu::DeviceInfo info(i);
57
58         printf("[----------]\n"), fflush(stdout);
59         printf("[ DEVICE   ] \t# %d %s.\n", i, info.name().c_str()), fflush(stdout);
60         printf("[          ] \tCompute capability: %d.%d\n", (int)info.majorVersion(), (int)info.minorVersion()), fflush(stdout);
61         printf("[          ] \tMulti Processor Count:  %d\n", info.multiProcessorCount()), fflush(stdout);
62         printf("[          ] \tTotal memory: %d Mb\n", static_cast<int>(static_cast<int>(info.totalMemory() / 1024.0) / 1024.0)), fflush(stdout);
63         printf("[          ] \tFree  memory: %d Mb\n", static_cast<int>(static_cast<int>(info.freeMemory()  / 1024.0) / 1024.0)), fflush(stdout);
64         if (!info.isCompatible())
65             printf("[ GPU INFO ] \tThis device is NOT compatible with current GPU module build\n");
66         printf("[----------]\n"), fflush(stdout);
67     }
68
69 #endif
70 }
71
72 }
73
74 CV_PERF_TEST_MAIN(gpu, printCudaInfo())