BIPS/Examples/C++: Difference between revisions

From RidgeRun Developer Wiki
No edit summary
No edit summary
 
(6 intermediate revisions by 2 users not shown)
Line 1: Line 1:
'''One to one example'''
<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>:


Example using Command Line Interface (CLI).
Remember the project structure necessary:
<pre>
<pre>
|- src
├── src
      |- examples
   └── examples
          |- one-to-one
        └── one-to-one
              - consumer
           ├── consumer
              - producer
           └── producer
</pre>
</pre>


So, move into one-to-one folder. Using the following command:
=== Executable options ===
<pre>
 
cd src/example/one-to-one
Both executables have the same CLI options. Please, take them into account:
</pre>


Execute in different terminals a producer and consumer. In both cases, you can change or use some arguments. If you want to know what options you can be used, execute:
<pre>
./producer -h
</pre>
Then, the arguments and information of use will be returned:
<pre>
<pre>
Usage:
Usage:
        producer [OPTION]...
consumer/producer [OPTION]...
Optional arguments:
Optional arguments:
        -h, --help: Display this message and exit
-h, --help: Display this message and exit
        --backend BACKEND: Use the specified inter-process shared memory
--backend BACKEND: Use the specified inter-process shared memory
                            backend; BACKEND can be 'shm' or 'nvsci'
                    backend; BACKEND can be 'shm' or 'nvsci'. Default: 'shm'
        --channel CHANNEL: Connect to the specified shared memory channel.
--channel CHANNEL: Connect to the specified shared memory channel.
                            CHANNEL preferably starts with a '/' character
                    CHANNEL preferably starts with a '/' character
                            followed by up to 255 characters, none of which
                    followed by up to 255 characters, none of which
                            are slashes
                    are slashes. Default: channel
        --num-buffers NUM_BUFFERS: Indicate how many shared memory buffers
--num-buffers NUM_BUFFERS: Indicate how many shared memory buffers
                                    to create; NUM_BUFFERS can be a positive
                            to create; NUM_BUFFERS can be a positive
                                    integer
                            integer. Default: 10
        --buffer-size BUFFER_SIZE: Indicate the size in bytes of a shared
--buffer-size BUFFER_SIZE: Indicate the size in bytes of a shared
                                    memory buffer; BUFFER_SIZE can be a
                            memory buffer; BUFFER_SIZE can be a
                                    positive integer
                            positive integer. Default 33 MB
        --exec-order ORDER: Follow execution order for buffer processing
--exec-order ORDER: Follow execution order for buffer processing
                            specified in ORDER; ORDER can be 'in-order' or
                    specified in ORDER; ORDER can be 'in-order' or
                            'out-of-order'
                    'out-of-order'. Default 'in-order'
        --process-size PROCESS_SIZE: Indicate the size in bytes of data to
--process-size PROCESS_SIZE: Indicate the size in bytes of data to
                                      write to/read from shared memory
                              write to/read from shared memory
                                      during execution; PROCESS_SIZE can be
                              during execution; PROCESS_SIZE can be
                                      a integer smaller than BUFFER_SIZE
                              a integer smaller than BUFFER_SIZE. Default:
        --timeout TIMEOUT: Indicate how long to wait for available buffers
                                      same as BUFFER_SIZE
                            before throwing a timeout error; TIMEOUT is
--timeout TIMEOUT: Indicate how long to wait for available buffers
                            measured in seconds and can be a positive
                    before throwing a timeout error; TIMEOUT is
                            integer
                    measured in seconds and can be a positive
        --num-iterations NUM-ITERATIONS: Indicate how long many buffer
                    integer. Default: 15 secs
                            processing iterations to run before exiting;
--num-iterations NUM-ITERATIONS: Indicate how long many buffer
                            NUM-ITERATIONS can be a positive integer
                    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



Previous: Examples Index Next: Examples/Python






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.

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.



Previous: Examples Index Next: Examples/Python