[Ns-developers] [RFC] Worker Infrastructure - Parallelization in Large
Hagen Paul Pfeifer
hagen at jauu.net
Mon Dec 22 05:00:06 PST 2008
under http://code.nsnam.org/pfeifer/ns-3-worker I published a high level
parallelization approach. Beside a component approach, where some/several
ns-3 subsystems works in parallel, this worker approach parallelize
complete ns-3 instances. The major goal is to speed up a *typical
simulation*
with more then one successive simulation runs.
The majority of simulations is influenced by several successive runs of
equal
or nearly equal simulated scenarios. It is often required to compare two or
more different scenarios (e.g. impact of different propagation models, et
cetera) and therefore start a simulation more the one time. Furthermore,
often
a simulation is started more then one time to determine an average value
(bypass
statistical flaws).
The next few lines show a minimal "hello world" worker application. That
example is generic enough to utilize all available cores at a system at
runtime
(see Worker::GetNumCores()):
#define NUMER_JOBS 20
void parallel(uint32_t id)
{
uint32_t i;
for (i = Worker::ChunkStart (id, Worker::GetNumCores (), NUMER_JOBS);
i <= Worker::ChunkEnd (id, Worker::GetNumCores (), NUMER_JOBS);
i++)
{
std::cerr << "Worker " << id << " process job #"
<< i << std::endl;
}
}
int main(void)
{
Worker worker;
worker.SetWorkers (Worker::GetNumCores ())
worker.AddCallback (MakeCallback (parallel));
worker.Run ();
return 0;
}
Under examples/worker-adhoc.c a complete example is parallelized.
The presented approach is simple and free the programmer to dig in any core
specific optimization. The user must take care of shared resources like
files
(e.g. not to write to the same files twice). The Worker class provides some
methods to make it easy to avoid writing to shared resources.
The presented approach is no high sophisticated parallelization
framework[tm]
but it provides an easy and very effective interface for a huge bunch of
typical simulated scenarios.
Last but no least, the parallelization is based on fork(2) and is therefore
currently limited for UNIX based operation systems.
Best regards, Hagen Paul Pfeifer
More information about the Ns-developers
mailing list