Skip to content

Instantly share code, notes, and snippets.

@ftessier
Created February 5, 2016 16:16
Show Gist options
  • Save ftessier/a4e5d0ee255ba4f6f338 to your computer and use it in GitHub Desktop.
Save ftessier/a4e5d0ee255ba4f6f338 to your computer and use it in GitHub Desktop.
@echo off
REM #################################################################################
REM
REM usage:
REM egs-parallel.bat (or double-click on this file)
REM
REM #################################################################################
REM # ask about command and number of processes
echo.
set /p egscommand=Enter the EGSnrc command you want to run:
set /p nstr=Enter number of parallel jobs:
set /a n=%nstr%
REM # Ready?
echo.
choice /N /M "Ready to run %egscommand% using %n% jobs [YN] ? "
if errorlevel 2 exit /b
REM ### launch $n EGSnrc jobs in parallel, in the background
echo.
for /l %%j in (1,1,%n%) do (
echo LAUNCHING job %%j of %n%: %egscommand% -b -P %n% -j %%j -f 1
start /b %egscommand% -b -P %n% -j %%j -f 1 >NUL 2>&1
)
@zhanglin-1993
Copy link

I'm so glad to see your work on the parallel calculation of the egs_cbct and it does work on my computer.But maybe something was wrong with that. When I run the procedure without parallel, the time is about 1100s, but when I run 4 jobs at the same time, the time will be about 550s.Do you know the reason? Thanks.

@edoerner
Copy link

Dear @ftessier, first of all thanks for the bat file!. I have a strange behavior with the bat file. It issues the commands for parallel execution, however, neither start execution untiI I enter a single command that triggers the parallel execution, for example, using egs_chamber I do the following on my terminal:

C:[...]>egs-parallel.bat
Enter the EGSnrc command you want to run:egs_chamber -i gk_egs_chamber -p gk521icru
Enter number of parallel jobs:16
Ready to run egs_chamber -i gk_egs_chamber -p gk521icru using 16 jobs [YN] ?Y

LAUNCHING job 1 of 16: egs_chamber -i gk_egs_chamber -p gk521icru -b -P 16 -j 1 -f 1
LAUNCHING job 2 of 16: egs_chamber -i gk_egs_chamber -p gk521icru -b -P 16 -j 2 -f 1
[ ... ]
LAUNCHING job 16 of 16: egs_chamber -i gk_egs_chamber -p gk521icru -b -P 16 -j 16 -f 1

however nothing happens, the processes do not start. In order to do so I have to issue a single command to execute the user code, for example:

C:[...]>egs_chamber -i gk_egs_chamber -p gk521icru

Then all processes start execution. Does this happen to you?. Anyway then everything works perfect, however it is just a bit strange.

@edoerner
Copy link

I answered myself, I just had to add a delay after each command call, I added:
timeout /t 2 /nobreak > NUL
after line 25 (start /b ...)

have a nice day!.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment