Skip to content

Returning view in c++20 #637

@rsarwar87

Description

@rsarwar87

hi

i have a design on an untrascale with 4 gb ram. i have partitioned it to be half reserved for DMA intake. Problem is when I try to send data that is say, 1.2 GB, the system seems to crash. that is because as returns i am limited to array tuple. i was hoping to send as quickly as possible without needing to copy the memory anywhere using span.

auto& get_adc1_data() {
         std::span<uint32_t, n_desc * n_pts> buffer_view{
             ram_s2mm_1.get_ptr<uint32_t, mem::ocm_s2mm1_range>()
         };
          return buffer_view;
    }

i ran into two problems, it seems

1. incorrect use of static assert. this is because span is supported in g++10 upwards. and this was just a compiler error:

239 | static_assert(req_buff_size <= cmd.payload.size(), "Buffer size too small"); | ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~ tmp/examples/teb808/adc_lvds_dma_ts4//server/interface_DataMover.cpp:239:33: error: 'cmd' is not a constant expression

cmd.payload.size() is not static,. so i changed it to . not sure if i should crash the serverd, or let it pass.

index 905cd7cf..38bce905 100644
--- a/server/__init__.py
+++ b/server/__init__.py
@@ -243,7 +243,9 @@ def parser_generator(driver, operation):
 
     if not has_vector:
         print_required_buff_size(lines, packs)
-        lines.append('    static_assert(req_buff_size <= cmd.payload.size(), "Buffer size too small");\n\n');
+        lines.append('    if (req_buff_size > cmd.payload.size()) {')
+        lines.append('        throw std::runtime_error("Buffer size too small");')
+        lines.append('    }')
 
     for idx, pack in enumerate(packs):
         if pack['family'] == 'scalar':

2. looking at the command DynamicSerializer, it seems its still using a buffer to copy things over. is it possible to implement support for view whitout needing to use the buffer. what may stop it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions