-
Notifications
You must be signed in to change notification settings - Fork 69
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
Provide a way to override memory allocator for frames #486
Conversation
Just let you know that I finished the initial implementation of the AD plugin relying on this feature, it's in https://github.com/dls-controls/ADExternal |
88a2ad5
to
a6b6dec
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understand the need for this capability.
I wonder if something more is needed to make this more general. For example, in a driver one might want to assign the NDArray::pData to the buffer that a vendor library allocated, to avoid the copy operation. Plugins would still use the normal allocators. The problem is that when it comes time to free() one needs a flag to indicate whether this buffer was allocated by the vendor library or by the normal mechanism. How does one do that?
@sveseli I know you have a derived NDArrayPool class. How do you handle this, and do you have any comments on this PR?
From what it looks like, the changes in this PR will work for what they were intended. However, I believe we already put in place a more general set of interfaces that would allow one to do this (the four methods starting with https://github.com/areaDetector/ADCore/blob/master/ADApp/ADSrc/NDArrayPool.cpp#L56). In the APS DAQ software we have a separate pool class for each type of DAQ object that we need to create and manage (see, for example, https://git.aps.anl.gov/C2/daq/modules/daq-base/-/blob/master/src/pva/daq/pva/PvaNDArrayPool.h#L55). This allows us to use AD framework with our own objects that inherit from NDArray. |
The thing is ... making a subclass of For my application, I needed to force the source of the frames to use shared memory, the way I proposed will force every plugin and driver to use shared memory and that way my plugin can get frames from anywhere. @sveseli , unfortunately, I don't have access permission for your link, I assume the buffers allocated by your @MarkRivers , this is a different problem right? in your case, you want to use special allocation only for the output frame of one plugin, not for everything. It's also an interesting problem, so let's brainstorm a few solutions:
|
@EmilioPeJu , if you'd like, we could probably get you read access to APS DAQ repositories, just send me email. In our case, we do not really use internal NDArray buffer, but instead create our own objects that are destroyed when the delete is called. The IOC driver instantiates the appropriate pool class, not individual plugins (see, for example https://git.aps.anl.gov/C2/daq/iocs/daq-ps-ioc/-/blob/master/src/driver/PsDaqDriver.cpp?ref_type=heads#L339). Looking at the NDArrayPool code again, I think you are right, there should be additional hooks that that would hide malloc/free calls. |
a6b6dec
to
e0e3208
Compare
OK, I've amended my commit and provided a hook to locally override the frame buffer allocation and deallocation functions. |
It can be done local to a `NDArrayPool` by overriding `frameMalloc` and `frameFree`. It can also be also done globally by using the static method `setDefaultFrameMemoryFunctions`
e0e3208
to
5a4eaaf
Compare
See issue #487