From 245270845c6093b683e4ee26d7516215e6beb7df Mon Sep 17 00:00:00 2001 From: Jian Chen Date: Fri, 19 Jul 2024 16:21:29 -0400 Subject: [PATCH] volatile size_t volatile_x = 0; for (size_t x = 0; x < body; x++) { volatile_x = x; // Your code here, using volatile_x if necessary } --- onnxruntime/test/onnx/microbenchmark/tptest.cc | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/onnxruntime/test/onnx/microbenchmark/tptest.cc b/onnxruntime/test/onnx/microbenchmark/tptest.cc index 4d69b8c452ef..9fe1aed08ebf 100644 --- a/onnxruntime/test/onnx/microbenchmark/tptest.cc +++ b/onnxruntime/test/onnx/microbenchmark/tptest.cc @@ -102,9 +102,10 @@ static void BM_ThreadPoolSimpleParallelFor(benchmark::State& state) { for (auto _ : state) { for (int j = 0; j < 100; j++) { ThreadPool::TrySimpleParallelFor(tp.get(), len, [&](size_t) { - volatile size_t x = 0; - for (size_t i = 0; i < body; i++) { - x++; + volatile size_t volatile_x = 0; + for (size_t x = 0; x < body; x++) { + volatile_x = x; + // Your code here, using volatile_x if necessary } }); }