Skip to content

cuda_buffer_backend::from_input_buffer should reject non-cuda backend buffer #8

Description

@dskkato

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

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions