From 1d21eda4eede13b9d5bc9168e5b6f937f072cdc3 Mon Sep 17 00:00:00 2001 From: Aaron Enye Shi Date: Tue, 15 Feb 2022 09:32:41 -0800 Subject: [PATCH] Use atomic instead of atomic_int64_t. The later is available in GCC7, but not GCC5 (#528) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Summary: Pull Request resolved: https://github.com/pytorch/kineto/pull/528 Since PyTorch CI builds for GCC5, we need to use std::atomic for iterationCount, because atomic_int64_t is not available until after GCC5. Test Plan: This fixes PyTorch CI error: https://app.circleci.com/pipelines/github/pytorch/pytorch/450702/workflows/e2f30e30-26d5-410d-8334-a2d6919d74de/jobs/16978938 ``` In file included from ../third_party/kineto/libkineto/src/ActivityProfilerController.cpp:3:0: ../third_party/kineto/libkineto/src/ActivityProfilerController.h:79:8: error: ‘atomic_int64_t’ in namespace ‘std’ does not name a type std::atomic_int64_t iterationCount_{-1}; ^ ../third_party/kineto/libkineto/src/ActivityProfilerController.cpp: In member function ‘void libkineto::ActivityProfilerController::step()’: ../third_party/kineto/libkineto/src/ActivityProfilerController.cpp:137:27: error: ‘iterationCount_’ was not declared in this scope int64_t currentIter = ++iterationCount_; ^ ../third_party/kineto/libkineto/src/ActivityProfilerController.cpp: In member function ‘void libkineto::ActivityProfilerController::scheduleTrace(const libkineto::Config&)’: ../third_party/kineto/libkineto/src/ActivityProfilerController.cpp:185:44: error: ‘iterationCount_’ was not declared in this scope if (config.hasProfileStartIteration() && iterationCount_ < 0) { ^ ``` Reviewed By: briancoutinho Differential Revision: D34190739 Pulled By: aaronenyeshi fbshipit-source-id: 8c0baef40cea393495fa12e842af72f733e26e8e --- libkineto/src/ActivityProfilerController.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libkineto/src/ActivityProfilerController.h b/libkineto/src/ActivityProfilerController.h index 9b23d6a88..415f107cb 100644 --- a/libkineto/src/ActivityProfilerController.h +++ b/libkineto/src/ActivityProfilerController.h @@ -3,6 +3,7 @@ #pragma once #include +#include #include #include #include @@ -76,7 +77,7 @@ class ActivityProfilerController : public ConfigLoader::ConfigHandler { std::unique_ptr logger_; std::thread* profilerThread_{nullptr}; std::atomic_bool stopRunloop_{false}; - std::atomic_int64_t iterationCount_{-1}; + std::atomic iterationCount_{-1}; ConfigLoader& configLoader_; };