NEURON
bbsavestate.cpp File Reference
#include <../../nrnconf.h>
#include "bbsavestate.h"
#include "cabcode.h"
#include "classreg.h"
#include "nrncvode.h"
#include "nrnoc2iv.h"
#include "nrnran123.h"
#include "ocfile.h"
#include <cmath>
#include <nrnmpiuse.h>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <sys/stat.h>
#include <unordered_map>
#include <unordered_set>
#include "netcon.h"
#include "nrniv_mf.h"
#include "tqueue.hpp"
#include "vrecitem.h"
#include "membfunc.h"
#include <ivocvect.h>

Go to the source code of this file.

Classes

class  BBSS_Cnt
 
class  BBSS_TxtFileOut
 
class  BBSS_TxtFileIn
 
class  BBSS_BufferOut
 
class  BBSS_BufferIn
 
struct  StateStructInfo
 
struct  DEList
 
class  SEWrap
 

Macros

#define QUEUECHECK   1
 
#define DEBUG   0
 
#define PDEBUG   f->s(dbuf, 1)
 

Typedefs

typedef void(* ReceiveFunc) (Point_process *, double *, double)
 
typedef void(* PFIO) (int, Object *)
 
typedef std::vector< TQItem * > TQItemList
 
typedef std::unordered_map< Point_process *, int > PointProcessMap
 
typedef struct DEList DEList
 
typedef std::unordered_map< Point_process *, DEList * > PP2DE
 
typedef std::vector< double > DblList
 
typedef std::unordered_map< NetCon *, DblList * > NetCon2DblList
 
typedef std::vector< SEWrap * > SEWrapList
 
typedef std::unordered_map< int, int > Int2Int
 
typedef std::unordered_map< int, DblList * > Int2DblList
 
typedef std::unordered_map< std::string, Section * > SecName2Sec
 

Functions

static void bbss_early (double td, TQItem *tq)
 
void nrn_shape_update ()
 
TQueuenet_cvode_instance_event_queue (NrnThread *)
 
void nrn_netcon_event (NetCon *, double)
 
void nrn_gidout_iter (PFIO)
 
Objectnrn_gid2obj (int gid)
 
PreSynnrn_gid2presyn (int gid)
 
int nrn_gid_exists (int gid)
 
static void nrnmpi_barrier ()
 
static void nrnmpi_int_alltoallv (const int *s, const int *scnt, const int *sdispl, int *r, int *rcnt, int *rdispl)
 
static void nrnmpi_dbl_alltoallv (const double *s, const int *scnt, const int *sdispl, double *r, int *rcnt, int *rdispl)
 
static int nrnmpi_int_allmax (int x)
 
static void nrnmpi_int_allgather (int *s, int *r, int n)
 
static void nrnmpi_int_allgatherv (int *s, int *r, int *n, int *dspl)
 
static void nrnmpi_dbl_allgatherv (double *s, double *r, int *n, int *dspl)
 
void nrn_play_init ()
 
static void tqcallback (const TQItem *tq, int i)
 
static void bbss_queuecheck ()
 
static void * cons (Object *)
 
static void destruct (void *v)
 
static double save (void *v)
 
static void bbss_restore_begin ()
 
static double restore (void *v)
 
static double save_request (void *v)
 
static double save_gid (void *v)
 
static double restore_gid (void *v)
 
static void pycell_name2sec_maps_clear ()
 
static double save_test (void *v)
 
static double save_test_bin (void *v)
 
static double ppignore (void *v)
 
static int ignored (Prop *p)
 
void * bbss_buffer_counts (int *len, int **gids, int **sizes, int *global_size)
 BBSaveState API See save_test_bin and restore_test_bin for an example of the use of this following interface. More...
 
void bbss_save_global (void *bbss, char *buffer, int sz)
 Call only on host 0 with a buffer of size equal to the global_size returned from the bbss_buffer_counts call on host 0 sz is the size of the buffer (for error checking only, buffer+sz is out of bounds) More...
 
void bbss_restore_global (void *bbss, char *buffer, int sz)
 Call on all hosts with the buffer contents returned from the call to bbss_save_global. More...
 
void bbss_save (void *bbss, int gid, char *buffer, int sz)
 Call this for each item of the gids from bbss_buffer_counts along with a buffer of size from the corresponding sizes array. More...
 
