};
#endif
-bool GNADeviceHelper::wait(uint32_t reqId, int64_t millisTimeout) {
+GnaWaitStatus GNADeviceHelper::wait(uint32_t reqId, int64_t millisTimeout) {
#if GNA_LIB_VER == 2
const auto status = Gna2RequestWait(reqId, millisTimeout);
if (status == Gna2StatusDriverQoSTimeoutExceeded) {
- return false;
+ return GNA_REQUEST_ABORTED;
+ }
+ if (status == Gna2StatusWarningDeviceBusy) {
+ return GNA_REQUEST_PENDING;
}
checkGna2Status(status);
unwaitedRequestIds.erase(std::remove(unwaitedRequestIds.begin(), unwaitedRequestIds.end(), reqId));
checkStatus();
#endif
updateGnaPerfCounters();
- return true;
+ return GNA_REQUEST_COMPLETED;
}
#if GNA_LIB_VER == 1
#include "gna-api-instrumentation.h"
#endif
+enum GnaWaitStatus : int {
+ GNA_REQUEST_COMPLETED = 0, // and removed from GNA library queue
+ GNA_REQUEST_ABORTED = 1, // for QoS purposes
+ GNA_REQUEST_PENDING = 2 // for device busy purposes
+};
/**
* holds gna - style handle in RAII way
static void checkGna2Status(Gna2Status status);
static void checkGna2Status(Gna2Status status, const Gna2Model& gnaModel);
#endif
- bool wait(uint32_t id, int64_t millisTimeout = MAX_TIMEOUT);
+ GnaWaitStatus wait(uint32_t id, int64_t millisTimeout = MAX_TIMEOUT);
struct DumpResult {
#if GNA_LIB_VER == 2
THROW_IE_EXCEPTION << PARAMETER_MISMATCH_str;
}
- bool qosOK;
if (millis_timeout == InferenceEngine::IInferRequest::WaitMode::RESULT_READY) {
- qosOK = plg->Wait(inferRequestIdx);
- } else {
- qosOK = plg->WaitFor(inferRequestIdx, millis_timeout);
+ millis_timeout = MAX_TIMEOUT;
}
+ const auto waitStatus = plg->WaitFor(inferRequestIdx, millis_timeout);
- if (qosOK) {
- return InferenceEngine::OK;
- } else {
+ if (waitStatus == GNA_REQUEST_PENDING) {
+ // request is still pending so Wait() is needed once again
+ return InferenceEngine::RESULT_NOT_READY;
+ }
+ if (waitStatus == GNA_REQUEST_ABORTED) {
// need to preserve invalid state here to avoid next Wait() from clearing it
inferRequestIdx = -1;
return InferenceEngine::INFER_NOT_STARTED;
}
+ return InferenceEngine::OK;
}
};
} // namespace GNAPluginNS
}
bool GNAPlugin::Wait(uint32_t request_idx) {
- return WaitFor(request_idx, MAX_TIMEOUT);
+ return GNA_REQUEST_COMPLETED == WaitFor(request_idx, MAX_TIMEOUT);
}
-bool GNAPlugin::WaitFor(uint32_t request_idx, int64_t millisTimeout) {
+GnaWaitStatus GNAPlugin::WaitFor(uint32_t request_idx, int64_t millisTimeout) {
#if GNA_LIB_VER == 2
auto& nnets = gnaRequestConfigToRequestIdMap;
#endif
- if (nnets.size() <= request_idx) return true; // TODO: GNA2: check whether necessary
+ // TODO: GNA2: check whether necessary
+ if (nnets.size() <= request_idx) return GNA_REQUEST_COMPLETED;
// already synced TODO: might be copy required ???
- if (std::get<1>(nnets[request_idx]) == -1) return true;
+ if (std::get<1>(nnets[request_idx]) == -1) return GNA_REQUEST_COMPLETED;
if (gnadevice) {
- if (!gnadevice->wait(std::get<1>(nnets[request_idx]), millisTimeout)) {
+ const auto waitStatus = gnadevice->wait(std::get<1>(nnets[request_idx]), millisTimeout);
+ if (waitStatus == GNA_REQUEST_ABORTED) {
std::get<1>(nnets[request_idx]) = -1;
- return false;
+ return GNA_REQUEST_ABORTED;
+ }
+ if (waitStatus == GNA_REQUEST_PENDING) {
+ return GNA_REQUEST_PENDING;
}
}
output_idx++;
}
- return true;
+ return GNA_REQUEST_COMPLETED;
}
void GNAPlugin::Reset() {
InferenceEngine::QueryNetworkResult &res) const override;
uint32_t QueueInference(const InferenceEngine::BlobMap &input, InferenceEngine::BlobMap &result);
bool Wait(uint32_t idx);
- bool WaitFor(uint32_t idx, int64_t millisTimeout);
+ GnaWaitStatus WaitFor(uint32_t idx, int64_t millisTimeout);
InferenceEngine::Parameter GetConfig(const std::string& name,
const std::map<std::string, InferenceEngine::Parameter> & options) const override;