numba icon indicating copy to clipboard operation
numba copied to clipboard

Export NRT_MemInfo_new

Open Hardcode84 opened this issue 4 years ago • 7 comments

  • We need it for our extension to allocate arrays with custom dtor

Hardcode84 avatar Nov 21 '21 11:11 Hardcode84

nrt_external.h from https://github.com/numba/numba/pull/4554 should satisfy the usecase for this.

sklam avatar Dec 02 '21 16:12 sklam

My suggestion in the meeting was to add a function, manage_memory_external, that takes does the same thing as manage_memory but takes an extra NRT_ExternalAllocator parameter and then puts that into the allocated object.

DrTodd13 avatar Dec 02 '21 16:12 DrTodd13

https://github.com/numba/numba/blob/master/numba/core/runtime/nrt_external.h#L46

  • manage_memory won't work for me as I need to pass additional data to dtor
  • allocate_external should probably work, I need to check it
  • Most convenient way would be probably to have smth like NRT_MemInfo* (*manage_memory2)(void *data, NRT_managed_dtor_opaque_data dtor, void* dtor_data);

Hardcode84 avatar Dec 02 '21 17:12 Hardcode84

Also, why manage_memory don't have size parameter (and how MemInfo->size is used internally)?

Hardcode84 avatar Dec 02 '21 17:12 Hardcode84

https://github.com/numba/numba/blob/master/numba/core/runtime/nrt_external.h#L46

  • manage_memory won't work for me as I need to pass additional data to dtor
  • allocate_external should probably work, I need to check it
  • Most convenient way would be probably to have smth like NRT_MemInfo* (*manage_memory2)(void *data, NRT_managed_dtor_opaque_data dtor, void* dtor_data);

I think you'd find that the extra opaque data pointer in manage_memory2 would not be sufficient. You'd end up back at NRT_MemInfo * (manage_memory_external)(void *data, void *dtor_data, NRT_ExternalAllocator *allocator). If you can use allocate_external to create it in the first place then that is fine but if Numba must take ownership of externally allocated memory then I think we need this new manage_memory_external function.

DrTodd13 avatar Dec 02 '21 18:12 DrTodd13

Just following up on this PR. Is it still needed in the proposed form or was there some conclusion over a new functionality required?

stuartarchibald avatar Feb 01 '22 12:02 stuartarchibald

Is this still needed?

sklam avatar Jul 19 '22 14:07 sklam

Is this still needed?

CC @Hardcode84

stuartarchibald avatar Jan 25 '23 09:01 stuartarchibald

Following OOB discussion with @Hardcode84, closing this as it is anticipated that it is not needed. Should it be needed in future this can be reopened. Thanks!

stuartarchibald avatar Jan 26 '23 16:01 stuartarchibald