Entity, it is necessary to decide which LP it will
live at, based on the partitioning strategy used. An
LP represents a single running thread of the sim-
ulation with a common clock value; in SimCore,
each LP is mapped to a distinct physical process.
• The ServiceManager is responsible for creating
the services on the entities, as well as reading in
the service related data before creating the ser-
vices.
• The InfoManager is responsible for mapping
Info types to Info objects and calling the appropri-
ate Info handler object when an info is received.
4.3 Partitioning and Load Balancing
Entities are mapped to LPs by a placement function.
The same function is later used to find which LP each
entity lives on, while sending messages. The user may
use any function and register it with a call to the Entity
Manager. The default placement function is a modulo
function based on the entity identifier, though differ-
ent placement schemes that map entities to LPs can
also be used. Entity placement and partitioning is one
of the crucial factors in the performance of a parallel,
discrete event simulation. We provide a detailed dis-
cussion of the performance of different partitioning
strategies from a load balancing perspective in (Thu-
lasidasan et al., 2010) and (Thulasidasan et al., 2009).
5 PYTHON INTEGRATION
To enable construction of simulation applications in
Python, we export the APIs from the three main Sim-
Core classes (Entity, Service, Info) to the Python
space. For the Python interface generation we use
the Boost.Python (Abrahams and Grosse-Kuntsleve,
2003) library which provides fairly seamless operabil-
ity between C++ and Python. Boost.Python provides
comprehensive mapping between C++ and Python
constructs, and supports advance templated meta-
programming techniques. There is support for excep-
tion handling, iterators, operator over-loading, stan-
dard template library (STL) containers and Python
collections, smart pointers and virtual functions that
can be over-ridden in Python. This feature makes the
interface bidirectional i.e user-extensions in Python
can be also invoked from C++.
Since each class and function has to be manu-
ally wrapped in Boost.Python code, to make this pro-
cess less cumbersome we use the Py++ (Py++, 2012)
automatic code generation utility that wraps input
C++ code inside Boost.Python constructs. Py++ is
based on the GCC-XML (GCC-XML, 2012), a GCC
based parser that generates XML representation of
C++ code. Using the XML output and user gen-
erated rules regarding API export, Py++ generates
the Boost.Python interface. This is then compiled
and linked against the Boost.Python and SimCore li-
braries to produce a module that can be imported in-
side Python. A schematic of the build-chain is shown
in Figure 2.
6 SimCore APPLICATIONS
In this section we briefly present some of the simula-
tion applications that have been developed at LANL
using the SimCore library. These applications were
built to model the large scale behavior and complex
interdependencies between various socio-technical
systems, and have been used in numerous real world
simulation studies to analyze the dynamics of vari-
ous national infrastructure The interested reader is re-
ferred to the relevant publications that describe these
applications in more detail.
• FastTrans Described in (Thulasidasan and Eiden-
benz, 2009; Thulasidasan et al., 2009), FastTrans
is a scalable, parallel microsimulator for trans-
portation networks that can simulate and route
tens of millions of vehicles on real-world road net-
works in a fraction of real time. Vehicular trips are
generated using agent-based simulations that pro-
vide realistic, daily activity schedules for a syn-
thetic population of millions of intelligent agents.
In FastTrans, simulation entities are the fixed ele-
ments of the road network – road links and traffic
intersections. All the properties of the network –
capacity, flow rate, etc – are members of the rel-
evant entity class. The scheduling logic at a traf-
fic intersection is implemented as a service on the
traffic-node entity. The modular design allows the
scheduling policy to be easily changed by simply
replacing one scheduling service with another.
The mobile elements of the simulation (vehicles)
are represented using messages. Vehicle objects
(messages) are created and destroyed during the
start and end of a trip, respectively. Since Fast-
Trans uses a distributed-memory model, different
entities of the road network are created in different
memory spaces during simulation start-up. Each
simulation process (also known as Logical Pro-
cess, or LP) in the Entity creation, partitioning
and LP set up are all, as described before, handled
seamlessly by the SimCore layer.
• MIITS (Multi-Scale Integrated Information
SIMULTECH2012-2ndInternationalConferenceonSimulationandModelingMethodologies,Technologiesand
Applications
74