use perf test replace performance sample
This commit is contained in:
@@ -7,12 +7,13 @@
|
||||
// copy or use the software.
|
||||
//
|
||||
//
|
||||
// Intel License Agreement
|
||||
// License Agreement
|
||||
// For Open Source Computer Vision Library
|
||||
//
|
||||
// Copyright (C) 2000, Intel Corporation, all rights reserved.
|
||||
// Copyright (C) 2010-2012, Multicoreware, Inc., all rights reserved.
|
||||
// Copyright (C) 2010-2012, Advanced Micro Devices, Inc., all rights reserved.
|
||||
// Third party copyrights are property of their respective owners.
|
||||
//
|
||||
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
@@ -21,12 +22,12 @@
|
||||
//
|
||||
// * Redistribution's in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
// and/or other oclMaterials provided with the distribution.
|
||||
//
|
||||
// * The name of Intel Corporation may not be used to endorse or promote products
|
||||
// * The name of the copyright holders may not be used to endorse or promote products
|
||||
// derived from this software without specific prior written permission.
|
||||
//
|
||||
// This software is provided by the copyright holders and contributors "as is" and
|
||||
// This software is provided by the copyright holders and contributors as is and
|
||||
// any express or implied warranties, including, but not limited to, the implied
|
||||
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
||||
// In no event shall the Intel Corporation or contributors be liable for any direct,
|
||||
@@ -41,129 +42,118 @@
|
||||
|
||||
#include "precomp.hpp"
|
||||
|
||||
#ifdef HAVE_OPENCL
|
||||
|
||||
using namespace std;
|
||||
using namespace cv;
|
||||
using namespace cv::ocl;
|
||||
using namespace cvtest;
|
||||
using namespace testing;
|
||||
|
||||
void print_info()
|
||||
int main(int argc, const char *argv[])
|
||||
{
|
||||
printf("\n");
|
||||
#if defined _WIN32
|
||||
# if defined _WIN64
|
||||
puts("OS: Windows 64");
|
||||
# else
|
||||
puts("OS: Windows 32");
|
||||
# endif
|
||||
#elif defined linux
|
||||
# if defined _LP64
|
||||
puts("OS: Linux 64");
|
||||
# else
|
||||
puts("OS: Linux 32");
|
||||
# endif
|
||||
#elif defined __APPLE__
|
||||
# if defined _LP64
|
||||
puts("OS: Apple 64");
|
||||
# else
|
||||
puts("OS: Apple 32");
|
||||
# endif
|
||||
#endif
|
||||
vector<ocl::Info> oclinfo;
|
||||
int num_devices = getDevice(oclinfo);
|
||||
|
||||
if (num_devices < 1)
|
||||
{
|
||||
cerr << "no device found\n";
|
||||
return -1;
|
||||
}
|
||||
|
||||
int devidx = 0;
|
||||
|
||||
for (size_t i = 0; i < oclinfo.size(); i++)
|
||||
{
|
||||
for (size_t j = 0; j < oclinfo[i].DeviceName.size(); j++)
|
||||
{
|
||||
printf("device %d: %s\n", devidx++, oclinfo[i].DeviceName[j].c_str());
|
||||
}
|
||||
}
|
||||
|
||||
redirectError(cvErrorCallback);
|
||||
|
||||
}
|
||||
std::string workdir;
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
TS::ptr()->init("ocl");
|
||||
InitGoogleTest(&argc, argv);
|
||||
const char *keys =
|
||||
|
||||
"{ h | help | false | print help message }"
|
||||
|
||||
"{ w | workdir | ../../../samples/c/| set working directory }"
|
||||
|
||||
"{ t | type | gpu | set device type:cpu or gpu}"
|
||||
|
||||
"{ p | platform | 0 | set platform id }"
|
||||
|
||||
"{ d | device | 0 | set device id }";
|
||||
|
||||
|
||||
"{ h | help | false | print help message }"
|
||||
"{ f | filter | | filter for test }"
|
||||
"{ w | workdir | | set working directory }"
|
||||
"{ l | list | false | show all tests }"
|
||||
"{ d | device | 0 | device id }"
|
||||
"{ i | iters | 10 | iteration count }"
|
||||
"{ m | warmup | 1 | gpu warm up iteration count}"
|
||||
"{ t | xtop | 1.1 | xfactor top boundary}"
|
||||
"{ b | xbottom | 0.9 | xfactor bottom boundary}"
|
||||
"{ v | verify | false | only run gpu once to verify if problems occur}";
|
||||
|
||||
CommandLineParser cmd(argc, argv, keys);
|
||||
|
||||
if (cmd.get<bool>("help"))
|
||||
|
||||
{
|
||||
|
||||
cout << "Avaible options besides goole test option:" << endl;
|
||||
|
||||
cout << "Avaible options:" << endl;
|
||||
cmd.printParams();
|
||||
return 0;
|
||||
}
|
||||
|
||||
workdir = cmd.get<string>("workdir");
|
||||
|
||||
string type = cmd.get<string>("type");
|
||||
|
||||
unsigned int pid = cmd.get<unsigned int>("platform");
|
||||
|
||||
int device = cmd.get<int>("device");
|
||||
|
||||
|
||||
print_info();
|
||||
// int flag = CVCL_DEVICE_TYPE_GPU;
|
||||
|
||||
// if(type == "cpu")
|
||||
|
||||
// {
|
||||
|
||||
// flag = CVCL_DEVICE_TYPE_CPU;
|
||||
|
||||
// }
|
||||
std::vector<cv::ocl::Info> oclinfo;
|
||||
int devnums = getDevice(oclinfo);
|
||||
if(devnums <= device || device < 0)
|
||||
|
||||
if (device < 0 || device >= num_devices)
|
||||
{
|
||||
|
||||
std::cout << "device invalid\n";
|
||||
|
||||
cerr << "Invalid device ID" << endl;
|
||||
return -1;
|
||||
|
||||
}
|
||||
|
||||
if(pid >= oclinfo.size())
|
||||
|
||||
if (cmd.get<bool>("verify"))
|
||||
{
|
||||
|
||||
std::cout << "platform invalid\n";
|
||||
|
||||
return -1;
|
||||
|
||||
TestSystem::instance().setNumIters(1);
|
||||
TestSystem::instance().setGPUWarmupIters(0);
|
||||
TestSystem::instance().setCPUIters(0);
|
||||
}
|
||||
|
||||
if(pid != 0 || device != 0)
|
||||
devidx = 0;
|
||||
|
||||
for (size_t i = 0; i < oclinfo.size(); i++)
|
||||
{
|
||||
|
||||
setDevice(oclinfo[pid], device);
|
||||
|
||||
for (size_t j = 0; j < oclinfo[i].DeviceName.size(); j++, devidx++)
|
||||
{
|
||||
if (device == devidx)
|
||||
{
|
||||
ocl::setDevice(oclinfo[i], (int)j);
|
||||
TestSystem::instance().setRecordName(oclinfo[i].DeviceName[j]);
|
||||
printf("\nuse %d: %s\n", devidx, oclinfo[i].DeviceName[j].c_str());
|
||||
goto END_DEV;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
cout << "Device type:" << type << endl << "Device name:" << oclinfo[pid].DeviceName[device] << endl;
|
||||
setBinpath(CLBINPATH);
|
||||
return RUN_ALL_TESTS();
|
||||
}
|
||||
END_DEV:
|
||||
|
||||
#else // DON'T HAVE_OPENCL
|
||||
string filter = cmd.get<string>("filter");
|
||||
string workdir = cmd.get<string>("workdir");
|
||||
bool list = cmd.get<bool>("list");
|
||||
int iters = cmd.get<int>("iters");
|
||||
int wu_iters = cmd.get<int>("warmup");
|
||||
double x_top = cmd.get<double>("xtop");
|
||||
double x_bottom = cmd.get<double>("xbottom");
|
||||
|
||||
TestSystem::instance().setTopThreshold(x_top);
|
||||
TestSystem::instance().setBottomThreshold(x_bottom);
|
||||
|
||||
if (!filter.empty())
|
||||
{
|
||||
TestSystem::instance().setTestFilter(filter);
|
||||
}
|
||||
|
||||
if (!workdir.empty())
|
||||
{
|
||||
if (workdir[workdir.size() - 1] != '/' && workdir[workdir.size() - 1] != '\\')
|
||||
{
|
||||
workdir += '/';
|
||||
}
|
||||
|
||||
TestSystem::instance().setWorkingDir(workdir);
|
||||
}
|
||||
|
||||
if (list)
|
||||
{
|
||||
TestSystem::instance().setListMode(true);
|
||||
}
|
||||
|
||||
TestSystem::instance().setNumIters(iters);
|
||||
TestSystem::instance().setGPUWarmupIters(wu_iters);
|
||||
|
||||
TestSystem::instance().run();
|
||||
|
||||
int main()
|
||||
{
|
||||
printf("OpenCV was built without OpenCL support\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
#endif // HAVE_OPENCL
|
||||
}
|
Reference in New Issue
Block a user