The ROme OpTimistic Simulator  2.0.0
A General-Purpose Multithreaded Parallel/Distributed Simulation Platform
checkpoints.c File Reference

State saving and restore for model state buffers. More...

#include <stdlib.h>
#include <stdio.h>
#include <fcntl.h>
#include <mm/dymelor.h>
#include <core/timer.h>
#include <core/core.h>
#include <scheduler/scheduler.h>
#include <scheduler/process.h>
#include <statistics/statistics.h>
+ Include dependency graph for checkpoints.c:

Go to the source code of this file.

Macros

#define copy_from_area(x)
 
#define copy_to_area(x)
 

Functions

void * log_full (struct lp_struct *lp)
 
void * log_state (struct lp_struct *lp)
 
void restore_full (struct lp_struct *lp, void *ckpt)
 
void log_restore (struct lp_struct *lp, state_t *state_queue_node)
 
void log_delete (void *ckpt)
 

Detailed Description

State saving and restore for model state buffers.

State saving and restore for model state buffers

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

Author
Roberto Toccaceli
Alessandro Pellegrini
Roberto Vitali
Francesco Quaglia

Definition in file checkpoints.c.

Macro Definition Documentation

#define copy_from_area (   x)
Value:
({\
memcpy(ptr, (void*)((char*)m_area->area + ((x) * chunk_size)), chunk_size);\
ptr = (void*)((char*)ptr + chunk_size);})
#define copy_to_area (   x)
Value:
({\
memcpy((void*)((char*)m_area->area + ((x) * chunk_size)), ptr, chunk_size);\
ptr += chunk_size;})

Function Documentation

void log_delete ( void *  ckpt)

This function is called directly from the simulation platform kernel to delete a certain log during the fossil collection.

Author
Alessandro Pellegrini
Roberto Vitali
Parameters
ckpta pointer to the simulation state which must be deleted

Definition at line 371 of file checkpoints.c.

+ Here is the caller graph for this function:

void* log_full ( struct lp_struct lp)

This function creates a full log of the current simulation states and returns a pointer to it. The algorithm behind this function is based on packing of the really allocated memory chunks into a contiguous memory area, exploiting some threshold-based approach to fasten it up even more. The contiguous copy is performed precomputing the size of the full log, and then scanning it using a pointer for storing the relevant information.

For further information, please see the paper: R. Toccaceli, F. Quaglia DyMeLoR: Dynamic Memory Logger and Restorer Library for Optimistic Simulation Objects with Generic Memory Layout Proceedings of the 22nd Workshop on Principles of Advanced and Distributed Simulation 2008

To fully understand the changes in this function to support the incremental logging as well, please point to the paper: A. Pellegrini, R. Vitali, F. Quaglia Di-DyMeLoR: Logging only Dirty Chunks for Efficient Management of Dynamic Memory Based Optimistic Simulation Objects Proceedings of the 23rd Workshop on Principles of Advanced and Distributed Simulation 2009

Author
Roberto Toccaceli
Francesco Quaglia
Alessandro Pellegrini
Roberto Vitali
Parameters
lpA pointer to the lp_struct of the LP for which we are taking a full log of the buffers keeping the current simulation state.
Returns
A pointer to a malloc()'d memory area which contains the full log of the current simulation state, along with the relative meta-data which can be used to perform a restore operation.

Definition at line 76 of file checkpoints.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void log_restore ( struct lp_struct lp,
state_t state_queue_node 
)

Upon the decision of performing a rollback operation, this function is invoked by the simulation kernel to perform a restore operation. This function checks the mark in the malloc_state telling whether we're dealing with a full or partial log, and calls the proper function accordingly

Author
Alessandro Pellegrini
Roberto Vitali
Parameters
lpA pointer to the lp_struct of the LP for which we are restoring model-specific buffers keeping the simulation state
state_queue_nodea pointer to a node in the state queue keeping the state which must be restored in the logical process live image

Definition at line 355 of file checkpoints.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void* log_state ( struct lp_struct lp)

This function is the only log function which should be called from the simulation platform. Actually, it is a demultiplexer which calls the correct function depending on the current configuration of the platform. Note that this function only returns a pointer to a malloc'd area which contains the state buffers. This means that this memory area cannot be used as-is, but should be wrapped into a state_t structure, which gives information about the simulation state pointer (defined via SetState() by the application-level code and the lvt associated with the log. This is done implicitly by the LogState() function, which in turn connects the newly taken snapshot with the currencly-scheduled LP. Therefore, any point of the simulator which wants to take a (real) log, shouldn't call directly this function, rather LogState() should be used, after having correctly set current and current_lvt.

Author
Alessandro Pellegrini
Parameters
lpA pointer to the lp_struct of the LP for which we want to take a snapshot of the buffers used by the model to keep state variables.
Returns
A pointer to a malloc()'d memory area which contains the log of the current simulation state, along with the relative meta-data which can be used to perform a restore operation.

Definition at line 195 of file checkpoints.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void restore_full ( struct lp_struct lp,
void *  ckpt 
)

This function restores a full log in the address space where the logical process will be able to use it as the current state. Operations performed by the algorithm are mostly the opposite of the corresponding log_full function.

For further information, please see the paper: R. Toccaceli, F. Quaglia DyMeLoR: Dynamic Memory Logger and Restorer Library for Optimistic Simulation Objects with Generic Memory Layout Proceedings of the 22nd Workshop on Principles of Advanced and Distributed Simulation 2008

Author
Roberto Toccaceli
Francesco Quaglia
Roberto Vitali
Alessandro Pellegrini
Parameters
lpA pointer to the lp_struct of the LP for which we are restoring the content of simulation state buffers, taking it from the checkpoint
ckptA pointer to the checkpoint to take the previous content of the buffers to be restored

Definition at line 225 of file checkpoints.c.

+ Here is the caller graph for this function: