improve aligned allocation performance

This commit is contained in:
daan 2021-12-17 13:18:05 -08:00
parent 684c2c82a7
commit 89f583a69b
5 changed files with 108 additions and 43 deletions

View file

@ -42,7 +42,7 @@ int main() {
free(p1);
free(p2);
free(s);
/* now test if override worked by allocating/freeing across the api's*/
//p1 = mi_malloc(32);
//free(p1);

View file

@ -158,6 +158,16 @@ int main(void) {
CHECK_BODY("malloc-aligned5", {
void* p = mi_malloc_aligned(4097,4096); size_t usable = mi_usable_size(p); result = usable >= 4097 && usable < 10000; mi_free(p);
});
CHECK_BODY("malloc-aligned6", {
void* p;
bool ok = true;
for (int i = 1; i < 8 && ok; i++) {
size_t align = 1UL << i;
p = mi_malloc_aligned(2*align, align);
ok = (p != NULL && (uintptr_t)(p) % align == 0); mi_free(p);
}
result = ok;
});
CHECK_BODY("malloc-aligned-at1", {
void* p = mi_malloc_aligned_at(48,32,0); result = (p != NULL && ((uintptr_t)(p) + 0) % 32 == 0); mi_free(p);
});
@ -172,8 +182,8 @@ int main(void) {
ok = (p != NULL && (uintptr_t)(p) % 16 == 0); mi_free(p);
}
result = ok;
});
});
// ---------------------------------------------------
// Heaps
// ---------------------------------------------------