Help with this code to run on multiprocesses

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Message
Author
Aacini
Expert
Posts: 1913
Joined: 06 Dec 2011 22:15
Location: México City, México
Contact:

Re: Help with this code to run on multiprocesses

#16 Post by Aacini » 26 Nov 2013 07:26

It is very easy to modify the multi-process version in order to add the frame buffer, just insert these changes; I hope they be clear enough:

Code: Select all

For /L %%. in (1,1,100) do (

   del frame.txt 2>NUL       %replace:  cls%

----------

   rem Wait for parallel processes to end
   call :waitForActiveProcesses

   rem Show the frame        %three lines added%
   cls
   type frame.txt

----------

  set /P "=!line!" < nul >> frame.txt    %redirection added%


Perhaps this version will display a smooth animation in the 12-core CPU. :wink:

Antonio

Magialisk
Posts: 104
Joined: 25 Jul 2013 19:00

Re: Help with this code to run on multiprocesses

#17 Post by Magialisk » 26 Nov 2013 10:23

Nice update Aacini, unfortunately it runs less spectacularly on the 12-thread CPU than I'd expect :lol:

In fact, from what I can see this operation doesn't scale very well to multiprocessing. At least not using the approach/algorithm in your code, and I can't imagine any better approach/algorithm to handling the children... The overhead of managing the children seems to slow it down, and on top of that the actual bottleneck (updating the screen) is not thread dependent, so it seems a poor fit to scaling up big.

Since I'm adding nothing of value to this one on the coding front, I thought I could at least add some testing data from the work CPU.

Code: Select all

# Threads Used     CPU Usage     Animation FPS
1                  18%           ~1.3
2                  25%           ~1.9
3 (default)        35%           ~1.8
6                  45%           ~1.3
10                 58%           ~0.9
There's a sweet spot in there right around 2-3 threads, which I'm sure Antonio already discovered, thus the change from "NUMBER_OF_PROCESSORS-1" to "3" in his code. My testing method was to use my eyeballs to count the number of frames rendered over 15 seconds, so there's some slight room for error, maybe around 0.1 fps.

einstein1969
Expert
Posts: 960
Joined: 15 Jun 2012 13:16
Location: Italy, Rome

Re: Help with this code to run on multiprocesses

#18 Post by einstein1969 » 26 Nov 2013 11:18

@Aacini thanks very much!

@majalisk see other thread! the problem is the same!

I have made a version that on monoprocessor go at 5 FPS without optimizing the sin/cos function

With the trick of Antonio will go very high frame rate! 8)

Allso there is a function in thread of wait-sleep-delay trick developed from Antonio for go more fast! 8)

Einstein1969

Magialisk
Posts: 104
Joined: 25 Jul 2013 19:00

Re: Help with this code to run on multiprocesses

#19 Post by Magialisk » 26 Nov 2013 13:40

einstein, I tested with the ping delay in the above code and unfortunately results are the same as AES - in other words no improvement, in general slight to negligible decrease in performance.

The problem is that you personally are testing on only a single processor, so if that processor is "busy" running a control loop it can't do any real work with the child process. In that situation, by "sleeping" the control loop with a ping, real work is allowed to be done for ~500ms. Hence you see really large speedups in your situation, perhaps close to doubling performance.

On a more modern CPU with even 4 cores, it doesn't scale quite as well, unfortunately. Sleeping the controller to run a 4th PID instead of 3 doesn't give as large of a percentage reduction in total time, as I'm sure you can see the obvious reasons. Going further up to my 12-thread machine it gives no improvement at all, and actually tends to hurt performance slightly.

I believe this is related to the non-linear scaling of these programs in the first place, where for example 1 thread takes 60 seconds, 2 might take 32 seconds (almost perfect scaling) but then 4 takes 25 seconds (not much scaling) 8 takes 20 seconds, etc.. etc.. diminishing returns. Extrapolating from that, adding a "partial" 12th thread that can run only while the controller is slept will give almost no advantage. The turning point is probably after 3-4 threads the bang isn't worth the buck, but I haven't tested extensively with enough different CPUs to lend that statement anything more than gut feeling...

einstein1969
Expert
Posts: 960
Joined: 15 Jun 2012 13:16
Location: Italy, Rome

Re: Help with this code to run on multiprocesses

#20 Post by einstein1969 » 26 Nov 2013 15:21

Magialisk wrote:einstein, I tested with the ping delay in the above code and unfortunately results are the same as AES - in other words no improvement, in general slight to negligible decrease in performance.

The problem is that you personally are testing on only a single processor, so if that processor is "busy" running a control loop it can't do any real work with the child process. In that situation, by "sleeping" the control loop with a ping, real work is allowed to be done for ~500ms. Hence you see really large speedups in your situation, perhaps close to doubling performance.

On a more modern CPU with even 4 cores, it doesn't scale quite as well, unfortunately. Sleeping the controller to run a 4th PID instead of 3 doesn't give as large of a percentage reduction in total time, as I'm sure you can see the obvious reasons. Going further up to my 12-thread machine it gives no improvement at all, and actually tends to hurt performance slightly.

I believe this is related to the non-linear scaling of these programs in the first place, where for example 1 thread takes 60 seconds, 2 might take 32 seconds (almost perfect scaling) but then 4 takes 25 seconds (not much scaling) 8 takes 20 seconds, etc.. etc.. diminishing returns. Extrapolating from that, adding a "partial" 12th thread that can run only while the controller is slept will give almost no advantage. The turning point is probably after 3-4 threads the bang isn't worth the buck, but I haven't tested extensively with enough different CPUs to lend that statement anything more than gut feeling...


thanks for explain.

Einstein1969

Aacini
Expert
Posts: 1913
Joined: 06 Dec 2011 22:15
Location: México City, México
Contact:

Re: Help with this code to run on multiprocesses

#21 Post by Aacini » 27 Nov 2013 17:07

I optimized the code trying to perform less operations in less SET /A commands; of course, the result is less clear. I also completely eliminated the calculation of the angle based on the time; although the comment said "rotate two degree at second", each cycle takes more than one second and if it would take less, then it would show two frames with the same angle, so this calculation have no sense. I used "rotate two degree each frame" instead. The new code takes 17% less time than the last single-process version. Here it is:

Code: Select all

@echo off & setlocal EnableDelayedExpansion

set /a cols=34, lines=38

mode con cols=%cols% lines=%lines%

set /a lines-=4, nchar=cols*lines, angle=0

set /a linesDiv2=lines/2, colsDiv2=cols/2

For /L %%a in (1,1,100) do (

   set "frame="

   rem rotate two degree each frame
   set /a "angle=%%a*20000%%450000"

   call :INT_SinD_CosD !angle! sin cos

   set /a "cos=cos/100000, sin=sin/100000"

   for /L %%y in (1,1,%lines%) do (

      set /a "y0=(%%y-linesDiv2)*100/8"

      for /L %%x in (1,1,%cols%) do (

         set /a "x=(%%x-colsDiv2)*100/8, x1=x*cos/100-y0*sin/100, y=x*sin/100+y0*cos/100, x2=x1*x1/100, y2=y*y/100, c1=x2+y2, c2=c1*c1/100*c1/100*c1/100*c1/100, c3=((x2-y2)*8*x1/100*y/100), c4=c3*c3/100, c=c2-c4"

         if !c! lss 0 (set "frame=!frame!*") else set "frame=!frame!."
      )
   )

   cls
   set /p "=!frame!" <nul

)

goto :eof


Antonio

PS - Is "... if it would take less, then it would show..." correctly written? :?

Magialisk
Posts: 104
Joined: 25 Jul 2013 19:00

Re: Help with this code to run on multiprocesses

#22 Post by Magialisk » 27 Nov 2013 18:45

That version is the fastest yet Aacini, over 2 fps and only 6-7% CPU usage on the work machine. Not bad at all, especially for a single process.
Aacini wrote:PS - Is "... if it would take less, then it would show..." correctly written? :?
Made perfect sense to me. I also think your change to two degrees per frame makes perfect sense (speaking algorithmically, not about the English language anymore), as opposed to using %time% in the equation.

einstein1969
Expert
Posts: 960
Joined: 15 Jun 2012 13:16
Location: Italy, Rome

Re: Help with this code to run on multiprocesses

#23 Post by einstein1969 » 28 Nov 2013 06:54

This version is not fully optimized. If anyone has suggestions for improvement are well accepted

And I have not even begun to put into practice the advice of Antonio to make multiprocessing (which, however, is what interests me more). I'm working on!

On my pc (MonoProcessor/Monocore) comes to about 5-6 fps.

take 4-5 fps with set "O=*." . As you can see this statement only makes you lose 1 FPS :shock:

There 's some expert who can explain why? I do not know!

