Use 4 CPU for Multithreading using C in xavier NX

Have you try the v4l2-ctl --stream-mmap to confirm with 4 channel?

A combination of:

https://man7.org/linux/man-pages/man2/sched_setscheduler.2.html

and

https://man7.org/linux/man-pages/man2/sched_setaffinity.2.html

should help you with setting each thread’s CPU affinity in your C program. As @ShaneCCC mentioned, taskset(1) is also another method to move threads to desired CPU.

Hi ShaneCC, AnishAney,
Thanks for your support, Here I have attached the output of command. In command itsself not reading 40fps. where will be the issue.
v4l2-ctl -d /dev/video0 --set-fmt-video=width=4096,height=1,pixelformat=RG8 --set-ctrl bypass_mode=0 --stream-mmap --stream-count=10 --stream-to=test.raw
<< 0.61 fps
< 0.61 fps
< 0.61 fps
< 0.61 fps
< 0.61 fps
< 0.61 fps
< 0.61 fps
< 0.61 fps
< 0.61 fps
Is it the issue of driver.
Thanks for your time

Hi,
After increase echo 1036800000 > vi/rate I can read 4 fps. But I want read frames 40 to 120FPS, How to attain it.

Note
My default $cat vi/max_rate is 409600000 I changed to 1036800000 using forum link: RAW capture over CSI works half speed only - #12 by ShaneCCC
Is any thing I want to change in dtsi file to attain max Vi/rate and how to set max vi/rate through driver and what is the max vi/rate.

My present nvcsi/rate is 314000000. is I want to increase it

Is any other config affect drop in fps .
Thanks for your Time

Try to max the nvcsi/vi clocks and remove the --stream-to=test.raw from the pipeline to clarify.

Hi ShaneCC,
Thanks for your support, In dtsi file where I can set max nvcsi/vi clock.

Boost them by below command.

sudo su
echo 1 > /sys/kernel/debug/bpmp/debug/clk/vi/mrq_rate_locked
echo 1 > /sys/kernel/debug/bpmp/debug/clk/isp/mrq_rate_locked
echo 1 > /sys/kernel/debug/bpmp/debug/clk/nvcsi/mrq_rate_locked
cat /sys/kernel/debug/bpmp/debug/clk/vi/max_rate |tee /sys/kernel/debug/bpmp/debug/clk/vi/rate
cat /sys/kernel/debug/bpmp/debug/clk/isp/max_rate | tee  /sys/kernel/debug/bpmp/debug/clk/isp/rate
cat /sys/kernel/debug/bpmp/debug/clk/nvcsi/max_rate | tee /sys/kernel/debug/bpmp/debug/clk/nvcsi/rate

Hi ShaneCC,
Thanks for your support, I tried this, but my fps increase to 5fps per second but I want to read 40 to 120fps. why there is a frame drop I don’t know could you please suggest any idea.
Thanks for your time.

How did you make sure the sensor is output 120fps as expect?

Hi ShaneCC,
Yes its giving 120fps. We checked.

It’s doesn’t make sense to me. v4l2-ctl command just a simple pipeline shouldn’t have such frame drop problem. Have you try boost the system as performance by nvpmode and jetson_clocks?
How do you check the output?

Hi ShaneCC,
Thanks for your support, Yes I boost the system as performance by nvpmode and jetson_clocks. but it’s reading 4fps, then I added mmap=3 it increase fps to 6FPS. Here I have attached command which is reading 6FPS.

v4l2-ctl -d /dev/video0 --set-fmt-video=width=4096,height=1,pixelformat=RG8 --set-ctrl bypass_mode=0 --stream-mmap=3 --stream-count=100 --stream-to=test1.raw\

Thanks for your time.

What’s the result for below command?

v4l2-ctl -d /dev/video0 --set-fmt-video=width=4096,height=1,pixelformat=RG8 --set-ctrl bypass_mode=0 --stream-mmap --stream-count=100

Hi ShaneCC,
Thanks for your support, In echo 1036800000 > vi/rate ,it’s reading 4fps.

Thanks

Could you enable the trace log the check SOF interval.

echo 1 > /sys/kernel/debug/tracing/tracing_on
echo 30720 > /sys/kernel/debug/tracing/buffer_size_kb
echo 1 > /sys/kernel/debug/tracing/events/tegra_rtcpu/enable
echo 1 > /sys/kernel/debug/tracing/events/freertos/enable
echo 2 > /sys/kernel/debug/camrtc/log-level
echo 1 > /sys/kernel/debug/tracing/events/camera_common/enable
echo > /sys/kernel/debug/tracing/trace
cat /sys/kernel/debug/tracing/trace

Hi ShaneCC,
Thanks for your support, Here I have attached my trace log.

Thanks for your timetrace.log (190.2 KB)

The trace log show the SOF interval is 0.32xx seconds that tell output just about 3 -4 fps only.

Hi ShaneCC,
Thanks for your support, How to increase it speed. Could you suggest any Idea.

Here I have attached my clock detais
sudo /usr/bin/jetson_clocks --show
SOC family:tegra194 Machine:NVIDIA Jetson Xavier NX Developer Kit
Online CPUs: 0-5
CPU Cluster Switching: Disabled
cpu0: Online=1 Governor=schedutil MinFreq=1420800 MaxFreq=1420800 CurrentFreq=1420800 IdleStates: C1=0 c6=0
cpu1: Online=1 Governor=schedutil MinFreq=1420800 MaxFreq=1420800 CurrentFreq=1420800 IdleStates: C1=0 c6=0
cpu2: Online=1 Governor=schedutil MinFreq=1420800 MaxFreq=1420800 CurrentFreq=1420800 IdleStates: C1=0 c6=0
cpu3: Online=1 Governor=schedutil MinFreq=1420800 MaxFreq=1420800 CurrentFreq=1420800 IdleStates: C1=0 c6=0
cpu4: Online=1 Governor=schedutil MinFreq=1420800 MaxFreq=1420800 CurrentFreq=1420800 IdleStates: C1=0 c6=0
cpu5: Online=1 Governor=schedutil MinFreq=1420800 MaxFreq=1420800 CurrentFreq=1420800 IdleStates: C1=0 c6=0
GPU MinFreq=1109250000 MaxFreq=1109250000 CurrentFreq=1109250000
EMC MinFreq=204000000 MaxFreq=1600000000 CurrentFreq=1600000000 FreqOverride=1
Fan: speed=0
NV Power Mode: MODE_15W_6CORE

Thanks for your time

I think it couldn’t be the system performance cause the problem.
From the trace I think it could be the sensor output problem.

Hi ShaneCC,
Thanks for your support, I will check with my team, Could please give any suggestion for this Multi Virtual Channel Implementation in a CSI port using Xavier NX - #59 by JerryChang.

Thanks for your time