This repository was archived by the owner on Sep 30, 2026. It is now read-only.
Repository navigation
Conversation
Contributor
|
This pull request was exported from Phabricator. Differential Revision: D39942067 |
pallab-zz
pushed a commit
to pallab-zz/kineto
that referenced
this pull request
Sep 30, 2022
Summary: Pull Request resolved: pytorch#661 Differential Revision: D39942067 fbshipit-source-id: 2a13f295beff4aab24c2d873b65fa04999c920ae
Contributor
|
This pull request was exported from Phabricator. Differential Revision: D39942067 |
pallab-zz
force-pushed
the
export-D39942067
branch
from
September 30, 2022 02:12
edec58a to
dab7678
Compare
pallab-zz
pushed a commit
to pallab-zz/kineto
that referenced
this pull request
Oct 1, 2022
Summary: Pull Request resolved: pytorch#661 Differential Revision: D39942067 fbshipit-source-id: 001f1986e786f93304e7dbf81015eaff9ff33607
pallab-zz
force-pushed
the
export-D39942067
branch
from
October 1, 2022 01:02
dab7678 to
e32cca7
Compare
Contributor
|
This pull request was exported from Phabricator. Differential Revision: D39942067 |
Summary: Pull Request resolved: pytorch#661 Differential Revision: D39942067 fbshipit-source-id: 1cc722c710452bf8037a85c25024a6b91cb3ab7d
pallab-zz
force-pushed
the
export-D39942067
branch
from
October 1, 2022 02:25
e32cca7 to
c05fccf
Compare
Contributor
|
This pull request was exported from Phabricator. Differential Revision: D39942067 |
scotts
added a commit
to scotts/kineto
that referenced
this pull request
Apr 7, 2026
pytorch#1350) Summary: `CuptiCallbackApi::singleton()` returns `std::shared_ptr<CuptiCallbackApi>` by value. Every call copies the shared_ptr, incurring two atomic ref-count operations (increment on copy, decrement on destruction). The `callback_switchboard` function -- the CUPTI hot path fired on every `cudaLaunchKernel` -- calls `singleton()` on each invocation. On ARM/aarch64, atomic operations are more expensive than on x86 due to load-exclusive / store-exclusive barriers, making this overhead measurable during profiling. This diff changes `singleton()` to return `CuptiCallbackApi&` from a Meyers singleton (`static CuptiCallbackApi instance`), eliminating the per-call atomic overhead. This matches the pattern already used by `CuptiActivityApi::singleton()`. **SIOF safety analysis:** D39942067 / PR pytorch#661 introduced the `shared_ptr` to fix a SIOF crash on aarch64. We analyzed all static initialization dependencies and found: 1. `CuptiCallbackApi`'s constructor is `= default` with all trivially constructible members. It has zero static dependencies at construction time. 2. The actual SIOF was between `initCallbackApi()` and GLOG -- there is an explicit comment in the code: "TODO: Remove temporarily to work around static initialization order issue between this and GLOG." The problematic `LOG()` call was already commented out as a workaround. 3. The `shared_ptr` does not meaningfully fix SIOF: no caller stores the `shared_ptr` long-term, so the lifetime-extension property is never used. Both the `shared_ptr` static and a Meyers singleton have identical construction timing (first call) and destruction timing (static destruction). 4. A Meyers singleton is safe here because `CuptiCallbackApi()` has no dependencies on other statics. The SIOF risk is in `initCallbackApi()` (which calls CUPTI and potentially GLOG), not in singleton construction. Differential Revision: D99843809
scotts
added a commit
to scotts/kineto
that referenced
this pull request
Apr 8, 2026
pytorch#1350) Summary: `CuptiCallbackApi::singleton()` returns `std::shared_ptr<CuptiCallbackApi>` by value. Every call copies the shared_ptr, incurring two atomic ref-count operations (increment on copy, decrement on destruction). The `callback_switchboard` function -- the CUPTI hot path fired on every `cudaLaunchKernel` -- calls `singleton()` on each invocation. On ARM/aarch64, atomic operations are more expensive than on x86 due to load-exclusive / store-exclusive barriers, making this overhead measurable during profiling. This diff changes `singleton()` to return `CuptiCallbackApi&` from a Meyers singleton (`static CuptiCallbackApi instance`), eliminating the per-call atomic overhead. This matches the pattern already used by `CuptiActivityApi::singleton()`. **SIOF safety analysis:** D39942067 / PR pytorch#661 introduced the `shared_ptr` to fix a SIOF crash on aarch64. We analyzed all static initialization dependencies and found: 1. `CuptiCallbackApi`'s constructor is `= default` with all trivially constructible members. It has zero static dependencies at construction time. 2. The actual SIOF was between `initCallbackApi()` and GLOG -- there is an explicit comment in the code: "TODO: Remove temporarily to work around static initialization order issue between this and GLOG." The problematic `LOG()` call was already commented out as a workaround. 3. The `shared_ptr` does not meaningfully fix SIOF: no caller stores the `shared_ptr` long-term, so the lifetime-extension property is never used. Both the `shared_ptr` static and a Meyers singleton have identical construction timing (first call) and destruction timing (static destruction). 4. A Meyers singleton is safe here because `CuptiCallbackApi()` has no dependencies on other statics. The SIOF risk is in `initCallbackApi()` (which calls CUPTI and potentially GLOG), not in singleton construction. Differential Revision: D99843809
meta-codesync Bot
pushed a commit
that referenced
this pull request
Apr 8, 2026
#1350) Summary: Pull Request resolved: #1350 `CuptiCallbackApi::singleton()` returns `std::shared_ptr<CuptiCallbackApi>` by value. Every call copies the shared_ptr, incurring two atomic ref-count operations (increment on copy, decrement on destruction). The `callback_switchboard` function -- the CUPTI hot path fired on every `cudaLaunchKernel` -- calls `singleton()` on each invocation. On ARM/aarch64, atomic operations are more expensive than on x86 due to load-exclusive / store-exclusive barriers, making this overhead measurable during profiling. This diff changes `singleton()` to return `CuptiCallbackApi&` from a Meyers singleton (`static CuptiCallbackApi instance`), eliminating the per-call atomic overhead. This matches the pattern already used by `CuptiActivityApi::singleton()`. **SIOF safety analysis:** D39942067 / PR #661 introduced the `shared_ptr` to fix a SIOF crash on aarch64. We analyzed all static initialization dependencies and found: 1. `CuptiCallbackApi`'s constructor is `= default` with all trivially constructible members. It has zero static dependencies at construction time. 2. The actual SIOF was between `initCallbackApi()` and GLOG -- there is an explicit comment in the code: "TODO: Remove temporarily to work around static initialization order issue between this and GLOG." The problematic `LOG()` call was already commented out as a workaround. 3. The `shared_ptr` does not meaningfully fix SIOF: no caller stores the `shared_ptr` long-term, so the lifetime-extension property is never used. Both the `shared_ptr` static and a Meyers singleton have identical construction timing (first call) and destruction timing (static destruction). 4. A Meyers singleton is safe here because `CuptiCallbackApi()` has no dependencies on other statics. The SIOF risk is in `initCallbackApi()` (which calls CUPTI and potentially GLOG), not in singleton construction. Reviewed By: ryanzhang22 Differential Revision: D99843809 fbshipit-source-id: b5910f400b6c47f05d9709bade894a2e1071fc81
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Differential Revision: D39942067