| 1006 | |
| 1007 | template <class ContextType> |
| 1008 | void inferenceExecution(InferenceOptions const& inference, InferenceEnvironment& iEnv, SyncStruct& sync, |
| 1009 | int32_t const threadIdx, int32_t const streamsPerThread, int32_t device, std::vector<InferenceTrace>& trace) noexcept |
| 1010 | { |
| 1011 | try |
| 1012 | { |
| 1013 | float warmupMs = inference.warmup; |
| 1014 | float durationMs = -1.F; |
| 1015 | if (inference.duration != -1.F) |
| 1016 | { |
| 1017 | durationMs = inference.duration * 1000.F + warmupMs; |
| 1018 | } |
| 1019 | |
| 1020 | cudaCheck(cudaSetDevice(device)); |
| 1021 | |
| 1022 | std::vector<std::unique_ptr<Iteration<ContextType>>> iStreams; |
| 1023 | |
| 1024 | for (int32_t s = 0; s < streamsPerThread; ++s) |
| 1025 | { |
| 1026 | int32_t const streamId{threadIdx * streamsPerThread + s}; |
| 1027 | auto* iteration = new Iteration<ContextType>( |
| 1028 | streamId, inference, *iEnv.template getContext<ContextType>(streamId), *iEnv.bindings[streamId]); |
| 1029 | if (inference.skipTransfers) |
| 1030 | { |
| 1031 | iteration->setInputData(true); |
| 1032 | } |
| 1033 | iStreams.emplace_back(iteration); |
| 1034 | } |
| 1035 | |
| 1036 | for (auto& s : iStreams) |
| 1037 | { |
| 1038 | s->wait(sync.gpuStart); |
| 1039 | } |
| 1040 | |
| 1041 | std::vector<InferenceTrace> localTrace; |
| 1042 | if (!inferenceLoop(iStreams, sync.cpuStart, sync.gpuStart, inference.iterations, durationMs, warmupMs, localTrace, |
| 1043 | inference.skipTransfers, inference.idle)) |
| 1044 | { |
| 1045 | sync.mutex.lock(); |
| 1046 | iEnv.error = true; |
| 1047 | sync.mutex.unlock(); |
| 1048 | } |
| 1049 | |
| 1050 | if (inference.skipTransfers) |
| 1051 | { |
| 1052 | for (auto& s : iStreams) |
| 1053 | { |
| 1054 | s->fetchOutputData(true); |
| 1055 | } |
| 1056 | } |
| 1057 | |
| 1058 | sync.mutex.lock(); |
| 1059 | trace.insert(trace.end(), localTrace.begin(), localTrace.end()); |
| 1060 | sync.mutex.unlock(); |
| 1061 | } |
| 1062 | catch(...) |
| 1063 | { |
| 1064 | sync.mutex.lock(); |
| 1065 | iEnv.error = true; |
nothing calls this directly
no test coverage detected