BIPS/Examples/C++: Difference between revisions
No edit summary |
No edit summary |
||
(9 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
<noinclude> | |||
{{BIPS/Head|previous=Examples|next=Examples/Python}} | |||
</noinclude> | |||
<seo title="BIPS/BIPS - C++ Examples | RidgeRun" titlemode="replace" metakeywords="GStreamer, NVIDIA, Jetson, TX1, TX2, Jetson AGX Xavier, Xavier, AI, Deep Learning, Machine Learning, Jetson TX1, Jetson TX2, Jetson Xavier, NVIDIA Jetson Xavier, NVIDIA Jetson Orin, Jetson Orin, Orin, NVIDIA Orin, NVIDIA Jetson AGX Orin, Jetson AGX Orin, Assembly Line, Assembly Line Activity, activity recognition, machine learning activity recognition, Exploratory Data Analysis, EDA" description="This RidgeRun wiki page provides more information on the RidgeRun Buffer Interprocess Sharing (BIPS) process with C++ examples."></seo> | |||
== Introduction == | |||
The C++ examples take into account two possible cases: | |||
* One-to-one communication | |||
* One-to-many in broadcast communication | |||
The example binaries are compiled after building. If the build directory is <code>build</code>: | |||
<pre> | |||
├── src | |||
└── examples | |||
└── one-to-one | |||
├── consumer | |||
└── producer | |||
</pre> | |||
=== Executable options === | |||
Both executables have the same CLI options. Please, take them into account: | |||
<pre> | <pre> | ||
Usage: | |||
consumer/producer [OPTION]... | |||
Optional arguments: | |||
-h, --help: Display this message and exit | |||
--backend BACKEND: Use the specified inter-process shared memory | |||
backend; BACKEND can be 'shm' or 'nvsci'. Default: 'shm' | |||
--channel CHANNEL: Connect to the specified shared memory channel. | |||
CHANNEL preferably starts with a '/' character | |||
followed by up to 255 characters, none of which | |||
are slashes. Default: channel | |||
--num-buffers NUM_BUFFERS: Indicate how many shared memory buffers | |||
to create; NUM_BUFFERS can be a positive | |||
integer. Default: 10 | |||
--buffer-size BUFFER_SIZE: Indicate the size in bytes of a shared | |||
memory buffer; BUFFER_SIZE can be a | |||
positive integer. Default 33 MB | |||
--exec-order ORDER: Follow execution order for buffer processing | |||
specified in ORDER; ORDER can be 'in-order' or | |||
'out-of-order'. Default 'in-order' | |||
--process-size PROCESS_SIZE: Indicate the size in bytes of data to | |||
write to/read from shared memory | |||
during execution; PROCESS_SIZE can be | |||
a integer smaller than BUFFER_SIZE. Default: | |||
same as BUFFER_SIZE | |||
--timeout TIMEOUT: Indicate how long to wait for available buffers | |||
before throwing a timeout error; TIMEOUT is | |||
measured in seconds and can be a positive | |||
integer. Default: 15 secs | |||
--num-iterations NUM-ITERATIONS: Indicate how long many buffer | |||
processing iterations to run before exiting; | |||
NUM-ITERATIONS can be a positive integer. Default: 100 | |||
--logfile LOGFILE: Indicate name of file to log to. Default: consumer.log | |||
or producer.log | |||
</pre> | </pre> | ||
You can use the defaults. | |||
{{Ambox | |||
|type=notice | |||
|small=left | |||
|issue='''Note''': It is recommended to match the configurations in both executables except in the logfile. | |||
|style=width:unset; | |||
}} | |||
== Running the examples == | |||
=== One-to-one example === | |||
1. Open two different terminals: one for the producer and another for the consumer. | |||
2. In terminal 1, execute the producer: | |||
<syntaxhighlight lang=bash> | |||
./producer | |||
</syntaxhighlight> | |||
3. In terminal 2, execute the consumer: | |||
<syntaxhighlight lang=bash> | |||
./consumer | |||
</syntaxhighlight> | |||
=== One-to-many example === | |||
1. Open two different terminals: one for the producer and another for the consumer. | |||
2. In terminal 1, execute the producer: | |||
<syntaxhighlight lang=bash> | |||
./producer | |||
</syntaxhighlight> | |||
3. In terminal 2, execute two consumers: | |||
<syntaxhighlight lang=bash> | |||
./consumer --logfile consumer1.log & ./consumer --logfile consumer2.log | |||
</syntaxhighlight> | |||
You can execute these two consumers in two different consoles as well. | |||
<noinclude> | |||
{{BIPS/Foot|Examples|Examples/Python}} | |||
</noinclude> |
Latest revision as of 21:02, 27 August 2024
Buffer Interprocess Sharing | |
---|---|
BIPS Basics | |
|
|
Getting Started | |
|
|
User Manual | |
|
|
Examples | |
|
|
Performance | |
|
|
Contact Us | |
|
Introduction
The C++ examples take into account two possible cases:
- One-to-one communication
- One-to-many in broadcast communication
The example binaries are compiled after building. If the build directory is build
:
├── src └── examples └── one-to-one ├── consumer └── producer
Executable options
Both executables have the same CLI options. Please, take them into account:
Usage: consumer/producer [OPTION]... Optional arguments: -h, --help: Display this message and exit --backend BACKEND: Use the specified inter-process shared memory backend; BACKEND can be 'shm' or 'nvsci'. Default: 'shm' --channel CHANNEL: Connect to the specified shared memory channel. CHANNEL preferably starts with a '/' character followed by up to 255 characters, none of which are slashes. Default: channel --num-buffers NUM_BUFFERS: Indicate how many shared memory buffers to create; NUM_BUFFERS can be a positive integer. Default: 10 --buffer-size BUFFER_SIZE: Indicate the size in bytes of a shared memory buffer; BUFFER_SIZE can be a positive integer. Default 33 MB --exec-order ORDER: Follow execution order for buffer processing specified in ORDER; ORDER can be 'in-order' or 'out-of-order'. Default 'in-order' --process-size PROCESS_SIZE: Indicate the size in bytes of data to write to/read from shared memory during execution; PROCESS_SIZE can be a integer smaller than BUFFER_SIZE. Default: same as BUFFER_SIZE --timeout TIMEOUT: Indicate how long to wait for available buffers before throwing a timeout error; TIMEOUT is measured in seconds and can be a positive integer. Default: 15 secs --num-iterations NUM-ITERATIONS: Indicate how long many buffer processing iterations to run before exiting; NUM-ITERATIONS can be a positive integer. Default: 100 --logfile LOGFILE: Indicate name of file to log to. Default: consumer.log or producer.log
You can use the defaults.
Note: It is recommended to match the configurations in both executables except in the logfile. |
Running the examples
One-to-one example
1. Open two different terminals: one for the producer and another for the consumer.
2. In terminal 1, execute the producer:
./producer
3. In terminal 2, execute the consumer:
./consumer
One-to-many example
1. Open two different terminals: one for the producer and another for the consumer.
2. In terminal 1, execute the producer:
./producer
3. In terminal 2, execute two consumers:
./consumer --logfile consumer1.log & ./consumer --logfile consumer2.log
You can execute these two consumers in two different consoles as well.