Skip to content

Commit

Permalink
remove CPU from default candidate list while GPUs more than 2 (openvi…
Browse files Browse the repository at this point in the history
  • Loading branch information
wgzintel authored May 30, 2022
1 parent 70e9cc0 commit f5e2a46
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions src/plugins/auto/auto_schedule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,36 @@ void AutoSchedule::init(const ScheduleContext::Ptr& sContext) {
std::list<DeviceInformation> validDevices =
_autoSContext->_plugin->GetValidDevice(_autoSContext->_devicePriorities, _loadContext[ACTUALDEVICE].networkPrecision);

// check if device priority is enabled
bool enableDevicePriority =
std::find_if(std::begin(validDevices), std::end(validDevices), [](DeviceInformation& di) {
return di.devicePriority > 0;
}) != std::end(validDevices);

// for the case of -d "AUTO" or "AUTO: -xxx"
if (!enableDevicePriority) {
std::list<DeviceInformation>::iterator itCPUDevice;
int GPUNums = 0, CPUNums = 0;
for (auto it = validDevices.begin(); it != validDevices.end(); it++) {
if (it->deviceName.find("GPU") != std::string::npos) {
GPUNums++;
}

if (it->deviceName.find("CPU") == 0) {
CPUNums++;
itCPUDevice = it;
}
}

// remove CPU from default candidate list for Cumulative Throughput mode
if (GPUNums >= 2 && CPUNums > 0) {
validDevices.erase(itCPUDevice);
LOG_INFO("[AUTOPLUGIN]:GPUNums:%d, remove CPU from default candidate list for "
"CUMULATIVE_THROUGHPUT",
GPUNums);
}
}

std::string deviceName = "MULTI:";
for (auto& device : validDevices) {
deviceName += device.deviceName;
Expand Down

0 comments on commit f5e2a46

Please sign in to comment.