Description
Currently, cuda_buffer_backend::from_input_buffer accept non-cuda backend rosidl::Buffer, and when there is mismatch between backends, it automatically allocates CUDA memory, without touching the original buffer contents. Since the original buffer descriptor stays in the message field, the following scenario could happen:
- create a default CPU backend buffer
- feed it to
cuda_buffer_backend::from_input_buffer
- use the CUDA memory through WriteHandle
- publish
- For publish step, only the original buffer descriptor can be seen
There is no automatic descriptor conversion in the publish path, so I'd like to recommend to reject such a backend mismatch for the write side. For read side, the automatic conversion is still necessary since some tools, such as rosbag, will publish the buffer with the default cpu fallbacked backend.
Motivation
I'm currently working on shared memory based rosidl::Buffer backend, and thinking about combinations of various backends.
https://github.com/dskkato/memfd_buffer_backend
For now, I'm trying to follow this cuda_buffer_backend design, and realized a bunch of buffer backend combinations to those APIs.
Design / Implementation Considerations
I believe it is better to throw an exception for an unmatched rosidl::Buffer object.
Additional Information
No response
Description
Currently,
cuda_buffer_backend::from_input_bufferaccept non-cuda backendrosidl::Buffer, and when there is mismatch between backends, it automatically allocates CUDA memory, without touching the original buffer contents. Since the original buffer descriptor stays in the message field, the following scenario could happen:cuda_buffer_backend::from_input_bufferThere is no automatic descriptor conversion in the publish path, so I'd like to recommend to reject such a backend mismatch for the write side. For read side, the automatic conversion is still necessary since some tools, such as rosbag, will publish the buffer with the default cpu fallbacked backend.
Motivation
I'm currently working on shared memory based rosidl::Buffer backend, and thinking about combinations of various backends.
https://github.com/dskkato/memfd_buffer_backend
For now, I'm trying to follow this cuda_buffer_backend design, and realized a bunch of buffer backend combinations to those APIs.
Design / Implementation Considerations
I believe it is better to throw an exception for an unmatched rosidl::Buffer object.
Additional Information
No response