2012-08-08 17:09:29 +08:00
|
|
|
/*M///////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
|
|
|
//
|
|
|
|
// By downloading, copying, installing or using the software you agree to this license.
|
|
|
|
// If you do not agree to this license, do not download, install,
|
|
|
|
// copy or use the software.
|
|
|
|
//
|
|
|
|
//
|
2013-03-27 12:04:48 +08:00
|
|
|
// License Agreement
|
2012-08-08 17:09:29 +08:00
|
|
|
// For Open Source Computer Vision Library
|
|
|
|
//
|
2013-03-27 12:04:48 +08:00
|
|
|
// Copyright (C) 2010-2012, Multicoreware, Inc., all rights reserved.
|
|
|
|
// Copyright (C) 2010-2012, Advanced Micro Devices, Inc., all rights reserved.
|
2012-08-08 17:09:29 +08:00
|
|
|
// Third party copyrights are property of their respective owners.
|
2013-03-27 12:04:48 +08:00
|
|
|
|
2012-08-08 17:09:29 +08:00
|
|
|
// Redistribution and use in source and binary forms, with or without modification,
|
|
|
|
// are permitted provided that the following conditions are met:
|
|
|
|
//
|
|
|
|
// * Redistribution's of source code must retain the above copyright notice,
|
|
|
|
// this list of conditions and the following disclaimer.
|
|
|
|
//
|
|
|
|
// * Redistribution's in binary form must reproduce the above copyright notice,
|
|
|
|
// this list of conditions and the following disclaimer in the documentation
|
2013-03-27 12:04:48 +08:00
|
|
|
// and/or other oclMaterials provided with the distribution.
|
2012-08-08 17:09:29 +08:00
|
|
|
//
|
2013-03-27 12:04:48 +08:00
|
|
|
// * The name of the copyright holders may not be used to endorse or promote products
|
2012-08-08 17:09:29 +08:00
|
|
|
// derived from this software without specific prior written permission.
|
|
|
|
//
|
2013-03-27 12:04:48 +08:00
|
|
|
// This software is provided by the copyright holders and contributors as is and
|
2012-08-08 17:09:29 +08:00
|
|
|
// 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,
|
|
|
|
// indirect, incidental, special, exemplary, or consequential damages
|
|
|
|
// (including, but not limited to, procurement of substitute goods or services;
|
|
|
|
// loss of use, data, or profits; or business interruption) however caused
|
|
|
|
// and on any theory of liability, whether in contract, strict liability,
|
|
|
|
// or tort (including negligence or otherwise) arising in any way out of
|
|
|
|
// the use of this software, even if advised of the possibility of such damage.
|
|
|
|
//
|
|
|
|
//M*/
|
|
|
|
|
|
|
|
#include "precomp.hpp"
|
|
|
|
|
2013-07-03 23:53:21 +08:00
|
|
|
static int cvErrorCallback(int /*status*/, const char * /*func_name*/,
|
|
|
|
const char *err_msg, const char * /*file_name*/,
|
|
|
|
int /*line*/, void * /*userdata*/)
|
2012-08-08 17:09:29 +08:00
|
|
|
{
|
2013-07-03 23:53:21 +08:00
|
|
|
TestSystem::instance().printError(err_msg);
|
|
|
|
return 0;
|
|
|
|
}
|
2012-10-22 15:14:22 +08:00
|
|
|
|
2013-03-27 12:04:48 +08:00
|
|
|
int main(int argc, const char *argv[])
|
2012-08-08 17:09:29 +08:00
|
|
|
{
|
2012-10-22 15:14:22 +08:00
|
|
|
const char *keys =
|
2013-04-05 23:52:42 +08:00
|
|
|
"{ 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 }"
|
2013-07-03 23:53:21 +08:00
|
|
|
"{ c cpu_ocl | false | use cpu as ocl device}"
|
2013-04-05 23:52:42 +08:00
|
|
|
"{ i iters | 10 | iteration count }"
|
|
|
|
"{ m warmup | 1 | gpu warm up iteration count}"
|
2013-07-03 23:53:21 +08:00
|
|
|
"{ t xtop | 1.1 | xfactor top boundary}"
|
|
|
|
"{ b xbottom | 0.9 | xfactor bottom boundary}"
|
2013-04-05 23:52:42 +08:00
|
|
|
"{ v verify | false | only run gpu once to verify if problems occur}";
|
2012-10-22 15:14:22 +08:00
|
|
|
|
2013-06-25 14:11:28 +08:00
|
|
|
redirectError(cvErrorCallback);
|
2012-10-22 15:14:22 +08:00
|
|
|
CommandLineParser cmd(argc, argv, keys);
|
2013-04-05 23:52:42 +08:00
|
|
|
if (cmd.has("help"))
|
2012-10-22 15:14:22 +08:00
|
|
|
{
|
2013-03-27 12:04:48 +08:00
|
|
|
cout << "Avaible options:" << endl;
|
2012-11-07 13:49:09 +08:00
|
|
|
cmd.printMessage();
|
|
|
|
return 0;
|
2012-10-22 15:14:22 +08:00
|
|
|
}
|
|
|
|
|
2013-06-25 14:11:28 +08:00
|
|
|
// get ocl devices
|
|
|
|
bool use_cpu = cmd.get<bool>("c");
|
|
|
|
vector<ocl::Info> oclinfo;
|
|
|
|
int num_devices = 0;
|
|
|
|
if(use_cpu)
|
|
|
|
num_devices = getDevice(oclinfo, ocl::CVCL_DEVICE_TYPE_CPU);
|
|
|
|
else
|
|
|
|
num_devices = getDevice(oclinfo);
|
|
|
|
if (num_devices < 1)
|
|
|
|
{
|
|
|
|
cerr << "no device found\n";
|
|
|
|
return -1;
|
|
|
|
}
|
2012-10-22 15:14:22 +08:00
|
|
|
|
2013-06-25 14:11:28 +08:00
|
|
|
// show device info
|
|
|
|
int devidx = 0;
|
|
|
|
for (size_t i = 0; i < oclinfo.size(); i++)
|
|
|
|
{
|
|
|
|
for (size_t j = 0; j < oclinfo[i].DeviceName.size(); j++)
|
|
|
|
{
|
|
|
|
cout << "device " << devidx++ << ": " << oclinfo[i].DeviceName[j] << endl;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int device = cmd.get<int>("device");
|
2013-03-27 12:04:48 +08:00
|
|
|
if (device < 0 || device >= num_devices)
|
2012-10-11 16:22:47 +08:00
|
|
|
{
|
2013-03-27 12:04:48 +08:00
|
|
|
cerr << "Invalid device ID" << endl;
|
2012-10-11 16:22:47 +08:00
|
|
|
return -1;
|
|
|
|
}
|
2012-10-22 15:14:22 +08:00
|
|
|
|
2013-06-25 14:11:28 +08:00
|
|
|
// set this to overwrite binary cache every time the test starts
|
|
|
|
ocl::setBinaryDiskCache(ocl::CACHE_UPDATE);
|
2013-07-03 23:53:21 +08:00
|
|
|
|
2013-03-27 12:04:48 +08:00
|
|
|
if (cmd.get<bool>("verify"))
|
2012-10-22 15:14:22 +08:00
|
|
|
{
|
2013-03-27 12:04:48 +08:00
|
|
|
TestSystem::instance().setNumIters(1);
|
|
|
|
TestSystem::instance().setGPUWarmupIters(0);
|
|
|
|
TestSystem::instance().setCPUIters(0);
|
2012-10-22 15:14:22 +08:00
|
|
|
}
|
|
|
|
|
2013-03-27 12:04:48 +08:00
|
|
|
devidx = 0;
|
|
|
|
for (size_t i = 0; i < oclinfo.size(); i++)
|
2012-10-22 15:14:22 +08:00
|
|
|
{
|
2013-03-27 12:04:48 +08:00
|
|
|
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]);
|
2013-06-25 14:11:28 +08:00
|
|
|
cout << "use " << devidx << ": " <<oclinfo[i].DeviceName[j] << endl;
|
2013-03-27 12:04:48 +08:00
|
|
|
goto END_DEV;
|
|
|
|
}
|
|
|
|
}
|
2012-10-22 15:14:22 +08:00
|
|
|
}
|
|
|
|
|
2013-03-27 12:04:48 +08:00
|
|
|
END_DEV:
|
2012-08-08 17:09:29 +08:00
|
|
|
|
2013-03-27 12:04:48 +08:00
|
|
|
string filter = cmd.get<string>("filter");
|
|
|
|
string workdir = cmd.get<string>("workdir");
|
2013-04-05 23:52:42 +08:00
|
|
|
bool list = cmd.has("list");
|
2013-03-27 12:04:48 +08:00
|
|
|
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");
|
2012-08-08 17:09:29 +08:00
|
|
|
|
2013-03-27 12:04:48 +08:00
|
|
|
TestSystem::instance().setTopThreshold(x_top);
|
|
|
|
TestSystem::instance().setBottomThreshold(x_bottom);
|
2012-10-22 15:14:22 +08:00
|
|
|
|
2013-03-27 12:04:48 +08:00
|
|
|
if (!filter.empty())
|
|
|
|
{
|
|
|
|
TestSystem::instance().setTestFilter(filter);
|
|
|
|
}
|
2012-10-22 15:14:22 +08:00
|
|
|
|
2013-03-27 12:04:48 +08:00
|
|
|
if (!workdir.empty())
|
2012-10-22 15:14:22 +08:00
|
|
|
{
|
2013-03-27 12:04:48 +08:00
|
|
|
if (workdir[workdir.size() - 1] != '/' && workdir[workdir.size() - 1] != '\\')
|
|
|
|
{
|
|
|
|
workdir += '/';
|
|
|
|
}
|
2012-10-22 15:14:22 +08:00
|
|
|
|
2013-03-27 12:04:48 +08:00
|
|
|
TestSystem::instance().setWorkingDir(workdir);
|
|
|
|
}
|
2012-10-22 15:14:22 +08:00
|
|
|
|
2013-03-27 12:04:48 +08:00
|
|
|
if (list)
|
|
|
|
{
|
|
|
|
TestSystem::instance().setListMode(true);
|
2012-10-22 15:14:22 +08:00
|
|
|
}
|
2012-08-08 17:09:29 +08:00
|
|
|
|
2013-03-27 12:04:48 +08:00
|
|
|
TestSystem::instance().setNumIters(iters);
|
|
|
|
TestSystem::instance().setGPUWarmupIters(wu_iters);
|
2012-08-08 17:09:29 +08:00
|
|
|
|
2013-03-27 12:04:48 +08:00
|
|
|
TestSystem::instance().run();
|
2012-08-08 17:09:29 +08:00
|
|
|
|
|
|
|
return 0;
|
2013-07-03 23:53:21 +08:00
|
|
|
}
|