Commit Graph

8 Commits

Author SHA1 Message Date
Hannes Friederich
331128b444 [c10] signal_handler: atomically exchange the signal count to fix data race in ExecuteStepRecursive() (#115510)
Summary:
`CheckForSignals()` can be called from multiple threads concurrently, e.g. from within `ExecuteStepRecursive()`. This means that `my_sigint_count_` and `my_sighup_count_` can be written concurrently, causing data races.

To fix, use atomic exchange which writes the new value and returns the old value in one atomic operation.

Test Plan: Running TSAN tests that failed before and now pass

Differential Revision: D52018963

Pull Request resolved: https://github.com/pytorch/pytorch/pull/115510
Approved by: https://github.com/malfet
2023-12-13 12:06:06 +00:00
cyy
87cbfe957a increase clang-tidy coverage to more c10 source files (#102902)
Pull Request resolved: https://github.com/pytorch/pytorch/pull/102902
Approved by: https://github.com/Skylion007
2023-06-04 06:33:01 +00:00
cyy
3ae42cb7db adjust header inclusions in C10 as sugguested by IWYU (#102467)
This PR aims to reduce unused header inclusions in C10.

Pull Request resolved: https://github.com/pytorch/pytorch/pull/102467
Approved by: https://github.com/albanD
2023-05-31 19:19:10 +00:00
cyy
fa65ae8f56 cleanup unused include (#93359)
Using `include-what-you-use` tool to find out and remove some unused includes
Pull Request resolved: https://github.com/pytorch/pytorch/pull/93359
Approved by: https://github.com/malfet
2023-02-04 02:15:50 +00:00
Aaron Gokaslan
97db9fde69 Fix header-filter for clang-tidy c10 and apply some fixes to c10 and … (#91178)
…c10d

Fixes a broken header filters from #90699 and applies a few more clang-tidy fixes that are relevant from c10 and c10d. The header filter pattern was actually broken and the clang-tidy include pattern was redundant. Also fixed a few bugs in torch/distributed/c10d

Pull Request resolved: https://github.com/pytorch/pytorch/pull/91178
Approved by: https://github.com/ezyang
2022-12-27 07:34:12 +00:00
Dimitrije Jankov
6bb33d93ab disable the format library in C10 (#60052)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/60052

Introduction:
We would like to use the minimal implementation of C10 for our our SGX port of pytorch. This would include disabling signal handlers and the fmt library.

Problem :
When C10_SUPPORTS_SIGNAL_HANDLER is disabled there is no reason to have fmt enabled as it is used only in stacktraceSignalHandler. The problem is that fmt/format.h is included regardless whether C10_SUPPORTS_SIGNAL_HANDLER is disabled or not.

Solution :
Move the #include <fmt/format.h> inside the #ifdef section of code where  C10_SUPPORTS_SIGNAL_HANDLER is checked.

Test Plan: Run the pytorch unit tests.

Reviewed By: h397wang, LiJihang

Differential Revision: D29022628

fbshipit-source-id: 638cf98381585cd6059129d9c5a65d9e6a841575
2021-07-09 12:28:19 -07:00
Pritam Damania
d230045fde Combine backtrace print into one string to avoid interleaving. (#56961)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/56961

As described in https://github.com/pytorch/pytorch/issues/56583, the
backtrace amongst several processes was garbled.
https://github.com/pytorch/pytorch/pull/56198 would've alleviated this to some
extent, but this PR combines all the logging into just one string to reduce
interleaving further.
ghstack-source-id: 128730047

Test Plan: waitforbuildbot

Reviewed By: cbalioglu

Differential Revision: D28013191

fbshipit-source-id: 8bd8978a92ee2fbcd18472e1293d5809455b411b
2021-05-12 15:52:05 -07:00
Pritam Damania
dc8a8cea79 Move caffe2 signal_handler to c10. (#56717)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/56717

The signal_handler was under the caffe2 namespacee but was being used
by PyTorch as well.

I've fixed this my moving it to the c10 namespace where now both C2 and PyTorch
can use it.

The signal_handler interface in caffe2/utils/signal_handler.h is kept the same
for backward compatiblity for C2, but most of the commmon code is moved to c10.
ghstack-source-id: 127446929

Test Plan: waitforbuildbot

Reviewed By: ezyang

Differential Revision: D27946738

fbshipit-source-id: d6228d1a0108f4c807d405e7a0bb799c5375388f
2021-04-26 23:08:12 -07:00