MCPcopy Create free account
hub / github.com/NVIDIA/TensorRT / runMultiTasksInference

Function runMultiTasksInference

samples/common/sampleInference.cpp:1124–1157  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1122}
1123
1124bool runMultiTasksInference(std::vector<std::unique_ptr<TaskInferenceEnvironment>>& tEnvList)
1125{
1126 cudaCheck(cudaProfilerStart());
1127 cudaSetDeviceFlags(cudaDeviceScheduleSpin);
1128
1129 SyncStruct sync;
1130 sync.sleep = 0;
1131 sync.mainStream.sleep(&sync.sleep);
1132 sync.cpuStart = getCurrentTime();
1133 sync.gpuStart.record(sync.mainStream);
1134
1135 std::vector<std::thread> threads;
1136 for (size_t i = 0; i < tEnvList.size(); ++i)
1137 {
1138 auto& tEnv = tEnvList[i];
1139 threads.emplace_back(makeThread(
1140 tEnv->iOptions, *(tEnv->iEnv), sync, /*threadIdx*/ 0, /*streamsPerThread*/ 1, tEnv->device, tEnv->trace));
1141 }
1142 for (auto& th : threads)
1143 {
1144 th.join();
1145 }
1146
1147 cudaCheck(cudaProfilerStop());
1148
1149 auto cmpTrace = [](InferenceTrace const& a, InferenceTrace const& b) { return a.h2dStart < b.h2dStart; };
1150 for (auto& tEnv : tEnvList)
1151 {
1152 std::sort(tEnv->trace.begin(), tEnv->trace.end(), cmpTrace);
1153 }
1154
1155 return std::none_of(tEnvList.begin(), tEnvList.end(),
1156 [](std::unique_ptr<TaskInferenceEnvironment>& tEnv) { return tEnv->iEnv->error; });
1157}
1158
1159namespace
1160{

Callers

nothing calls this directly

Calls 6

cudaCheckFunction · 0.85
getCurrentTimeFunction · 0.85
makeThreadFunction · 0.85
sleepMethod · 0.80
recordMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected