[Discuss OpenCPI] Unexpected behaviour of sequenceLength attribute in protocol argument

From: <dwp_at_md1tech.co.uk>
Date: Fri, 28 Apr 23 13:49:21 +0000

Hi,

Apologies for such a long message. The sequenceLength property does not act as an upper bound if the size in memory of the resulting array is below 8192.

To reproduce:

Create a protocol named `test` with the following spec:

`<Protocol datavaluegranularity="2">`\
` <Operation Name="msg" >`\
` <Argument name="data" type="Short" sequenceLength="64"/>`\
` </Operation>`\
`</Protocol>`

Create a component with the following spec:

`<ComponentSpec>`\
` <DataInterfaceSpec name='test' producer='true' protocol='test-prot.xml'/>`\
`</ComponentSpec>`

Create a C++ worker and add the following lines to the run method:

`std::cout << test.msg().data().size() << std::endl ;`\
`test.msg().data().resize (640) ;`\
`std::cout << test.msg().data().size() << std::endl ;`

You would expect this to give an error, since there is an attempt to resize the array to a value greater than `sequenceLength `however the program outputs:

`0`\
`640`

If instead we have:

`test.msg().data().resize (6400) ;`

We get the following error:

`Container "rcc0" background thread exception: `…` operation "msg" argument "data": sequence size 6400 (12800 bytes) exceeds remaining buffer size (8192)`

\
To see what I believe is the expected behaviour, change the `sequenceLength` attribute in the `test` protocol to 6400. Then in the worker’s run method:\
\
`std::cout << test.msg().data().size() << std::endl ;`\
`test.msg().data().resize (6400) ;`\
`std::cout << test.msg().data().size() << std::endl ;`

outputs :

`0`\
`6400`

as expected, and you can see that the underlying buffer size has been changed if we instead have:

`test.msg().data().resize (6500) ;`

which gives the error:

`Container "rcc0" background thread exception: `…` operation "msg" argument "data": sequence size 6500 (13000 bytes) exceeds remaining buffer size (12800)`

This error is also present if `sequenceLength` is 0 which, according to documentation, is supposed to result in no upper bound.

I discovered this when attempting to create a very large sequence protocol, is there a hard limit on the size in memory of a protocol of 2^16? As when `sequenceLength` is 100,000 I get the following error:

`app failed: Value for property "ocpi_buffer_size_test" of instance "fft" of component "local.uhd.uhd.fft" is invalid for its type: for property ocpi_buffer_size_test: Expression value (2.00064e5) is out of range for UShort type properties (0 to 6.5535e4)`

Thanks in advance,\
Dan






Received on Fri Apr 28 2023 - 13:49:21 CDT

This archive was generated by hypermail 2.3.0 : Fri Jun 05 2026 - 08:45:25 CDT