Skip to content

Commit

Permalink
Small redundancy fix (allocated intervals are never empty)
Browse files Browse the repository at this point in the history
  • Loading branch information
Tom94 committed Apr 21, 2022
1 parent 9d238b5 commit 5d91020
Showing 1 changed file with 11 additions and 16 deletions.
27 changes: 11 additions & 16 deletions include/tiny-cuda-nn/gpu_memory.h
Original file line number Diff line number Diff line change
Expand Up @@ -386,19 +386,14 @@ struct Interval {
// Inclusive start, exclusive end
size_t start, end;

/*
bool operator<(const Interval& other) const {
return end < other.end;
}*/


bool operator<(const Interval& other) const {
if(end < other.end)
return 1;
else if (end == other.end)
if (end < other.end) {
return true;
} else if (end == other.end) {
return start < other.start;
else
return 0;
} else {
return false;
}
}

bool overlaps(const Interval& other) const {
Expand Down Expand Up @@ -522,11 +517,11 @@ class GPUMemoryArena {

Interval interval = {start, m_allocated_intervals[start]};
m_allocated_intervals.erase(start);
if(interval.start != interval.end)
m_free_intervals.insert(
std::upper_bound(std::begin(m_free_intervals), std::end(m_free_intervals), interval),
interval
);

m_free_intervals.insert(
std::upper_bound(std::begin(m_free_intervals), std::end(m_free_intervals), interval),
interval
);

merge_adjacent_intervals();
}
Expand Down

0 comments on commit 5d91020

Please sign in to comment.