Skip to content

Commit

Permalink
Use atomic<int64_t> instead of atomic_int64_t. The later is available…
Browse files Browse the repository at this point in the history
… in GCC7, but not GCC5 (#528)

Summary:
Pull Request resolved: #528

Since PyTorch CI builds for GCC5, we need to use std::atomic<std::int64_t> 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
  • Loading branch information
aaronenyeshi authored and facebook-github-bot committed Feb 15, 2022
1 parent 04f36ca commit 1d21eda
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion libkineto/src/ActivityProfilerController.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#pragma once

#include <atomic>
#include <cstdint>
#include <memory>
#include <mutex>
#include <thread>
Expand Down Expand Up @@ -76,7 +77,7 @@ class ActivityProfilerController : public ConfigLoader::ConfigHandler {
std::unique_ptr<ActivityLogger> logger_;
std::thread* profilerThread_{nullptr};
std::atomic_bool stopRunloop_{false};
std::atomic_int64_t iterationCount_{-1};
std::atomic<std::int64_t> iterationCount_{-1};
ConfigLoader& configLoader_;
};

Expand Down

0 comments on commit 1d21eda

Please sign in to comment.