Record Simulation in Parallel Models

General issues of interest both for network and
individual cell parallelization.

Moderator: hines

Post Reply
henrychen1986
Posts: 15
Joined: Wed Nov 25, 2009 7:07 pm

Record Simulation in Parallel Models

Post by henrychen1986 » Tue Sep 07, 2010 3:19 am

Hi,

In my parallel model, I am trying to record the time while i record some time-dependent variables. I can record and save those variables correctly, but the recording of time gives all zero to the recording vector.

Here is my code for time recording.

Code: Select all

objref TRec
TRec = new Vector()

SaveDataDt = 0.1

proc RecTime() {
	TRec.record(&t,SaveDataDt)
}

RecTime()
Thanks in advance!

-Henry

ted
Site Admin
Posts: 5590
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: Record Simulation in Parallel Models

Post by ted » Tue Sep 07, 2010 10:19 pm

What version of NEURON are you using?

hines
Site Admin
Posts: 1577
Joined: Wed May 18, 2005 3:32 pm

Re: Record Simulation in Parallel Models

Post by hines » Wed Sep 08, 2010 2:32 am

There is nothing incorrect about the code fragment you copied. I tested it with
the neurondemo after selecting the HH demo, then pressing Init&Run and seeing that
TRec.printf() printed the times every .1 interval. Some things that can go wrong in
context are
not doing a run()
doing something that calls finitialize() after the run and before saving/printing TRec
unreferencing TRec somehow (recreating it, for example)
and a few other obscure ways. Check first if your fragment works in the neurondemo
context.
If you continue to have difficulty, try changing the record statement to record without
specifying the time interval. If the time now starts getting recorded into TVec
(every time step), is .1 a multiple of dt? Since you wish to record t every .1 ms,
there is no real reason to record it, instead, you can record the other variables at
TRec.indgen(0, tstop, SaveDataDt) and use a second arg of TRec in those
record statements.

henrychen1986
Posts: 15
Joined: Wed Nov 25, 2009 7:07 pm

Re: Record Simulation in Parallel Models

Post by henrychen1986 » Wed Sep 08, 2010 7:26 pm

Thanks for the reply!

Actually, i am doing it in pNEURON. And the run() is implemented as pc.psolve(tstop)
The full code i tested is

Code: Select all

objref pc
pc = new ParallelContext()

objref TRec
TRec = new Vector()

SaveDataDt = 0.1

proc RecTime() {
   TRec.record(&t,SaveDataDt)
}

RecTime()

tstop = 10000
{pc.set_maxstep(10)}

dt = 0.01

init()

t = 0
{pc.psolve(tstop)}

TRec.printf()

{pc.runworker()}
{pc.done()}

hines
Site Admin
Posts: 1577
Joined: Wed May 18, 2005 3:32 pm

Re: Record Simulation in Parallel Models

Post by hines » Thu Sep 09, 2010 1:57 am

You're right. That demonstrates a bug. t is not being updated during
pc.psolve()
That bug came into existence when threads were introduced. Each thread
has its own time variable ->_t and the thread 0 time does not get copied to
the hoc variable, 't', during pc.psolve in many circumstances. The fix would be
to edit nrn/src/nrnoc/fadvance.c: nrn_fixed_step_group and copythe last
line in that function
t = nrn_threads[0]._t;
to the last statement of the various while loops
or else just fill the TVec explicity using indgen.
I'm going to consider other ways of mirroring t and the thread 0 _t
or may consider it as a specific problem of Vector.record(&t) and specially
record the thread 0 time.

hines
Site Admin
Posts: 1577
Joined: Wed May 18, 2005 3:32 pm

Re: Record Simulation in Parallel Models

Post by hines » Mon Sep 13, 2010 12:23 pm

I've done some further looking into the problem and realize that the reason for
TVec.record(&t, DT) not working in the thread version is that recording the time
needs a special implementation and that was done only for TVec.record(&t)
and not for the DT and tvec second arg variants. So TVec.record(&t) works
for all methods, threads, parallel mpi because of its special implementation
as a TVecRecord class in nrn/src/nrncvode/vrecitem.h but there is
no corresponding TVecRecordDiscrete or TVecRecordDt variants as there is for
YVecRecord
VecRecordDiscrete
VecRecordDt

From one point of view, it does not seem worthwhile to add the implmentations since
recording time at specific times seems pointless. One either already has the time in a vector
or else it is tvec.indgen(0, tstop, DT). However in this case I should at least add a specific
error message. I guess the

Post Reply