提交 6db776f9 编写于 作者: Y yao

add "-c" for cpu ocl mode in perf tests

上级 c244f000
...@@ -44,43 +44,21 @@ ...@@ -44,43 +44,21 @@
int main(int argc, const char *argv[]) int main(int argc, const char *argv[])
{ {
vector<ocl::Info> oclinfo;
int num_devices = getDevice(oclinfo);
if (num_devices < 1)
{
cerr << "no device found\n";
return -1;
}
// set this to overwrite binary cache every time the test starts
ocl::setBinaryDiskCache(ocl::CACHE_UPDATE);
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);
const char *keys = const char *keys =
"{ h | help | false | print help message }" "{ h | help | false | print help message }"
"{ f | filter | | filter for test }" "{ f | filter | | filter for test }"
"{ w | workdir | | set working directory }" "{ w | workdir | | set working directory }"
"{ l | list | false | show all tests }" "{ l | list | false | show all tests }"
"{ d | device | 0 | device id }" "{ d | device | 0 | device id }"
"{ c | cpu_ocl | false | use cpu as ocl device}"
"{ i | iters | 10 | iteration count }" "{ i | iters | 10 | iteration count }"
"{ m | warmup | 1 | gpu warm up iteration count}" "{ m | warmup | 1 | gpu warm up iteration count}"
"{ t | xtop | 1.1 | xfactor top boundary}" "{ t | xtop | 1.1 | xfactor top boundary}"
"{ b | xbottom | 0.9 | xfactor bottom boundary}" "{ b | xbottom | 0.9 | xfactor bottom boundary}"
"{ v | verify | false | only run gpu once to verify if problems occur}"; "{ v | verify | false | only run gpu once to verify if problems occur}";
redirectError(cvErrorCallback);
CommandLineParser cmd(argc, argv, keys); CommandLineParser cmd(argc, argv, keys);
if (cmd.get<bool>("help")) if (cmd.get<bool>("help"))
{ {
cout << "Avaible options:" << endl; cout << "Avaible options:" << endl;
...@@ -88,14 +66,40 @@ int main(int argc, const char *argv[]) ...@@ -88,14 +66,40 @@ int main(int argc, const char *argv[])
return 0; return 0;
} }
int device = cmd.get<int>("device"); // 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;
}
// 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");
if (device < 0 || device >= num_devices) if (device < 0 || device >= num_devices)
{ {
cerr << "Invalid device ID" << endl; cerr << "Invalid device ID" << endl;
return -1; return -1;
} }
// set this to overwrite binary cache every time the test starts
ocl::setBinaryDiskCache(ocl::CACHE_UPDATE);
if (cmd.get<bool>("verify")) if (cmd.get<bool>("verify"))
{ {
TestSystem::instance().setNumIters(1); TestSystem::instance().setNumIters(1);
...@@ -104,7 +108,6 @@ int main(int argc, const char *argv[]) ...@@ -104,7 +108,6 @@ int main(int argc, const char *argv[])
} }
devidx = 0; devidx = 0;
for (size_t i = 0; i < oclinfo.size(); i++) for (size_t i = 0; i < oclinfo.size(); i++)
{ {
for (size_t j = 0; j < oclinfo[i].DeviceName.size(); j++, devidx++) for (size_t j = 0; j < oclinfo[i].DeviceName.size(); j++, devidx++)
...@@ -113,7 +116,7 @@ int main(int argc, const char *argv[]) ...@@ -113,7 +116,7 @@ int main(int argc, const char *argv[])
{ {
ocl::setDevice(oclinfo[i], (int)j); ocl::setDevice(oclinfo[i], (int)j);
TestSystem::instance().setRecordName(oclinfo[i].DeviceName[j]); TestSystem::instance().setRecordName(oclinfo[i].DeviceName[j]);
printf("\nuse %d: %s\n", devidx, oclinfo[i].DeviceName[j].c_str()); cout << "use " << devidx << ": " <<oclinfo[i].DeviceName[j] << endl;
goto END_DEV; goto END_DEV;
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册