1 #include <../../nrnconf.h>
34 #define ASSERTfgets(a, b, c) nrn_assert(fgets(a, b, c) != 0)
35 #define ASSERTfread(a, b, c, d) nrn_assert(fread(a, b, c, d) == c)
36 #define ASSERTfwrite(a, b, c, d) nrn_assert(fwrite(a, b, c, d) == c)
84 bool check(
bool warn);
193 for (
int i = 0;
i <
cnt; ++
i) {
200 for (
int i = 0;
i <
cnt; ++
i) {
208 for (
int i = 0;
i <
cnt; ++
i) {
220 for (
int i = 0;
i <
cnt; ++
i) {
222 b = ss[
i].
root ? 1 : 0;
232 nct =
s->u.ctemplate;
258 if (
ssi[im].offset < 0) {
278 "SaveState warning: %d sections exist but saved %d\n",
287 "SaveState warning: %d cells exist but saved %d\n",
310 for (
int isec = 0; isec <
nsec_; ++isec) {
316 fprintf(stderr,
"SaveState warning: saved section no longer exists\n");
319 "SaveState warning: %s has %d nodes but saved %d\n",
327 for (
int inode = 0; inode < ss.
nnode; ++inode) {
332 for (
p = nd->
prop;
p;
p =
p->next) {
339 "SaveState warning: \
340 fewer mechanisms saved than exist at node %d of %s\n",
346 if (
p->_type != ns.
type[
i]) {
349 "SaveState warning: mechanisms out of order at node %d of %s\n\
350 saved %s but need %s\n",
364 "SaveState warning: more mechanisms saved than exist at node %d of %s\n",
371 if (!
sec->parentsec || ss.
root) {
372 if (
sec->parentsec || !ss.
root) {
375 "SaveState warning: Saved section and %s are not both root sections.\n",
393 for (
p = nd->
prop;
p;
p =
p->next) {
400 "SaveState warning: \
401 fewer mechanisms saved than exist at a root node\n");
405 if (
p->_type != ns.
type[
i]) {
408 "SaveState warning: mechanisms out of order at a rootnode\n\
409 saved %s but need %s\n",
419 fprintf(stderr,
"SaveState warning: more mechanisms saved than exist at a rootnode\n");
430 "SaveState warning: different number of %s saved than exist.\n",
456 for (inode = 0; inode < ss.
nnode; ++inode) {
461 if (!
sec->parentsec) {
492 for (
p = nd->
prop;
p;
p =
p->next) {
506 for (
p = nd->
prop;
p;
p =
p->next) {
526 for (isec = 0; isec <
nsec_; ++isec) {
528 for (inode = 0; inode < ss.
nnode; ++inode) {
604 for (
int isec = 0; isec <
nsec_; ++isec) {
607 for (
int inode = 0; inode < ss.
nnode; ++inode) {
627 prs_[
i] = e->savestate_save();
656 for (
int ip =
ssi[
type].offset; ip < max; ++ip) {
657 ns.
state[istate++] =
p->param_legacy(ip);
668 for (
int j = 0;
j < sz; ++
j) {
676 hoc_execerror(
"SaveState:",
"Stored state inconsistent with current neuron structure");
682 for (
int isec = 0; isec <
nsec_; ++isec) {
685 for (
int inode = 0; inode < ss.
nnode; ++inode) {
707 assert(nprs_ <= prl->size());
714 hoc_execerror(
"SaveState:",
"This state requires Python to unpack.");
737 for (
int ip =
ssi[
type].offset; ip < max; ++ip) {
738 p->param_legacy(ip) = ns.
state[istate++];
749 for (
int j = 0;
j < sz; ++
j) {
765 if (strcmp(
buf,
"SaveState binary file version 6.0\n") != 0) {
766 if (strcmp(
buf,
"SaveState binary file version 7.0\n") == 0) {
770 hoc_execerror(
"Bad SaveState binary file",
" Neither version 6.0 or 7.0");
786 for (
int isec = 0; isec <
nsec_; ++isec) {
791 for (
int inode = 0; inode < ss.
nnode; ++inode) {
817 sscanf(
buf,
"%d\n", &
n);
821 int nt = 0, nc = 0, ns = 0;
853 }
catch (
const std::bad_alloc& e) {
874 fprintf(f,
"SaveState binary file version %d.0\n", version);
878 for (
int isec = 0; isec <
nsec_; ++isec) {
881 for (
int inode = 0; inode < ss.
nnode; ++inode) {
909 fprintf(f,
"%d\n",
nprs_);
911 fprintf(f,
"%d %d\n",
prs_[
i]->pr_->type(),
i);
1035 sscanf(
buf,
"%d\n", &
n);
1041 for (
int i = 0;
i <
n; ++
i) {
1069 hoc_execerror(
"SaveState::readnet",
"Unimplemented DiscreteEvent type");
1078 fprintf(f,
"%d\n",
nncs_);
1085 fprintf(f,
"%d\n",
npss_);
1090 fprintf(f,
"%d\n",
n);
1093 for (
int i = 0;
i <
n; ++
i) {
1103 "SaveState warning: There are %d NetCon but %d saved\n",
1117 "SaveState warning: %s is matched with NetCon[%d]\n",
1119 ncs_[
i].object_index);
1126 "SaveState warning: %s has %d weight states but saved %d\n",
1143 "SaveState warning: There are %d internal PreSyn but %d saved\n",
1172 ps->hi_index_ =
npss_;
1242 close =
chkarg(2, 0, 1) ? true :
false;
1255 close =
chkarg(2, 0, 1) ? true :
false;
1258 ss->
write(f, close);
1266 {
nullptr,
nullptr}};
const char * secname(Section *sec)
name of section (for use in error messages)
virtual DiscreteEvent * savestate_save()
virtual void savestate_write(FILE *)
static DiscreteEvent * savestate_read(FILE *)
virtual void savestate_restore(double deliverytime, NetCvode *)
static DiscreteEvent * savestate_read(FILE *)
static DiscreteEvent * savestate_read(FILE *)
static DiscreteEvent * savestate_read(FILE *)
bool open(const char *filename, const char *type)
static DiscreteEvent * savestate_read(FILE *)
static PlayRecordSave * savestate_read(FILE *)
virtual void savestate_restore()
virtual void savestate_write(FILE *)
static DiscreteEvent * savestate_read(FILE *)
virtual void unref() const
virtual void write(OcFile *, bool close)
void restorenode(NodeState &, Node *)
virtual void restore(int type)
void restoreacell(ACellState &, int type)
void saveacell(ACellState &, int type)
bool checknode(NodeState &, Node *, bool)
void fwrite_SecState(SecState *, int, FILE *)
void tqsave(const TQItem *, int)
void fread_SecState(SecState *, int, FILE *)
void fread_NodeState(NodeState *, int, FILE *)
virtual void read(OcFile *, bool close)
void savenode(NodeState &, Node *)
bool checkacell(ACellState &, int type, bool)
void allocnode(NodeState &, Node *)
void tqcount(const TQItem *, int)
void fwrite_NodeState(NodeState *, int, FILE *)
void allocacell(ACellState &, int type)
static DiscreteEvent * savestate_read(FILE *)
void forall_callback(void(*)(const TQItem *, int))
void class2oc(const char *, ctor_f *cons, dtor_f *destruct, Member_func *, Member_ret_obj_func *, Member_ret_str_func *)
#define PlayRecordEventType
constexpr auto enumerate(T &&iterable)
double chkarg(int, double low, double high)
size_t hoc_total_array_data(const Symbol *s, Objectdata *obd)
void check_obj_type(Object *obj, const char *type_name)
char * hoc_object_name(Object *ob)
Symbol * hoc_lookup(const char *)
Object ** hoc_objgetarg(int)
#define ITERATE(itm, lst)
auto for_threads(NrnThread *threads, int num_threads)
void hoc_execerror(const char *s1, const char *s2)
icycle< ncycle;++icycle) { int istride=stride[icycle];nrn_pragma_acc(loop vector) nrn_pragma_omp(loop bind(parallel)) for(int icore=0;icore< warpsize;++icore) { int i=ii+icore;if(icore< istride) { int ip=GPU_PARENT(i);GPU_RHS(i) -=GPU_B(i) *GPU_RHS(ip);GPU_RHS(i)/=GPU_D(i);} i+=istride;} ii+=istride;} }}void solve_interleaved2(int ith) { NrnThread *nt=nrn_threads+ith;InterleaveInfo &ii=interleave_info[ith];int nwarp=ii.nwarp;if(nwarp==0) return;int ncore=nwarp *warpsize;int *ncycles=ii.cellsize;int *stridedispl=ii.stridedispl;int *strides=ii.stride;int *rootbegin=ii.firstnode;int *nodebegin=ii.lastnode;if(0) { nrn_pragma_acc(parallel loop gang present(nt[0:1], strides[0:nstride], ncycles[0:nwarp], stridedispl[0:nwarp+1], rootbegin[0:nwarp+1], nodebegin[0:nwarp+1]) async(nt->stream_id)) nrn_pragma_omp(target teams loop map(present, alloc:nt[:1], strides[:nstride], ncycles[:nwarp], stridedispl[:nwarp+1], rootbegin[:nwarp+1], nodebegin[:nwarp+1])) for(int icore=0;icore< ncore;icore+=warpsize) { solve_interleaved2_loop_body(nt, icore, ncycles, strides, stridedispl, rootbegin, nodebegin);} nrn_pragma_acc(wait(nt->stream_id)) } else { for(int icore=0;icore< ncore;icore+=warpsize) { solve_interleaved2_loop_body(nt, icore, ncycles, strides, stridedispl, rootbegin, nodebegin);} }}void solve_interleaved1(int ith) { NrnThread *nt=nrn_threads+ith;int ncell=nt-> ncell
#define DiscreteEventType
void section_ref(Section *)
void section_unref(Section *)
#define nrn_assert(x)
assert()-like macro, independent of NDEBUG status
int const size_t const size_t n
int * nrn_prop_param_size_
std::vector< Memb_func > memb_func
int nrn_vartype(const Symbol *sym)
std::vector< Memb_list > memb_list
#define BinaryMode(ocfile)
std::vector< PreSyn * > * net_cvode_instance_psl()
short * nrn_is_artificial_
static double ssread(void *v)
#define ASSERTfread(a, b, c, d)
ReceiveFunc * pnt_receive
static SaveState * this_savestate
static Member_func members[]
static void * cons(Object *)
#define ASSERTfgets(a, b, c)
static void destruct(void *v)
void(* ReceiveFunc)(Point_process *, double *, double)
static double sswrite(void *v)
std::vector< PlayRecord * > * net_cvode_instance_prl()
void(* nrnpy_restore_savestate)(int64_t, char *)
static double save(void *v)
#define ASSERTfwrite(a, b, c, d)
static void tqcallback(const TQItem *tq, int i)
TQueue * net_cvode_instance_event_queue(NrnThread *)
NetCvode * net_cvode_instance
static double restore(void *v)
void(* nrnpy_store_savestate)(char **save_data, uint64_t *save_data_size)
A view into a set of mechanism instances.
std::vector< double * > data()
Get a vector of double* representing the model data.
Represent main neuron object computed by single thread.
A point process is computed just like regular mechanisms.
struct Symbol::@45::@46 rng