-
Notifications
You must be signed in to change notification settings - Fork 5
Convert thread storage from std::array to std::vector with dynamic growth #21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
anujshuk-amd
wants to merge
20
commits into
timem
Choose a base branch
from
users/anujshuk/dynamic-thread-storage_ds
base: timem
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
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
Fixed a bug in processing command line parameters
…ction not being called when a default is defined (#3)
Invalid RPATH used for libunwind properties. Failing RPM generations and rpath check on RHEL 10. --------- Signed-off-by: David Galiffi <[email protected]>
Signed-off-by: David Galiffi <[email protected]>
Update submodule to ROCm/GOTCHA@c04cc3f (v1.0.8 +). Now points to the ROCm fork of GOTCHA
Signed-off-by: David Galiffi <[email protected]>
* Exclude perf_event_uncore events from evaluation * Change1: Optimization and cleaner code fixes
Fallback to use `patchelf`, if `chrpath` is not present. Change some logging from "WARNING"s to "AUTHOR_WARNING"s. Signed-off-by: David Galiffi <[email protected]>
…g BEFORE keyword (#19)
…owth - Replace fixed std::array with std::vector for dynamic thread storage - Add ensure_capacity() with double-checked locking pattern - Use std::atomic<size_t> for lock-free capacity reads - Add bounds checking in get_storage operation - Implement geometric growth (2x doubling) when capacity exceeded - Initial capacity set to TIMEMORY_MAX_THREADS, grows as needed
8d9b5e6 to
696a160
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Later will move/remove this
Used by : ROCm/rocm-systems#2542
Motivation
These updates ensure that storage can grow as needed and that concurrent accesses are safely managed.
Technical Details
This pull request refactors the storage management logic in
source/timemory/operations/types.hppto improve thread safety and scalability. The main changes are the switch from a fixed-size array to a dynamically resizing vector for storage, the introduction of atomic and mutex-based synchronization for concurrent access, and the use of a configurable thread limit.Thread safety and dynamic storage management
set_storagefrom using a fixed-sizestd::arrayto a dynamically resizingstd::vector, allowing for more flexible and scalable storage of thread-local data. ([source/timemory/operations/types.hppL816-R872](https://github.com/ROCm/timemory/pull/21/files#diff-e60a89742e16350cc3b36bbb562d4c77c8b1b7e34bd8a2011b6f81cf13fb771eL816-R872))std::atomic,std::mutex) to ensure safe concurrent resizing and access of the storage vector. ([[1]](https://github.com/ROCm/timemory/pull/21/files#diff-e60a89742e16350cc3b36bbb562d4c77c8b1b7e34bd8a2011b6f81cf13fb771eR42-R45),[[2]](https://github.com/ROCm/timemory/pull/21/files#diff-e60a89742e16350cc3b36bbb562d4c77c8b1b7e34bd8a2011b6f81cf13fb771eL816-R872))ensure_capacitymethod inset_storageto grow the storage vector geometrically (doubling size) when a new thread index exceeds current capacity, ensuring efficient scaling and minimizing lock contention. ([source/timemory/operations/types.hppL816-R872](https://github.com/ROCm/timemory/pull/21/files#diff-e60a89742e16350cc3b36bbb562d4c77c8b1b7e34bd8a2011b6f81cf13fb771eL816-R872))4096with theTIMEMORY_MAX_THREADSmacro for greater flexibility. ([source/timemory/operations/types.hppL816-R872](https://github.com/ROCm/timemory/pull/21/files#diff-e60a89742e16350cc3b36bbb562d4c77c8b1b7e34bd8a2011b6f81cf13fb771eL816-R872))Safe access and read logic
get_storageto use atomic capacity checks before accessing the storage vector, returningnullptrfor out-of-bounds thread indices to prevent unsafe reads. ([source/timemory/operations/types.hppR905-R907](https://github.com/ROCm/timemory/pull/21/files#diff-e60a89742e16350cc3b36bbb562d4c77c8b1b7e34bd8a2011b6f81cf13fb771eR905-R907))Test Plan
To be tested in CI/CD or rocm-system
Test Result
TBA
Submission Checklist