I have to run video encoding program, where I have different quantization parameters QP. QP goes from 0 to 51. In my perl script I iterate over this parameter and execute command line. The command line is qiven with:
TAppEncoder encoder_intra_main_rext.cfg -i BSEQ.RAW -b BSEQ_1.bin -o /dev/null -qp 1 -wdt 7811 -hgt 7911 -fr 1 -fs 0 -f 2 --InputBitDepth=16 --OutputBitDepth=16 --InternalBitDepth=16 --InputChromaFormat=400 --ConformanceMode=1 --SEIDecodedPictureHash >> BSEQ_1.txt
In each iteration I change ONLY qp. Now, in my Perl script when I execute the line above, it waits to finish and than proceed to the next iteration in the loop (e.g. qp=2
).
Also perl script has been called by the top level shell script:
test.sh ---> test.pl ---> command1 with qp=1
---> command2 with qp=2
---> command3 with qp=3
---> command4 with qp=4
---> until the end of the for loop
I was wondering how to run two (or more) processes in parallel. For example, to run qp=1
and immediately after qp=2
, without waiting qp=1
to finish. And than when one of those two is done (no matter if qp=1 or qp=2 finished first) to run qp=3, and so on.
So basically, I do not want to run the perl script in parallel, do not need multiple instances of the perl script. I need command within script (which is part of the loop) to be run in parallel. However, if there is other way to accomplis this, let me know.
The part of the code is below, now it runs one qp at the time. I want to run 2 in the parallel all the time, once one is done to go to the next, so all the time 2 processes are running.
I'm running scripts on linux mint. Im running it on one computer (I do not have a cluster). The idea is to tun it on a two cores.
Any idea how to accomplish that, or at least where to start? Thanks.
$QP_end = $Configuration->{nb_QPs}-1;
foreach $QP_index (0 .. $QP_end)
{
$QP = $Configuration->{QP_list}[$QP_index];
print($QP," ");
set_command_line(); # HERE I CHANGE THE QP TO SET NEW COMMAND LINE, AND THEN EXECUTE THE NEW COMMAND
@RunCommand = ($command_line);
`@RunCommand`;
}