8000 [BE] Fix variable shadowing in CUDACachingAllocator.cpp by malfet · Pull Request #86646 · pytorch/pytorch · GitHub
[go: up one dir, main page]

Skip to content

[BE] Fix variable shadowing in CUDACachingAllocator.cpp #86646

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

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 9 additions & 10 deletions c10/cuda/CUDACachingAllocator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -558,8 +558,8 @@ class DeviceCachingAllocator {
bool record_history = false;
std::atomic<CreateContextFn> context_recorder_;
size_t alloc_trace_next = 0;
bool alloc_trace_record_context = false;
size_t alloc_trace_max_entries = 1;
bool alloc_trace_record_context_ = false;
size_t alloc_trace_max_entries_ = 1;
std::vector<TraceEntry>*
alloc_trace; // pointer because we need to intentionally leak this on
// deallocation it can hold references to Python state which
Expand Down Expand Up @@ -599,11 +599,10 @@ class DeviceCachingAllocator {
size_t alloc_trace_max_entries,
bool alloc_trace_record_context) {
std::unique_lock<std::recursive_mutex> lock(mutex);
this->record_history = enabled;
this->context_recorder_.store(context_recorder);
this->alloc_trace_max_entries =
std::max(size_t(1), alloc_trace_max_entries);
this->alloc_trace_record_context = alloc_trace_record_context;
record_history = enabled;
context_recorder_.store(context_recorder);
alloc_trace_max_entries_ = std::max(size_t(1), alloc_trace_max_entries);
alloc_trace_record_context_ = alloc_trace_record_context;
alloc_trace_next = 0;
alloc_trace->clear();
}
Expand Down Expand Up @@ -1758,12 +1757,12 @@ class DeviceCachingAllocator {
addr,
size,
stream,
alloc_trace_record_context ? std::move(context) : nullptr);
if (alloc_trace->size() < alloc_trace_max_entries) {
alloc_trace_record_context_ ? std::move(context) : nullptr);
if (alloc_trace->size() < alloc_trace_max_entries_) {
alloc_trace->emplace_back(te);
} else {
(*alloc_trace)[alloc_trace_next++] = te;
if (alloc_trace_next == alloc_trace_max_entries) {
if (alloc_trace_next == alloc_trace_max_entries_) {
alloc_trace_next = 0;
}
}
Expand Down
0