[Beignet] [PATCH] Fix a negative number alignment bug in RegisterFilePartitioner allocate.
Yang Rong
rong.r.yang at intel.com
Mon May 13 19:39:12 PDT 2013
Signed-off-by: Yang Rong <rong.r.yang at intel.com>
---
backend/src/backend/context.cpp | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/backend/src/backend/context.cpp b/backend/src/backend/context.cpp
index c636b48..0beea1d 100644
--- a/backend/src/backend/context.cpp
+++ b/backend/src/backend/context.cpp
@@ -120,7 +120,12 @@ namespace gbe
continue;
}
} else {
- aligned = ALIGN(list->offset+list->size-size-(alignment-1), alignment); //alloc from block's tail
+ int16_t unaligned = list->offset + list->size - size - (alignment-1);
+ if(unaligned < 0) {
+ list = list->prev;
+ continue;
+ }
+ aligned = ALIGN(unaligned, alignment); //alloc from block's tail
spaceOnLeft = aligned - list->offset;
spaceOnRight = list->size - size - spaceOnLeft;
@@ -196,7 +201,6 @@ namespace gbe
// Track the allocation to retrieve the size later
allocatedBlocks.insert(std::make_pair(aligned, size));
-
// We have a valid offset now
return aligned;
}
--
1.7.9.5
More information about the Beignet
mailing list