![]() |
The ROme OpTimistic Simulator
2.0.0
A General-Purpose Multithreaded Parallel/Distributed Simulation Platform
|
This file contains the implementation of the the agent based modeling interface offered by ROOT-Sim. More...
#include <ROOT-Sim.h>
#include <lib/abm_layer.h>
#include <core/init.h>
#include <scheduler/scheduler.h>
#include <lib/topology.h>
#include <datatypes/array.h>
#include <datatypes/hash_map.h>
Go to the source code of this file.
Data Structures | |
struct | _visit_abm_t |
struct | _agent_abm_t |
struct | _region_abm_t |
struct | _leave_evt |
Macros | |
#define | ACTION_START INIT |
#define | retrieve_agent(agent_id) |
Functions | |
static unsigned long long | get_agent_mark (region_abm_t *region) |
static unsigned | agent_dump_size (const struct _agent_abm_t *agent) |
static struct _agent_abm_t * | agent_from_buffer (const unsigned char *event_content, unsigned event_size) |
static void | agent_to_buffer (struct _agent_abm_t *agent, unsigned char *buffer) |
unsigned char * | abm_do_checkpoint (region_abm_t *region) |
void | abm_restore_checkpoint (unsigned char *data, region_abm_t *region) |
void | abm_layer_init (void) |
static void | receive_update (void) |
static void | update_neighbours (void) |
static void | on_abm_visit (void) |
static void | on_abm_leave (void) |
void | ProcessEventABM (void) |
int | GetNeighbourInfo (direction_t i, unsigned int *region_id, void **data_p) |
void | TrackNeighbourInfo (void *neighbour_data) |
bool | IterAgents (agent_t *agent_p) |
unsigned | CountAgents (void) |
agent_t | SpawnAgent (unsigned user_data_size) |
void | KillAgent (agent_t agent_id) |
void * | DataAgent (agent_t agent_id, unsigned *data_size_p) |
void | ScheduleNewLeaveEvent (simtime_t time, unsigned int event_type, agent_t agent_id) |
unsigned | CountPastVisits (agent_t agent_id) |
void | GetPastVisit (agent_t agent_id, unsigned *region_p, unsigned *event_type_p, simtime_t *time_p, unsigned i) |
unsigned | CountVisits (agent_t agent_id) |
void | GetVisit (agent_t agent_id, unsigned *region_p, unsigned *event_type_p, unsigned i) |
void | SetVisit (agent_t agent_id, unsigned region, unsigned event_type, unsigned i) |
void | EnqueueVisit (agent_t agent_id, unsigned region, unsigned event_type) |
void | AddVisit (agent_t agent_id, unsigned region, unsigned event_type, unsigned i) |
void | RemoveVisit (agent_t agent_id, unsigned i) |
This file contains the implementation of the the agent based modeling interface offered by ROOT-Sim.
Copyright (C) 2008-2018 HPDCS Group http://www.dis.uniroma1.it/~hpdcs
This file is part of ROOT-Sim (ROme OpTimistic Simulator).
ROOT-Sim is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; only version 3 of the License applies.
ROOT-Sim is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with ROOT-Sim; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Definition in file abm_layer.c.
#define retrieve_agent | ( | agent_id | ) |
Definition at line 38 of file abm_layer.c.
unsigned char* abm_do_checkpoint | ( | region_abm_t * | region | ) |
Checkpoint the region state, saving it into a buffer. This is periodically called by the checkpointing module to save the region state. The returned buffer needs to be freed.
region | A pointer to the region struct to be checkpointed |
Definition at line 161 of file abm_layer.c.
void abm_layer_init | ( | void | ) |
Initializes the abm layer internals for all the lps hosted on the machine. This needs to be called before starting processing events, after basic initialization of the lps.
Definition at line 235 of file abm_layer.c.
void abm_restore_checkpoint | ( | unsigned char * | data, |
region_abm_t * | region | ||
) |
Restore a region struct from a previously checkpointed state.
data | A pointer to the region struct to be checkpointed |
Definition at line 198 of file abm_layer.c.
|
static |
Compute the size in bytes of an eventual agent serialization.
agent | A pointer to the agent |
Definition at line 90 of file abm_layer.c.
|
static |
Deserialize an agent from a buffer.
event_content | A pointer to the buffer containing the serialzied agent |
event_size | The size in bytes of the buffer |
Definition at line 103 of file abm_layer.c.
|
static |
Serialize an agent into a buffer, the buffer is caller supplied and its required size can be calculated with the function agent_dump_size.
agent | A pointer to the agent struct to be serialized |
buffer | A pointer to the buffer to fill with the serialized agent |
Definition at line 136 of file abm_layer.c.
|
static |
Handle an agent departure. This is called by the abm layer when a leave message is received. We expect the event to have the the agent key as payload.
Definition at line 326 of file abm_layer.c.
|
static |
Handle a visit to a region. This is called by the abm layer when a visit message is received. We expect the event to have the serialized visiting agent as payload.
Definition at line 297 of file abm_layer.c.
void ProcessEventABM | ( | void | ) |
The event handler which gets called instead of the user supplied ProcessEvent() function when the abm_layer is in use. The unrecognized events get passed to ProcessEventTopology() since the abm layer is based on the topology APIs.
Definition at line 461 of file abm_layer.c.
|
static |
Handle an update receive. This updates the corresponding entry in the region struct, which will be used to serve fresh neighbour data to the user.
Definition at line 419 of file abm_layer.c.
|
static |
Keep updated the neighbours of changes in the tracked data. This is called after each event and boradcasts eventual changes to neighbours
Definition at line 438 of file abm_layer.c.