Skip to content
Open
Show file tree
Hide file tree
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
6 changes: 3 additions & 3 deletions src/a2a3/runtime/aicpu_build_graph/runtime/pto_ring_buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ struct PTO2HeapRing {
if (space_at_end >= alloc_size) {
new_top = top + alloc_size;
result = (char *)base + top;
} else if (tail > alloc_size) {
} else if (tail >= alloc_size) {
// Wrap to beginning
new_top = alloc_size;
result = base;
Expand Down Expand Up @@ -545,7 +545,7 @@ struct PTO2DepListPool {
*/
PTO2DepListEntry *alloc() {
int32_t used = top - tail;
if (used >= capacity) {
if (used >= capacity - 1) {
LOG_ERROR("========================================");
LOG_ERROR("FATAL: Dependency Pool Overflow!");
LOG_ERROR("========================================");
Expand All @@ -563,7 +563,7 @@ struct PTO2DepListPool {
}
return nullptr;
}
int32_t idx = top % capacity;
int32_t idx = static_cast<int32_t>((static_cast<uint32_t>(top) - 1) % (capacity - 1)) + 1;
top++;
used++;
if (used > high_water) high_water = used;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ class PTO2TaskAllocator {
if (space_at_end >= alloc_size) {
result = static_cast<char *>(heap_base_) + top;
heap_top_ = top + alloc_size;
} else if (tail > alloc_size) {
} else if (tail >= alloc_size) {
result = heap_base_;
heap_top_ = alloc_size;
} else {
Expand Down Expand Up @@ -426,7 +426,7 @@ struct PTO2DepListPool {
*/
PTO2DepListEntry *alloc() {
int32_t used = top - tail;
if (used >= capacity) {
if (used >= capacity - 1) {
LOG_ERROR("========================================");
LOG_ERROR("FATAL: Dependency Pool Overflow!");
LOG_ERROR("========================================");
Expand All @@ -444,7 +444,7 @@ struct PTO2DepListPool {
}
return nullptr;
}
int32_t idx = top % capacity;
int32_t idx = static_cast<int32_t>((static_cast<uint32_t>(top) - 1) % (capacity - 1)) + 1;
top++;
used++;
if (used > high_water) high_water = used;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ class PTO2TaskAllocator {
if (space_at_end >= alloc_size) {
result = static_cast<char *>(heap_base_) + top;
heap_top_ = top + alloc_size;
} else if (tail > alloc_size) {
} else if (tail >= alloc_size) {
result = heap_base_;
heap_top_ = alloc_size;
} else {
Expand Down Expand Up @@ -426,7 +426,7 @@ struct PTO2DepListPool {
*/
PTO2DepListEntry *alloc() {
int32_t used = top - tail;
if (used >= capacity) {
if (used >= capacity - 1) {
LOG_ERROR("========================================");
LOG_ERROR("FATAL: Dependency Pool Overflow!");
LOG_ERROR("========================================");
Expand All @@ -444,7 +444,7 @@ struct PTO2DepListPool {
}
return nullptr;
}
int32_t idx = top % capacity;
int32_t idx = static_cast<int32_t>((static_cast<uint32_t>(top) - 1) % (capacity - 1)) + 1;
top++;
used++;
if (used > high_water) high_water = used;
Expand Down
Loading