void bbss_restore (void *bbss, int gid, int ngroup, char *buffer, int sz)
 Call this for each item of the gids from bbss_buffer_counts, the number of buffers that were concatenated for the gid, and the concatenated buffer (the concatenated buffer does NOT contain npiece as the first value in the char* buffer pointer). More...
 
void bbss_save_done (void *bbss)
 At the end of the save process, call this to cleanup. More...
 
static void bbss_remove_delivered ()
 
void bbss_restore_done (void *bbss)
 At the end of the restore process, call this to do some extra setting up and cleanup. More...
 
static double restore_test (void *v)
 
static double restore_test_bin (void *v)
 
static double vector_play_init (void *v)
 
void BBSaveState_reg ()
 
static void ssi_def ()
 
static double binq_time (double tt)
 
static void del_presyn_info ()
 
static void base2spgid_item (int spgid, Object *obj)
 
static void cb_gidobj (int gid, Object *obj)
 
static void pycell_name2sec_maps_fill ()
 
static SecName2Secpycell_name2sec_map (Object *c)
 
static void all2allv_helper (int *scnt, int *sdispl, int *rcnt, int *rdispl)
 
static void all2allv_int2 (int *scnt, int *sdispl, int *gidsrc, int *ndsrc)
 
static void all2allv_dbl1 (int *scnt, int *sdispl, double *tssrc)
 
static void scatteritems ()
 
static void allgatherv_helper (int cnt, int *rcnt, int *rdspl)
 
static void spikes_on_correct_host (int cnt, int *g, int *dcnts, int tscnt, double *ts, Int2DblList *m)
 
static void construct_presyn_queue ()
 

Variables

bool nrn_use_bin_queue_
 
void(* nrn_binq_enqueue_error_handler )(double, TQItem *)
 
int section_count
 
Section ** secorder
 
ReceiveFuncpnt_receive
 
NetCvodenet_cvode_instance
 
cTemplate ** nrn_pnt_template_
 
double t
 
short * nrn_is_artificial_
 
Symlisthoc_built_in_symlist
 
static bool use_spikecompress_
 
static bool use_gidcompress_
 
static int callback_mode
 
static TQItemListtq_presyn_fanout
 
static TQItemListtq_removal_list
 
static int debug = DEBUG
 
static char dbuf [1024]
 
static BBSaveStatebbss
 
static int usebin_
 
static std::unique_ptr< PointProcessMappp_ignore_map
 
static Member_func members []
 
static StateStructInfossi
 
static cTemplatenct
 
static std::unique_ptr< PP2DEpp2de
 
static std::unique_ptr< NetCon2DblListnc2dblist
 
static SEWrapListsewrap_list
 
static std::unique_ptr< Int2Intbase2spgid {new Int2Int()}
 
static std::unique_ptr< Int2DblListsrc2send {new Int2DblList()}
 
static int src2send_cnt
 
static std::unique_ptr< Int2DblListqueuecheck_gid2unc
 
static std::unique_ptr< Int2DblListpresyn_queue
 
static std::unordered_map< void *, SecName2Secpycell_name2sec_maps
 
static int giddest_size
 
static int * giddest
 
static int * tsdest_cnts
 
static double * tsdest
 

Macro Definition Documentation

◆ DEBUG

#define DEBUG   0

Definition at line 297 of file bbsavestate.cpp.

◆ PDEBUG

#define PDEBUG   f->s(dbuf, 1)

Definition at line 303 of file bbsavestate.cpp.

◆ QUEUECHECK

#define QUEUECHECK   1

Definition at line 291 of file bbsavestate.cpp.

Typedef Documentation

◆ DblList

typedef std::vector<double> DblList

Definition at line 1095 of file bbsavestate.cpp.

◆ DEList

typedef struct DEList DEList

◆ Int2DblList

typedef std::unordered_map<int, DblList*> Int2DblList

Definition at line 1141 of file bbsavestate.cpp.

◆ Int2Int

typedef std::unordered_map<int, int> Int2Int

Definition at line 1137 of file bbsavestate.cpp.

◆ NetCon2DblList

typedef std::unordered_map<NetCon*, DblList*> NetCon2DblList

Definition at line 1096 of file bbsavestate.cpp.

◆ PFIO

typedef void(* PFIO) (int, Object *)

Definition at line 212 of file bbsavestate.cpp.

◆ PointProcessMap

typedef std::unordered_map<Point_process*, int> PointProcessMap

Definition at line 746 of file bbsavestate.cpp.

◆ PP2DE

typedef std::unordered_map<Point_process*, DEList*> PP2DE

Definition at line 1092 of file bbsavestate.cpp.

◆ ReceiveFunc

typedef void(* ReceiveFunc) (Point_process *, double *, double)

Definition at line 200 of file bbsavestate.cpp.

◆ SecName2Sec

typedef std::unordered_map<std::string, Section*> SecName2Sec

Definition at line 1718 of file bbsavestate.cpp.

◆ SEWrapList

typedef std::vector<SEWrap*> SEWrapList

Definition at line 1134 of file bbsavestate.cpp.

◆ TQItemList

typedef std::vector<TQItem*> TQItemList

Definition at line 287 of file bbsavestate.cpp.

Function Documentation

◆ all2allv_dbl1()

static void all2allv_dbl1 ( int *  scnt,
int *  sdispl,
double *  tssrc 
)
static

Definition at line 2370 of file bbsavestate.cpp.

◆ all2allv_helper()

static void all2allv_helper ( int *  scnt,
int *  sdispl,
int *  rcnt,
int *  rdispl 
)
static

Definition at line 2329 of file bbsavestate.cpp.

◆ all2allv_int2()

static void all2allv_int2 ( int *  scnt,
int *  sdispl,
int *  gidsrc,
int *  ndsrc 
)
static

Definition at line 2346 of file bbsavestate.cpp.

◆ allgatherv_helper()

static void allgatherv_helper ( int  cnt,
int *  rcnt,
int *  rdspl 
)
static

Definition at line 2485 of file bbsavestate.cpp.

◆ base2spgid_item()

static void base2spgid_item ( int  spgid,
Object obj 
)
static

Definition at line 1518 of file bbsavestate.cpp.

◆ BBSaveState_reg()

void BBSaveState_reg ( )

Definition at line 1012 of file bbsavestate.cpp.

◆ bbss_buffer_counts()

void* bbss_buffer_counts ( int *  len,
int **  gids,
int **  sizes,
int *  global_size 
)

BBSaveState API See save_test_bin and restore_test_bin for an example of the use of this following interface.

