-
Notifications
You must be signed in to change notification settings - Fork 621
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
Fix a race condition in GetGPUAllocator #1575
Conversation
CI MESSAGE: [1032036]: BUILD STARTED |
CI MESSAGE: [1032036]: BUILD FAILED |
CI MESSAGE: [1032051]: BUILD STARTED |
CI MESSAGE: [1032051]: BUILD FAILED |
CI MESSAGE: [1032768]: BUILD STARTED |
CI MESSAGE: [1032768]: BUILD PASSED |
CI MESSAGE: [1034872]: BUILD STARTED |
CI MESSAGE: [1034872]: BUILD FAILED |
dali/pipeline/data/backend.cc
Outdated
} | ||
|
||
~AllocatorManager() { | ||
delete cpu_allocator_; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On one hand - I know it's a destructor and nothing should follow it - but on the other, just for debugging purposes I prefer to set the deleted pointers to nullptr. That should save us some headache when some crazy bug hits us with a rogue thread trying to use these after we've shut down.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
delete cpu_allocator_; | |
delete std::atomic_exchange(&cpu_allocator_, nullptr); |
CI MESSAGE: [1034879]: BUILD STARTED |
dali/pipeline/data/backend.cc
Outdated
for (auto& gpu_alloc : gpu_allocators_) { | ||
gpu_alloc.store(nullptr); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dont't they get that by default?
alloc = gpu_allocators_[dev].load(); | ||
if (!alloc) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
CI MESSAGE: [1034883]: BUILD STARTED |
dali/pipeline/data/backend.cc
Outdated
if (!alloc) { | ||
SetGPUAllocator(*gpu_opspec_); | ||
} | ||
return *alloc; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
set alloc to a proper value!
CI MESSAGE: [1035052]: BUILD STARTED |
CI MESSAGE: [1034883]: BUILD FAILED |
CI MESSAGE: [1035052]: BUILD PASSED |
- reworks AllocatorManager to use atomic pointers - reworks AllocatorManager to be a static global variable available by the global accessors Signed-off-by: Janusz Lisiecki <jlisiecki@nvidia.com>
Signed-off-by: Janusz Lisiecki <jlisiecki@nvidia.com>
Signed-off-by: Janusz Lisiecki jlisiecki@nvidia.com
Why we need this PR?
What happened in this PR?
JIRA TASK: [DALI-1181]