You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[C++] Refactor memory allocation from InvertKernel #20710
subtask for overall fix to remove memory allocation. Do this first to make sure I understand the problem and acceptable solution (seems like a simple API change).
Wes McKinney / @wesm:
To be clear, we need to have a usable code path for both the case of
allocate memory and invoke kernel
invoke kernel on pre-allocated memory
Right now we only have the first option.
There's some code that partly handles this issue in kernels/cast.cc, but it could also benefit from some refactoring (to make the "allocate output space" problem more generic / reusable for other kernel implementations)
Micah Kornfield / @emkornfield: @wesm Yes, sorry misleading title. I changed it. I'm still ramping up on the code base, so I'm not sure on the desired outcome here.
It seems there are a two things that could be done:
Replicate this pattern to the boolean kernels and document this contract.
Change/Add API entry points to make the choice on allocation more explicit and more generic.
My intention was to move forward with option 1, and hopefully factor out some of the code from AllocateIfNotPreallocated to a utility method. If option 2 is desired, I would rather do a little bit more work with Kernels before I trying to propose an appropriate API.
Wes McKinney / @wesm:
My preference would be to not allocate memory at all in the implementation of Call for fixed-width / primitive outputs. This is discussed as it relates to Cast in ARROW-1896.
If the output is binary or nested then things have to be handled a bit differently
Activity
asfimport commentedon Dec 27, 2018
Wes McKinney / @wesm:
To be clear, we need to have a usable code path for both the case of
allocate memory and invoke kernel
invoke kernel on pre-allocated memory
Right now we only have the first option.
There's some code that partly handles this issue in kernels/cast.cc, but it could also benefit from some refactoring (to make the "allocate output space" problem more generic / reusable for other kernel implementations)
asfimport commentedon Dec 27, 2018
Micah Kornfield / @emkornfield:
@wesm Yes, sorry misleading title. I changed it. I'm still ramping up on the code base, so I'm not sure on the desired outcome here.
Looking quickly at the the code in cast.cc (https://github.com/apache/arrow/blob/master/cpp/src/arrow/compute/kernels/cast.cc#L1103[)](https://github.com/apache/arrow/blob/master/cpp/src/arrow/compute/kernels/cast.cc#L710)) seems to be assuming that if the array buffers are already allocated those are fine to use.
It seems there are a two things that could be done:
Replicate this pattern to the boolean kernels and document this contract.
Change/Add API entry points to make the choice on allocation more explicit and more generic.
My intention was to move forward with option 1, and hopefully factor out some of the code from AllocateIfNotPreallocated to a utility method. If option 2 is desired, I would rather do a little bit more work with Kernels before I trying to propose an appropriate API.
asfimport commentedon Dec 27, 2018
Wes McKinney / @wesm:
My preference would be to not allocate memory at all in the implementation of
Callfor fixed-width / primitive outputs. This is discussed as it relates toCastin ARROW-1896.If the output is binary or nested then things have to be handled a bit differently
asfimport commentedon Feb 3, 2019
Micah Kornfield / @emkornfield:
I attached the wrong Jira number to the PR for this (#3287)