But It 's like having a pc 5 times faster! :D

Now that makes sense, I changed to 15 degrees per second for most animation cute!

Code: Select all

@echo off & setlocal EnableDelayedExpansion

mode con cols=74 lines=38

set /a "cols=36, lines=38, cols-=2, lines-=4, nchar=cols*lines, angle=0, colsm=cols/2"

set "l0=b=((%%x"
set "l1=-%colsm%)*100/8)*f/100-i, e=((%%x"
set "l2=-%colsm%)*100/8)*g/100+j, d=b*b/100+e*e/100, e=(b*b/100-e*e/100)*8*b/100*e/100"
set "l3=(1-((d*d/100*d/100*d/100*d/100-e*e/100)>>31)&1)"

set t0=%time%

set "O=* "

For /L %%. in (1,1,500) do (

  echo(!time!>%tmp%\t2.time.dat

  type nul>%tmp%\rotate.dat.txt

  for /F "tokens=1-8 delims=:.," %%a in ("%t0: =0%:!time: =0!") do set /a "a=(((1%%e-1%%a)*60)+1%%f-1%%b)*6000+1%%g%%h-1%%c%%d, a+=(a>>31) & 8640000, angle=(a*150000/100)%%450000"&set a=

   set size=-1
   For %%a in (450000000 265650512 140362435 71250163 35763344 17899106
   8951737 4476142 2238105 1119057 559529 279765 139882 69941 34971 17485
   8743 4371 2186 1093 546 273 137 68 34 17 9 4 2 1) do (
   set /a "size+=1"
   set "at!size!=%%a"
   )
   set size=
   if !angle! geq 0 (     set /a "d=607252935, angle*=1000, angle-=450000000, e=d"
                   ) else set /a "d=607252935, angle*=1000, angle+=450000000, e=-d"
   For /L %%# in (1,1,29) do (
     if !angle! lss 0        (set /a "angle+=!at%%#!, f=d/(1<<%%#), d+=e/(1<<%%#), e-=f"
     ) else if !angle! gtr 0 (set /a "angle-=!at%%#!, f=d/(1<<%%#), d-=e/(1<<%%#), e+=f")
   )
   set /a "g=(e+55)/10000000, f=(d+55)/10000000"&set angle=&for /L %%n in (0,1,29) do (set at%%n=)

  for /L %%y in (1,1,%lines%) do (
   set N=
   set /a "i=((%%y-%lines%/2)*100/8)*g/100, j=((%%y-%lines%/2)*100/8)*f/100"
   for /L %%x in (1,4,%cols%) do (
      set /a "%l0%%l1%%l2%, h=10000+%l3%*1000, %l0%+1%l1%+1%l2%, h+=%l3%*100, %l0%+2%l1%+2%l2%, h+=%l3%*10, %l0%+3%l1%+3%l2%, h+=%l3%"
      for /f "tokens=1-4" %%i in ("!h:~1,1! !h:~2,1! !h:~3,1! !h:~4,1!") do set N=!N!!O:~%%~i,1!!O:~%%~j,1!!O:~%%~k,1!!O:~%%~l,1!
   )

   Echo( !N!!N!>>%tmp%\rotate.dat.txt
  )

  cls&type %tmp%\rotate.dat.txt
  set t3=!time!
  <%tmp%\t2.time.dat set /p "t2="

  for /F "tokens=1-8 delims=:.," %%a in ("!t2: =0!:!t3: =0!") do set /a "a=(((1%%e-1%%a)*60)+1%%f-1%%b)*6000+1%%g%%h-1%%c%%d, a+=(a>>31) & 8640000, FPS=10000/a"&echo(FPS=!FPS:~0,-2!.!FPS:~-2![!a!cs]&set t2=&set t3=
  for /F "delims==" %%f in ('set') do if /i not "%%f"=="O" set "%%f="
)


EDIT: I have edited the code for adding 2 decimal at FPS. I have eliminated the dependencies from the INT_SinD_CosD function.

Einstein1969

Magialisk
Posts: 104
Joined: 25 Jul 2013 19:00

Re: Help with this code to run on multiprocesses

#24 Post by Magialisk » 28 Nov 2013 22:50

Just to confirm your findings, 5-6 fps @ 25% usage on my quad core at home. Well done!

I'm guessing the second fan is helping keep the processor cooler so it can run faster :D

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: Help with this code to run on multiprocesses

#25 Post by foxidrive » 28 Nov 2013 23:08

I get 7 to 9 FPS and 7% CPU on an 8 core machine.

einstein1969
Expert
Posts: 960
Joined: 15 Jun 2012 13:16
Location: Italy, Rome

Re: Help with this code to run on multiprocesses

#26 Post by einstein1969 » 29 Nov 2013 14:54

Magialisk wrote:Nice update Aacini, unfortunately it runs less spectacularly on the 12-thread CPU than I'd expect :lol:

In fact, from what I can see this operation doesn't scale very well to multiprocessing. At least not using the approach/algorithm in your code, and I can't imagine any better approach/algorithm to handling the children... The overhead of managing the children seems to slow it down, and on top of that the actual bottleneck (updating the screen) is not thread dependent, so it seems a poor fit to scaling up big.

Since I'm adding nothing of value to this one on the coding front, I thought I could at least add some testing data from the work CPU.

Code: Select all

# Threads Used     CPU Usage     Animation FPS
1                  18%           ~1.3
2                  25%           ~1.9
3 (default)        35%           ~1.8
6                  45%           ~1.3
10                 58%           ~0.9
There's a sweet spot in there right around 2-3 threads, which I'm sure Antonio already discovered, thus the change from "NUMBER_OF_PROCESSORS-1" to "3" in his code. My testing method was to use my eyeballs to count the number of frames rendered over 15 seconds, so there's some slight room for error, maybe around 0.1 fps.


I have study the algo implemented by Antonio and and it was quite difficult to me to understand. I not have a multiprocessor and I can't do test :(

The algorithm calculate each line alternating and using a process for each line, but modulo number core.

The concept look good and it's strange that this is the result. :?

the first thing to do would be to avoid too many synchronizations.

@Antonio
What do you think on partitioning the frame in zone and not interleaving?
What do you say to use the "sort" for recomposing?
And syncronize by using the pipe? (like proc1 | proc2 | proc3 | ....)

Einstein1969

Aacini
Expert
Posts: 1913
Joined: 06 Dec 2011 22:15
Location: México City, México
Contact:

Re: Help with this code to run on multiprocesses

#27 Post by Aacini » 02 Dec 2013 00:21

einstein1969 wrote:This version is not fully optimized. If anyone has suggestions for improvement are well accepted

Einstein1969


I am afraid that you still don't understand that if you want us to help you, you must help us to understand your code!

You made several modifications in your code compared with the last version, but there is not a single explanation about the changes; this point force us to replicate all your changes in order to reach the point where we can go further and optimize that code. If you would explained your changes, we would understand them in a couple minutes instead of spend more than a couple hours in this matter! :evil:

For example, you didn't explained that you made algebraic modifications in the equations in order to perform less operations in the inner most loop, although the resulting equations seems more complex than the originals, nor that you have replicated these calculations four times in each SET /A command in order to simultaneously calculate and draw four points per cycle, etc. I still think that you should started this thread with a short explanation, like this one: "The purpose of this topic is to draw the projection of the 3D-surface given by the equation F(X,Y) = (X^2+Y^2)^5 - ((X^2-Y^2)8XY)^2 on Z=0 plane, from (-2,2) to (2,-2) coordinates..." (like I did in this post) "... and rotate it in the fastest possible animation" (forget the "raytracing" and "multi-process" stuff).

There is a single point that deserve special mention. We all know that if a large number of variables are defined, the processing of a Batch file slow down; what we didn't know is the large amount this point affect the speed of a program when there are few variables. If there are just 40-50 variables with values around 20-60 characters each (that is, the normal environment contents), the addition of just 10-15 short variables slow down the program in a major grade! This means that the only way to run a Batch file at its maximum possible speed is via deleting ALL variables from the environment and try to keep the working variables to the minimum. Even the inclusion of a single short variable (like "SET T2=!TIME!") affects the elapsed time in a measurable amount! :shock: It is faster to store the value in a disk file ("ECHO !TIME! > TEMPFILE.TXT"), later read it ("SET /P T2=< TEMPFILE.TXT") and delete the variable after it was used (with all the involved overhead) that just keep the variable in the environment while other calculations are performed. einstein1969: this point is very important, why you didn't posted it? (I did it! :wink: )

The Batch file below is an optimized version of your last code; it takes an optional parameter that specify the number of simultaneous points that are calculated in each SET /A command. If this parameter is not given, the program uses the largest factor (maximum 26) of the number of columns in the drawing, although this does not assure that this factor produce the fastest animation when the program run in a given computer. If the number of columns have not a factor less or equal 26, the program show an error message. The code is listed here as you like it: with no explanations!

Code: Select all

@echo off
setlocal DisableDelayedExpansion
set bang=!
setlocal EnableDelayedExpansion

rem Graph dimensions:
set /a cols=32, lines=34

set "Num=%~1"
if not defined Num (
   for /L %%i in (1,1,26) do (
      set /A mod=cols%%%%i
      if !mod! equ 0 set Num=%%i
   )
)
if not defined Num echo %cols% columns have not factors less or equal 26 & goto :EOF
set /A mod=cols%%Num
if %mod% neq 0 echo %Num% is not a factor of %cols% columns & goto :EOF

set /a scrCols=cols*2+4, scrLines=lines+4, colsDiv2=cols/2, linesDiv2=lines/2, lastPoint=cols-Num+1, F=0

set "expr="
set "tokens="
set "points="
set "letter=0ABCDEFGHIJKLMNOPQRSTUVWXYZ"
for /L %%h in (1,1,%Num%) do (
   set "expr=!expr!, b=((x-%colsDiv2%)*100/8)*cos/100-i, e=((x-%colsDiv2%)*100/8)*sin/100+j, d=b*b/100+e*e/100, e=(b*b/100-e*e/100)*8*b/100*e/100, h%%h=((d*d/100*d/100*d/100*d/100-e*e/100)>>31)&1, x+=1"
   set "tokens=!tokens! !bang!h%%h!bang!"
   set "points=!points!!bang!O:~%%!letter:~%%h,1!,1!bang!"
)

mode con cols=%scrCols% lines=%scrLines%

For /L %%i in (1,1,500) do (
   for %%a in ("F=!F!") do (
      for /F "delims==" %%v in ('set') do set "%%v="
      set %%a
   )
   echo !time: =0!> "%tmp%\t2.txt"

   rem rotate 15 degree each frame
   set /a "angle=%%i*150000%%450000"

   if !angle! geq 0 (
      set /a x=607252935, angle=angle*1000-450000000, y=x
   ) else (
      set /a x=607252935, angle=angle*1000+450000000, y=-x
   )
   set i=0
   for %%a in (265650512 140362435 71250163 35763344 17899106 8951737
               4476142 2238105 1119057 559529 279765 139882 69941 34971
               17485 8743 4371 2186 1093 546 273 137 68 34 17 9 4 2 1
              ) do (
      if !angle! lss 0 (
         set /a "angle+=%%a, i+=1, dx=x/(1<<i), x+=y/(1<<i), y-=dx"
      ) else (
         set /a "angle-=%%a, i+=1, dx=x/(1<<i), x-=y/(1<<i), y+=dx"
      )
   )
   set /a sin=y/10000000, cos=x/10000000
   for %%v in (angle i x y dx) do set "%%v="

   set "O= *"
   (for /L %%y in (1,1,%lines%) do (
      set "line="
      set /a "i=((%%y-%linesDiv2%)*100/8)*sin/100, j=((%%y-%linesDiv2%)*100/8)*cos/100"
      for /L %%x in (1,%Num%,%lastPoint%) do (
         set /a "x=%%x %expr%"
         for /F "tokens=1-%Num%" %%A in ("%tokens%") do set "line=!line!%points%"
      )
      echo/ !line! !line!
   )) > "%tmp%\frame.txt"

   cls
   type "%tmp%\frame.txt"

   set /P "t2=" < "%tmp%\t2.txt"
   for /F "tokens=1-8 delims=:.," %%a in ("!t2!:!time: =0!") do set /a "a=(((1%%e-1%%a)*60)+1%%f-1%%b)*6000+1%%g%%h-1%%c%%d, a+=(a>>31)&8640000"
   if %%i leq 15 (
      echo Calibrating, please wait...
   ) else (
      set /A "F+=10000/a, FPS=F/(%%i-15)"
      echo Num=%Num%, FPS=!FPS:~0,-2!.!FPS:~-2! [!a!cs]
   )

)

The Batch file below is a modified version that calculate the sin and cos values via a simpler method (direct table access), so it run faster.

Code: Select all

@echo off
setlocal DisableDelayedExpansion
set bang=!
setlocal EnableDelayedExpansion

rem Graph dimensions:
set /a cols=32, lines=34

set "Num=%~1"
if not defined Num (
   for /L %%i in (1,1,26) do (
      set /A mod=cols%%%%i
      if !mod! equ 0 set Num=%%i
   )
)
if not defined Num echo %cols% columns have not factors less or equal 26 & goto :EOF
set /A mod=cols%%Num
if %mod% neq 0 echo %Num% is not a factor of %cols% columns & goto :EOF

set /a scrCols=cols*2+4, scrLines=lines+4, colsDiv2=cols/2, linesDiv2=lines/2, lastPoint=cols-Num+1, F=0

set "expr="
set "tokens="
set "points="
set "letter=0ABCDEFGHIJKLMNOPQRSTUVWXYZ"
for /L %%h in (1,1,%Num%) do (
   set "expr=!expr!, b=((x-%colsDiv2%)*100/8)*cos/65536-i, e=((x-%colsDiv2%)*100/8)*sin/65536+j, d=b*b/100+e*e/100, e=(b*b/100-e*e/100)*8*b/100*e/100, h%%h=((d*d/100*d/100*d/100*d/100-e*e/100)>>31)&1, x+=1"
   set "tokens=!tokens! !bang!h%%h!bang!"
   set "points=!points!!bang!O:~%%!letter:~%%h,1!,1!bang!"
)

mode con cols=%scrCols% lines=%scrLines%

For /L %%i in (1,1,500) do (
   for %%a in ("F=!F!") do (
      for /F "delims==" %%v in ('set') do set "%%v="
      set %%a
   )
   echo !time: =0!> "%tmp%\t2.txt"

   rem rotate 15 degree each frame
   set /a "angle=%%i*15%%45, s=angle*6, c=(44-angle)*6"

set "sin=     0  1144  2287  3430  4572  5712  6850  7987  9121 10252 11380 12505 13626 14742 15855 16962 18064 19161 20252 21336 22415 23486 24550 25607 26656 27697 28729 29753 30767 31772 32768 33754 34729 35693 36647 37590 38521 39441 40348 41243 42126 42995 43852 44695 45525"

set "cos= 47143 47930 48703 49461 50203 50931 51643 52339 53020 53684 54332 54963 55578 56175 56756 57319 57865 58393 58903 59396 59870 60326 60764 61183 61584 61966 62328 62672 62997 63303 63589 63856 64104 64332 64540 64729 64898 65048 65177 65287 65376 65446 65496 65526 65536"

   for /F "tokens=1,2" %%a in ("!s! !c!") do set /A "sin=!sin:~%%a,6!, cos=!cos:~%%b,6!"
   for %%v in (angle s c) do set "%%v="

   set "O= *"
   (for /L %%y in (1,1,%lines%) do (
      set "line="
      set /a "i=((%%y-%linesDiv2%)*100/8)*sin/65536, j=((%%y-%linesDiv2%)*100/8)*cos/65536"
      for /L %%x in (1,%Num%,%lastPoint%) do (
         set /a "x=%%x %expr%"
         for /F "tokens=1-%Num%" %%A in ("%tokens%") do set "line=!line!%points%"
      )
      echo/ !line! !line!
   )) > "%tmp%\frame.txt"

   cls
   type "%tmp%\frame.txt"

   set /P "t2=" < "%tmp%\t2.txt"
   for /F "tokens=1-8 delims=:.," %%a in ("!t2!:!time: =0!") do set /a "a=(((1%%e-1%%a)*60)+1%%f-1%%b)*6000+1%%g%%h-1%%c%%d, a+=(a>>31)&8640000"
   if %%i leq 20 (
      echo Calibrating, please wait...
   ) else (
      set /A "F+=10000/a, FPS=F/(%%i-20)"
      echo Num=%Num%, FPS=!FPS:~0,-2!.!FPS:~-2! [!a!cs]
   )

)


Antonio

einstein1969
Expert
Posts: 960
Joined: 15 Jun 2012 13:16
Location: Italy, Rome

Re: Help with this code to run on multiprocesses

#28 Post by einstein1969 » 02 Dec 2013 05:42

Antonio, Awesome :shock:

You have done an excellent job!

You're right, I had to say at the beginning that I wanted to parallelize to speed up this type of code. But perhaps I've said or taken for granted.

The tricks, however, that are used on a single processor may be used on multiprocessor.

My goal is still to parallelize the whole exceed the threshold of approximately 6.5 fps (with your latest version). There was been a gain of about 20-30%.

Have you considered my ideas about the parallel Synchronization via pipe?

Einstein1969

Post Reply