-
-
Notifications
You must be signed in to change notification settings - Fork 571
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
aligned_malloc and realloc for MemoryAllocator #27292
Comments
New commits:
|
Branch: public/27292 |
Commit: |
Branch pushed to git repo; I updated commit sha1. New commits:
|
Branch pushed to git repo; I updated commit sha1. New commits:
|
comment:5
This is mostly looking good. Just a few comments:
|
comment:6
While you're at it, could you move |
Reviewer: Jeroen Demeyer |
Branch pushed to git repo; I updated commit sha1. New commits:
|
Branch pushed to git repo; I updated commit sha1. New commits:
|
Branch pushed to git repo; I updated commit sha1. New commits:
|
comment:11
Why the plus 1? Isn't that making it more complicated than it should be? |
comment:12
Instead of returning an index in |
comment:13
I'll work on this. |
Changed author from Jonathan Kliem to Jonathan Kliem, Jeroen Demeyer |
comment:14
I wanted to reserve an except value. It turns out that -1 would work just as good and is more natural. There are never Replying to @jdemeyer:
Yes, indeed. I never thought about returning the actual place where the pointer is stored. |
comment:16
After seeing the code, I made some changes to the design, mainly to simplify things. I implemented Needs review. |
comment:17
Doesn't |
comment:18
Replying to @nbruin:
What I don't like about |
comment:19
Replying to @jdemeyer:
calloc functionality would be trivial to build on top of posix_memalign: a simply API conversion and zero out the memory block.
Indeed, It looks to me you're paying a rather hefty penalty with the current design:
I doubt that the occasional "realloc" that might be satisfied without relocating the memory block will be worth paying the other penalties all the time. |
comment:20
Replying to @nbruin:
It's a common misconception that
Indeed, this is a penalty to pay. But if the alignment value is relatively small to the size of the allocation (which I expect to be the typical case), then it doesn't matter so much.
We're already doing that in |
comment:21
Replying to @nbruin:
Similarly, for large allocations |
Changed reviewer from Jeroen Demeyer to Jeroen Demeyer, Jonathan Kliem |
comment:22
To me, this looks fine and good to go. But I am a newbie. |
comment:23
Looks OK to me too. It would seem to me the allocator could use a "free" too, but that's perhaps something for another ticket (and perhaps doesn't come up in its applications). |
Changed reviewer from Jeroen Demeyer, Jonathan Kliem to Jeroen Demeyer, Jonathan Kliem, Nils Bruin |
Changed branch from public/27292 to |
Adding realloc and aligned_alloc to
MemoryAllocator
.realloc
is available incysignals.memory
anyway, so we might as well have it inMemoryAllocator
.aligned_malloc
is useful for intrinsics, when memory up to 64-byte aligned is required. There are also similar functions in C, but its nice to have the memory taken care of byMemoryAllocator
.Component: cython
Author: Jonathan Kliem, Jeroen Demeyer
Branch/Commit:
61ad091
Reviewer: Jeroen Demeyer, Jonathan Kliem, Nils Bruin
Issue created by migration from https://trac.sagemath.org/ticket/27292
The text was updated successfully, but these errors were encountered: