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*/
|
|
|
|
|
2013-08-08 22:18:54 +08:00
|
|
|
#include "perf_precomp.hpp"
|
2012-08-08 17:09:29 +08:00
|
|
|
|
2013-08-23 22:38:31 +08:00
|
|
|
const char * impls[] =
|
|
|
|
{
|
|
|
|
IMPL_OCL,
|
|
|
|
IMPL_PLAIN,
|
|
|
|
#ifdef HAVE_OPENCV_GPU
|
|
|
|
IMPL_GPU
|
|
|
|
#endif
|
|
|
|
};
|
|
|
|
|
|
|
|
int main(int argc, char ** argv)
|
2012-08-08 17:09:29 +08:00
|
|
|
{
|
2013-08-23 22:38:31 +08:00
|
|
|
const char * keys =
|
|
|
|
"{ h | help | false | print help message }"
|
|
|
|
"{ t | type | gpu | set device type:cpu or gpu}"
|
|
|
|
"{ p | platform | 0 | set platform id }"
|
|
|
|
"{ d | device | 0 | set device id }";
|
2012-10-22 15:14:22 +08:00
|
|
|
|
|
|
|
CommandLineParser cmd(argc, argv, keys);
|
|
|
|
if (cmd.get<bool>("help"))
|
|
|
|
{
|
2013-08-23 22:38:31 +08:00
|
|
|
cout << "Available options besides google test option:" << endl;
|
2012-10-22 15:14:22 +08:00
|
|
|
cmd.printParams();
|
2013-03-27 12:04:48 +08:00
|
|
|
return 0;
|
2012-10-22 15:14:22 +08:00
|
|
|
}
|
|
|
|
|
2013-08-23 22:38:31 +08:00
|
|
|
string type = cmd.get<string>("type");
|
|
|
|
unsigned int pid = cmd.get<unsigned int>("platform");
|
2013-06-25 14:11:28 +08:00
|
|
|
int device = cmd.get<int>("device");
|
2012-10-22 15:14:22 +08:00
|
|
|
|
2013-08-23 22:38:31 +08:00
|
|
|
int flag = type == "cpu" ? cv::ocl::CVCL_DEVICE_TYPE_CPU :
|
|
|
|
cv::ocl::CVCL_DEVICE_TYPE_GPU;
|
2012-10-22 15:14:22 +08:00
|
|
|
|
2013-08-23 22:38:31 +08:00
|
|
|
std::vector<cv::ocl::Info> oclinfo;
|
|
|
|
int devnums = cv::ocl::getDevice(oclinfo, flag);
|
|
|
|
if (devnums <= device || device < 0)
|
2012-10-22 15:14:22 +08:00
|
|
|
{
|
2013-08-23 22:38:31 +08:00
|
|
|
std::cout << "device invalid\n";
|
|
|
|
return -1;
|
2013-03-27 12:04:48 +08:00
|
|
|
}
|
2012-10-22 15:14:22 +08:00
|
|
|
|
2013-08-23 22:38:31 +08:00
|
|
|
if (pid >= oclinfo.size())
|
2013-03-27 12:04:48 +08:00
|
|
|
{
|
2013-08-23 22:38:31 +08:00
|
|
|
std::cout << "platform invalid\n";
|
|
|
|
return -1;
|
2013-08-22 22:03:05 +08:00
|
|
|
}
|
|
|
|
|
2013-08-23 22:38:31 +08:00
|
|
|
cv::ocl::setDevice(oclinfo[pid], device);
|
|
|
|
cv::ocl::setBinaryDiskCache(cv::ocl::CACHE_UPDATE);
|
2013-08-22 22:03:05 +08:00
|
|
|
|
|
|
|
CV_PERF_TEST_MAIN_INTERNALS(ocl, impls)
|
|
|
|
}
|