nverke commented on code in PR #13197:
URL: https://github.com/apache/tvm/pull/13197#discussion_r1004999799
##########
tests/cpp-runtime/hexagon/hexagon_vtcm_pool_tests.cc:
##########
@@ -164,6 +166,45 @@ TEST_F(HexagonVtcmPoolTest, free_alloc_combinations) {
vtcm_pool->Free(ptr4, max_bytes);
}
+TEST_F(HexagonVtcmPoolTest, find_allocation) {
+ void* ptr1;
+ void* ptr2;
+ void* ptr3;
+ void* ptr4;
+ void* new_ptr;
+
+ ptr1 = vtcm_pool->Allocate(min_bytes);
+ ptr2 = vtcm_pool->Allocate(one_k_block);
+ ptr3 = vtcm_pool->Allocate(two_k_block);
+ // Free 2, realloc it, make sure it is the same as before
+ vtcm_pool->Free(ptr2, two_k_block);
+
+ ptr4 = vtcm_pool->Allocate(four_k_block);
+ new_ptr = vtcm_pool->Allocate(two_k_block);
+ CHECK(new_ptr == ptr3);
+
+ vtcm_pool->Free(ptr1, min_bytes);
+ vtcm_pool->Free(ptr2, one_k_block);
+ vtcm_pool->Free(ptr3, two_k_block);
+ vtcm_pool->Free(ptr4, four_k_block);
+
+ new_ptr = vtcm_pool->Allocate(min_bytes);
+ CHECK(new_ptr == ptr1);
+
+ new_ptr = vtcm_pool->Allocate(one_k_block);
+ CHECK(new_ptr == ptr2);
+
+ new_ptr = vtcm_pool->Allocate(two_k_block);
+ CHECK(new_ptr == ptr3);
+
+ new_ptr = vtcm_pool->Allocate(four_k_block);
+ CHECK(new_ptr == ptr4);
+
+ // Make sure at the end we have the full amount available again
+ ptr4 = vtcm_pool->Allocate(max_bytes);
+ vtcm_pool->Free(ptr4, max_bytes);
+}
+
Review Comment:
✅
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]