Note in particular the use in restore_test_bin of a prior clear_event_queue() in order to allow bbss_buffer_counts to pass an assert during the restore process. First call to return the information needed to make the other calls. Returns a pointer used by the other methods. Caller is reponsible for freeing (using free() and not delete []) the returned gids and sizes arrays when finished. The sizes array and global_size are needed for the caller to construct proper buffer sizes to pass to bbss_save_global and bbss_save for filling in. The size of these arrays is returned in *len. They are not needed for restoring (since the caller is passing already filled in buffers that are read by bbss_restore_global and bbss_restore. The gids returned are base gids. It is the callers responsibility to somehow concatenate buffers with the same gid (from different hosts) either after save or before restore and preserve the piece count of the number of concatenated buffers for each base gid. Global_size will only be non_zero for host 0.

Definition at line 773 of file bbsavestate.cpp.

◆ bbss_early()

static void bbss_early ( double  td,
TQItem tq 
)
static

Definition at line 1189 of file bbsavestate.cpp.

◆ bbss_queuecheck()

static void bbss_queuecheck ( )
static

Definition at line 2816 of file bbsavestate.cpp.

◆ bbss_remove_delivered()

static void bbss_remove_delivered ( )
static

Definition at line 823 of file bbsavestate.cpp.

◆ bbss_restore()

void bbss_restore ( void *  bbss,
int  gid,
int  npiece,
char *  buffer,
int  sz 
)

Call this for each item of the gids from bbss_buffer_counts, the number of buffers that were concatenated for the gid, and the concatenated buffer (the concatenated buffer does NOT contain npiece as the first value in the char* buffer pointer).

sz is the size of the buffer (error checking only).

Definition at line 807 of file bbsavestate.cpp.

◆ bbss_restore_begin()

static void bbss_restore_begin ( )
static

Definition at line 606 of file bbsavestate.cpp.

◆ bbss_restore_done()

void bbss_restore_done ( void *  bbss)

At the end of the restore process, call this to do some extra setting up and cleanup.

When this call returns, bbss will be invalid.

Definition at line 856 of file bbsavestate.cpp.

◆ bbss_restore_global()

void bbss_restore_global ( void *  bbss,
char *  buffer,
int  sz 
)

Call on all hosts with the buffer contents returned from the call to bbss_save_global.

This must be called prior to any calls to bbss_restore sz is the size of the buffer (error checking only). This also does some other important restore initializations.

Definition at line 791 of file bbsavestate.cpp.

◆ bbss_save()

void bbss_save ( void *  bbss,
int  gid,
char *  buffer,
int  sz 
)

Call this for each item of the gids from bbss_buffer_counts along with a buffer of size from the corresponding sizes array.

The buffer will be filled in with savestate information. The gid may be the same on different hosts, in which case it is the callers responsibility to concatentate buffers at some point to allow calling of bbss_restore. sz is the size of the buffer (error checking only).

Definition at line 799 of file bbsavestate.cpp.

◆ bbss_save_done()

void bbss_save_done ( void *  bbss)

At the end of the save process, call this to cleanup.

When this call returns, bbss will be invalid.

Definition at line 818 of file bbsavestate.cpp.

◆ bbss_save_global()

void bbss_save_global ( void *  bbss,
char *  buffer,
int  sz 
)

Call only on host 0 with a buffer of size equal to the global_size returned from the bbss_buffer_counts call on host 0 sz is the size of the buffer (for error checking only, buffer+sz is out of bounds)

Definition at line 785 of file bbsavestate.cpp.

◆ binq_time()

static double binq_time ( double  tt)
static

Definition at line 1175 of file bbsavestate.cpp.

◆ cb_gidobj()

static void cb_gidobj ( int  gid,
Object obj 
)
static

Definition at line 1634 of file bbsavestate.cpp.

◆ cons()

static void* cons ( Object )
static

Definition at line 586 of file bbsavestate.cpp.

◆ construct_presyn_queue()

static void construct_presyn_queue ( )
static

Definition at line 2550 of file bbsavestate.cpp.

◆ del_presyn_info()

static void del_presyn_info ( )
static

Definition at line 1426 of file bbsavestate.cpp.

◆ destruct()

static void destruct ( void *  v)
static

Definition at line 591 of file bbsavestate.cpp.

◆ ignored()

static int ignored ( Prop p)
static

Definition at line 763 of file bbsavestate.cpp.

◆ net_cvode_instance_event_queue()

TQueue* net_cvode_instance_event_queue ( NrnThread nt)

Definition at line 270 of file netcvode.cpp.

◆ nrn_gid2obj()

Object * nrn_gid2obj ( int  gid)

Definition at line 1564 of file netpar.cpp.

◆ nrn_gid2presyn()

PreSyn * nrn_gid2presyn ( int  gid)

Definition at line 1568 of file netpar.cpp.

◆ nrn_gid_exists()

int nrn_gid_exists ( int  gid)

Definition at line 1039 of file netpar.cpp.

◆ nrn_gidout_iter()

void nrn_gidout_iter ( PFIO  callback)

Definition at line 1574 of file netpar.cpp.

◆ nrn_netcon_event()

void nrn_netcon_event ( NetCon nc,
double  td 
)

Definition at line 147 of file netcvode.cpp.

◆ nrn_play_init()

void nrn_play_init ( )

Definition at line 76 of file cvodestb.cpp.

◆ nrn_shape_update()

void nrn_shape_update ( )

Definition at line 915 of file treeset.cpp.

◆ nrnmpi_barrier()

static void nrnmpi_barrier ( )
static

Definition at line 228 of file bbsavestate.cpp.

◆ nrnmpi_dbl_allgatherv()

static void nrnmpi_dbl_allgatherv ( double *  s,
double *  r,
int *  n,
int *  dspl 
)
static

Definition at line 262 of file bbsavestate.cpp.

◆ nrnmpi_dbl_alltoallv()

static void nrnmpi_dbl_alltoallv ( const double *  s,
const int *  scnt,
const int *  sdispl,
double *  r,
int *  rcnt,
int *  rdispl 
)
static

Definition at line 239 of file bbsavestate.cpp.

◆ nrnmpi_int_allgather()

static void nrnmpi_int_allgather ( int *  s,
int *  r,
int  n 
)
static

Definition at line 252 of file bbsavestate.cpp.

◆ nrnmpi_int_allgatherv()

static void nrnmpi_int_allgatherv ( int *  s,
int *  r,
int *  n,
int *  dspl 
)
static

Definition at line 257 of file bbsavestate.cpp.

◆ nrnmpi_int_allmax()

static int nrnmpi_int_allmax ( int  x)
static

Definition at line 249 of file bbsavestate.cpp.

◆ nrnmpi_int_alltoallv()

static void nrnmpi_int_alltoallv ( const int *  s,
const int *  scnt,
const int *  sdispl,
int *  r,
int *  rcnt,
int *  rdispl 
)
static

Definition at line 229 of file bbsavestate.cpp.

◆ ppignore()

static double ppignore ( void *  v)
static

Definition at line 749 of file bbsavestate.cpp.

◆ pycell_name2sec_map()

static SecName2Sec& pycell_name2sec_map ( Object c)
static

Definition at line 1761 of file bbsavestate.cpp.

◆ pycell_name2sec_maps_clear()

static void pycell_name2sec_maps_clear ( )
static

Definition at line 1722 of file bbsavestate.cpp.

◆ pycell_name2sec_maps_fill()

static void pycell_name2sec_maps_fill ( )
static

Definition at line 1726 of file bbsavestate.cpp.

◆ restore()

static double restore ( void *  v)
static

Definition at line 625 of file bbsavestate.cpp.

◆ restore_gid()

static double restore_gid ( void *  v)
static

Definition at line 664 of file bbsavestate.cpp.

◆ restore_test()

static double restore_test ( void *  v)
static

Definition at line 898 of file bbsavestate.cpp.

◆ restore_test_bin()

static double restore_test_bin ( void *  v)
static

Definition at line 930 of file bbsavestate.cpp.

◆ save()

static double save ( void *  v)
static

Definition at line 596 of file bbsavestate.cpp.

◆ save_gid()

static double save_gid ( void *  v)
static

Definition at line 659 of file bbsavestate.cpp.

◆ save_request()

static double save_request ( void *  v)
static

Definition at line 640 of file bbsavestate.cpp.

◆ save_test()

static double save_test ( void *  v)
static

Definition at line 671 of file bbsavestate.cpp.

◆ save_test_bin()

static double save_test_bin ( void *  v)
static

Definition at line 703 of file bbsavestate.cpp.

◆ scatteritems()

static void scatteritems ( )
static

Definition at line 2392 of file bbsavestate.cpp.

◆ spikes_on_correct_host()

static void spikes_on_correct_host ( int  cnt,
int *  g,
int *  dcnts,
int  tscnt,
double *  ts,
Int2DblList m 
)
static

Definition at line 2493 of file bbsavestate.cpp.

◆ ssi_def()

static void ssi_def ( )
static

Definition at line 1024 of file bbsavestate.cpp.

◆ tqcallback()

static void tqcallback ( const TQItem tq,
int  i 
)
static

Definition at line 1202 of file bbsavestate.cpp.

◆ vector_play_init()

static double vector_play_init ( void *  v)
static

Definition at line 990 of file bbsavestate.cpp.

Variable Documentation

◆ base2spgid

std::unique_ptr<Int2Int> base2spgid {new Int2Int()}
static

Definition at line 1138 of file bbsavestate.cpp.

◆ bbss

BBSaveState* bbss
static

Definition at line 306 of file bbsavestate.cpp.

◆ callback_mode

int callback_mode
static

Definition at line 285 of file bbsavestate.cpp.

◆ dbuf

char dbuf[1024]
static

Definition at line 299 of file bbsavestate.cpp.

◆ debug

int debug = DEBUG
static

Definition at line 298 of file bbsavestate.cpp.

◆ giddest

int* giddest
static

Definition at line 2324 of file bbsavestate.cpp.

◆ giddest_size

int giddest_size
static

Definition at line 2323 of file bbsavestate.cpp.

◆ hoc_built_in_symlist

Symlist* hoc_built_in_symlist
extern

Definition at line 28 of file symbol.cpp.

◆ members

Member_func members[]
static
Initial value:
= {{"save", save},
{"restore", restore},
{"save_test", save_test},
{"restore_test", restore_test},
{"save_test_bin", save_test_bin},
{"restore_test_bin", restore_test_bin},
{"save_request", save_request},
{"save_gid", save_gid},
{"restore_gid", restore_gid},
{"ignore", ppignore},
{"vector_play_init", vector_play_init},
{nullptr, nullptr}}
static double vector_play_init(void *v)
static double save_gid(void *v)
static double ppignore(void *v)
static double restore_gid(void *v)
static double restore_test_bin(void *v)
static double save(void *v)
static double restore_test(void *v)
static double save_test_bin(void *v)
static double save_request(void *v)
static double save_test(void *v)
static double restore(void *v)

Definition at line 995 of file bbsavestate.cpp.

◆ nc2dblist

std::unique_ptr<NetCon2DblList> nc2dblist
static

Definition at line 1097 of file bbsavestate.cpp.

◆ nct

cTemplate* nct
static

Definition at line 1023 of file bbsavestate.cpp.

◆ net_cvode_instance

NetCvode* net_cvode_instance
extern

Definition at line 26 of file cvodestb.cpp.

◆ nrn_binq_enqueue_error_handler

void(* nrn_binq_enqueue_error_handler) (double, TQItem *) ( double  ,
TQItem  
)
extern

Definition at line 44 of file tqueue.cpp.

◆ nrn_is_artificial_

short* nrn_is_artificial_
extern

Definition at line 214 of file init.cpp.

◆ nrn_pnt_template_

cTemplate** nrn_pnt_template_
extern

Definition at line 153 of file init.cpp.

◆ nrn_use_bin_queue_

bool nrn_use_bin_queue_
extern

Definition at line 225 of file netcvode.cpp.

◆ pnt_receive

ReceiveFunc* pnt_receive
extern

Definition at line 155 of file init.cpp.

◆ pp2de

std::unique_ptr<PP2DE> pp2de
static

Definition at line 1093 of file bbsavestate.cpp.

◆ pp_ignore_map

std::unique_ptr<PointProcessMap> pp_ignore_map
static

Definition at line 747 of file bbsavestate.cpp.

◆ presyn_queue

std::unique_ptr<Int2DblList> presyn_queue
static

Definition at line 1424 of file bbsavestate.cpp.

◆ pycell_name2sec_maps

std::unordered_map<void*, SecName2Sec> pycell_name2sec_maps
static

Definition at line 1719 of file bbsavestate.cpp.

◆ queuecheck_gid2unc

std::unique_ptr<Int2DblList> queuecheck_gid2unc
static

Definition at line 1172 of file bbsavestate.cpp.

◆ secorder

Section** secorder
extern

Definition at line 82 of file solve.cpp.

◆ section_count

int section_count
extern

Definition at line 81 of file solve.cpp.

◆ sewrap_list

SEWrapList* sewrap_list
static

Definition at line 1135 of file bbsavestate.cpp.

◆ src2send

std::unique_ptr<Int2DblList> src2send {new Int2DblList()}
static

Definition at line 1142 of file bbsavestate.cpp.

◆ src2send_cnt

int src2send_cnt
static

Definition at line 1144 of file bbsavestate.cpp.

◆ ssi

StateStructInfo* ssi
static

Definition at line 1022 of file bbsavestate.cpp.

◆ t

double t
extern

Definition at line 57 of file cvodeobj.cpp.

◆ tq_presyn_fanout

TQItemList* tq_presyn_fanout
static

Definition at line 288 of file bbsavestate.cpp.

◆ tq_removal_list

TQItemList* tq_removal_list
static

Definition at line 289 of file bbsavestate.cpp.

◆ tsdest

double* tsdest
static

Definition at line 2326 of file bbsavestate.cpp.

◆ tsdest_cnts

int* tsdest_cnts
static

Definition at line 2325 of file bbsavestate.cpp.

◆ use_gidcompress_

bool use_gidcompress_
static

Definition at line 283 of file bbsavestate.cpp.

◆ use_spikecompress_

bool use_spikecompress_
static

Definition at line 282 of file bbsavestate.cpp.

◆ usebin_

int usebin_
static

Definition at line 310 of file bbsavestate.cpp.