parallel runs using &

566 views
Skip to first unread message

giorgio corbellini

unread,
Feb 8, 2012, 5:22:54 AM2/8/12
to omnetpp
Hi all,

I can use a machine with multiple cores and I'd like to execute
multiple runs in parallel using the command line. I don't want to
parallelize the simulator, but just to run several parallel runs. To
do so I wrote a script in bash and used the & command, the script is
similar to:

opp_run ... -r 0..9 ... config.ini & opp_run ... -r 10..19 ...
config.ini

I noticed that simulation results are strange, it seems like if
parallel runs are executing both of them are writing/reading in the
same temporary files, as result when the finish() method of one run is
executed results are not correct. (I mean different with respect to
serial execution of the same runs). Is that a known issue? Have you
smarter idea to run parallel processes?

best regards

giorgio

Rudolf Hornig

unread,
Feb 8, 2012, 6:23:15 AM2/8/12
to omn...@googlegroups.com
This is not related to temporary files overwritten by each other as omnet does not do that (if it writes out a file it always qualifies it with the run number).

The different results are most likely because running several runs in the *same* process are very prone to C++  programming errors. e.g. if you have a static variable that is initialized on process load, your are bound to fail because (static) initialization is done only when the process is started (when run 0 start, but it is not initialized for runs 1..9)

Because of this, you should always run each simulation in a separate process (i.e. never use -r 0..7 construct).

Now the good thing is, parallelization is supported by omnet out of box.

- from the IDE: in the Launch dialog just switch to Cmdenv and specify the number of processors/cores you want to use and specify * for the run number. The IDE will do the rest for you by starting each run in a separate process (also you will get consolidated progress report)
- from the command line: use the "opp_runall" script. Specify your simulation executable and parameters. You CAN specify -r 0..9 here because opp_runall will parse out it from the command line and will not pass it to the simulation but instead it will do some magic to run each run in separate process (and pass only a single run number to it). You can set the required parallelism using the -j command line argument. In short:

$ opp_runall -j 6 ./mysimulation -r 0..15 

This will run the specified 16 runs parallel on 6 cores.

(if you are wondering how it is done, the opp_runall script creates a temporary makefile with a target for each run and a default target that depends on each run target. After this, it invokes make with the specified -j parameter. GNU make itself handles the parallelism and parallel process starting and ensures that no more than the specified number of processes are running at the same time. Even is some processes are finishing earlier that the others.

Rudolf


giorgio

--
Sent from the OMNeT++ mailing list. To configure your membership,
visit http://groups.google.com/group/omnetpp

Reply all
Reply to author
Forward
0 new messages