Пример #1
0
def prun(tstop):

    runtime = h.startsw()
    wait = pc.wait_time()

    # run simulation
    pc.psolve(tstop)

    # calculate various time statistics for profiling/debugging

    wait = pc.wait_time() - wait
    runtime = h.startsw() - runtime

    computation_time = pc.step_time()

    cw_time = computation_time + pc.step_wait()
    max_cw_time = pc.allreduce(cw_time, 2)

    avg_comp_time = pc.allreduce(computation_time, 1) / settings.nhost

    load_balance = avg_comp_time / max_cw_time

    # spike communication time
    spk_time = (pc.allreduce(wait, 2), pc.allreduce(wait, 3))

    # gap junction transfer time
    gap_time = (pc.allreduce(pc.vtransfer_time(), 2), pc.allreduce(pc.vtransfer_time(), 3))

    return runtime, load_balance, avg_comp_time, spk_time, gap_time
Пример #2
0
 def setup_mechanisms(self):
     start = h.startsw()
     for i,sec in enumerate(self.sections):
         #print "set %s to %d" % (mc.mapping.domain_name(i), i)
         self.insert_domain(sec, self.mc.domain(i))
     
     self.setup_time += h.startsw() - start
Пример #3
0
def prun(tstop):

    runtime = h.startsw()
    wait = pc.wait_time()

    # run simulation
    pc.psolve(tstop)

    # calculate various time statistics for profiling/debugging

    wait = pc.wait_time() - wait
    runtime = h.startsw() - runtime

    computation_time = pc.step_time()

    cw_time = computation_time + pc.step_wait()
    max_cw_time = pc.allreduce(cw_time, 2)

    avg_comp_time = pc.allreduce(computation_time, 1) / settings.nhost

    load_balance = avg_comp_time / max_cw_time

    # spike communication time
    spk_time = (pc.allreduce(wait, 2), pc.allreduce(wait, 3))

    # gap junction transfer time
    gap_time = (pc.allreduce(pc.vtransfer_time(),
                             2), pc.allreduce(pc.vtransfer_time(), 3))

    return runtime, load_balance, avg_comp_time, spk_time, gap_time
Пример #4
0
    def setup_sections(self):
        start = h.startsw()
        
        ###################################################
        # set up sections
        self.sections = []
        # old style, but it is need for section_name in hoc
        h(self.section_def_template % (self.name, len(self.tree)))
        for sec in h.allsec():
            self.sections.append(sec)


        ###################################################
        # connect sections
        for i,sec in enumerate(self.sections):
            parent = self.tree[i]
            #print "%d to %d" % (i, tree[i])
            if(parent != 0):
                sec.connect(self.sections[parent-1], 1, 0)

        self.num_compartment = 0
        for sec in h.allsec():
            self.num_compartment += 1

        self.setup_time += h.startsw() - start
Пример #5
0
def timeit(message):
  global _timeit
  if message == None:
    _timeit = h.startsw()
  else:
    x = h.startsw()
    if rank == 0: print '%gs %s'%((x - _timeit), message)
    _timeit = x
def output():
    wtime = h.startsw()
    for vmrec, filename in vmrecordings:
        f = open(filename, 'w')
        for j in range(int(vmrec.size())):
            f.write('%g %g\n' % (tvec.x[j], vmrec.x[j]))
        f.close()
    util.elapsed('vm recorded  write time %.g' % (h.startsw() - wtime))
Пример #7
0
def timeit(message, rank):
    global _timeit
    if message == None:
        _timeit = h.startsw()
    else:
        x = h.startsw()
        if rank == 0:
            print ('%gs %s' % ((x - _timeit), message))
        _timeit = x
Пример #8
0
    def multisplit(self):
        start = h.startsw()
        self.complexity = h.multisplit()
        self.pc.multisplit()
        self.pc.set_maxstep(10)

        self.num_compartment = 0
        for sec in h.allsec():
            self.num_compartment += 1

        self.setup_time += h.startsw() - start
Пример #9
0
    def prun(self,tstop):
        #from neuron import h    
        pc=h.ParallelContext()
        NCELL=self.NCELL
        SIZE=self.SIZE
        COMM = self.COMM
        RANK=self.RANK
        checkpoint_interval = 50000.

        #The following definition body is from the open source code at:
        #http://senselab.med.yale.edu/ModelDB/ShowModel.asp?model=151681
        #with some minor modifications
        cvode = h.CVode()
        cvode.cache_efficient(1)
        # pc.spike_compress(0,0,1)
    
        pc.setup_transfer()
        mindelay = pc.set_maxstep(10)
        if RANK == 0:
            print 'mindelay = %g' % mindelay
        runtime = h.startsw()
        exchtime = pc.wait_time()
    
        inittime = h.startsw()
        h.stdinit()
        inittime = h.startsw() - inittime
        if RANK == 0:
            print 'init time = %g' % inittime
    
        while h.t < tstop:
            told = h.t
            tnext = h.t + checkpoint_interval
            if tnext > tstop:
                tnext = tstop
            pc.psolve(tnext)
            if h.t == told:
                if RANK == 0:
                    print 'psolve did not advance time from t=%.20g to tnext=%.20g\n' \
                        % (h.t, tnext)
                break    
            print 'working', h.t
        runtime = h.startsw() - runtime
        comptime = pc.step_time()
        splittime = pc.vtransfer_time(1)
        gaptime = pc.vtransfer_time()
        exchtime = pc.wait_time() - exchtime
        if RANK == 0:
            print 'runtime = %g' % runtime
        print comptime, exchtime, splittime, gaptime
Пример #10
0
def main():
    h.load_file("multisplit.hoc")
    h('{nrn_load_dll("../specials/x86_64/.libs/libnrnmech.so")}')

    tstop = 1000
    pc = h.ParallelContext()
    start = h.startsw()

    ######################################################
    # load model
    cell = load_model("./1056.swc")

    ######################################################
    # generate mcomplex.dat
    lb = h.MyLoadBalance()
    lb.ExperimentalMechComplex()
    #save_mcomplex(lb)
    pc.barrier()

    ######################################################
    # set up multi split
    cplx = h.multisplit(lb)
    pc.multisplit()
    pc.set_maxstep(10)

    ######################################################
    # set stim and record of v
    stim = set_iclamp("CellSwc[0].Dend[2000]", pc)
    vec_t = h.Vector()
    vec_t.record(h._ref_t)
    vec_v = set_vec_v("CellSwc[0].Dend[100]", pc)
    setup_time = h.startsw() - start

    ######################################################
    # run simulation
    start = h.startsw()
    h.stdinit()
    pc.psolve(tstop)
    pc.barrier()
    calc_time = h.startsw() - start

    ######################################################
    # disp info
    show_result(pc, setup_time, calc_time, cplx)
    #show_section()
    #if(vec_v != 0):
    #    show_plot(vec_t, vec_v)
    pc.done()
Пример #11
0
    def run(self):
        """Run the simulation:
        if beginning from a blank state, then will use h.run(),
        if continuing from the saved state, then will use h.continuerun() 
        """
        for mod in self._sim_mods:
            mod.initialize(self)

        self.start_time = h.startsw()
        s_time = time.time()
        pc.timeout(0)

        pc.barrier()  # wait for all hosts to get to this point
        io.log_info(
            'Running simulation for {:.3f} ms with the time step {:.3f} ms'.
            format(self.tstop, self.dt))
        io.log_info('Starting timestep: {} at t_sim: {:.3f} ms'.format(
            self.tstep, h.t))
        io.log_info('Block save every {} steps'.format(self.nsteps_block))

        if self._start_from_state:
            h.continuerun(h.tstop)
        else:
            h.run(h.tstop)  # <- runs simuation: works in parallel

        pc.barrier()

        for mod in self._sim_mods:
            mod.finalize(self)
        pc.barrier()

        end_time = time.time()

        sim_time = self.__elapsed_time(end_time - s_time)
        io.log_info('Simulation completed in {} '.format(sim_time))
Пример #12
0
    def run(self):
        '''
        Run the simulation: 
        if beginning from a blank state, then will use h.run(),
        if continuing from the saved state, then will use h.continuerun() 
        
        '''
        self.start_time = h.startsw()
        s_time = time.time()
        pc.timeout(0)  #

        pc.barrier()  # wait for all hosts to get to this point
        io.print2log0(
            'Running simulation until tstop: %.3f ms with the time step %.3f ms'
            % (self.conf["run"]['tstop'], self.conf["run"]['dt']))

        io.print2log0('Starting timestep: %d at t_sim: %.3f ms' %
                      (self.tstep, h.t))
        io.print2log0('Block save every %d steps' %
                      (self.conf["run"]['nsteps_block']))

        if self._start_from_state:
            h.continuerun(h.tstop)
        else:
            h.run(h.tstop)  # <- runs simuation: works in parallel

        pc.barrier()  #

        end_time = time.time()

        sim_time = self.__elapsed_time(end_time - s_time)
        io.print2log0now('Simulation completed in {} '.format(sim_time))
Пример #13
0
 def insert_domain(self, sec, domain):
     start = h.startsw()
     modlist = []
     for subcomp in domain.dynamics.subcomponents:
         modlist.append(subcomp.name)
         sec.insert(subcomp.name)
         for prop in subcomp.dynamics.properties:
             ############################################
             # this is not good and old style
             #
             sec.push()
             h(prop.name+'_'+subcomp.name+' = '+str(prop.value))
             h.pop_section()
             # 
             #sec.setter(prop.name+'_'+subcomp.name, prop.value)
             ############################################
     self.setup_time += h.startsw() - start
Пример #14
0
def onerun(seed=1, nchannels=50, n_trajectory=1):
    r = tcr  # global from parrun
    cvodewrap.fs.use_fixed_step = 1.0
    tt = h.startsw()
    pc = h.ParallelContext()
    id = int(pc.id())
    print "%d start seed=%d nchannels=%d" % (id, seed, nchannels)
    run = 3
    r.compute(nchannels, seed, n_trajectory, run)
    tt = h.startsw() - tt
    print "%d finish walltime=%g seed=%d nchannels=%d n_trajectory=%d" % (
        id, tt, seed, nchannels, n_trajectory)
    #return value suitable for bulletin board
    result = [[tt, seed, nchannels, n_trajectory, run]]
    print 'run ', run
    if run >= 1: result += [[numpy.array(r.postTrueParm), r.postTruef]]
    if run >= 2: result += [[numpy.array(r.postSNFParm), r.postSNFf]]
    if run >= 3: result += [[numpy.array(r.postMPFParm), r.postMPFf]]
    if run >= 4: result += [[numpy.array(r.postAPFParm), r.postAPFf]]
    return result
Пример #15
0
from neuron import h

startsw = h.startsw()
h.load_file("stdgui.hoc")

h("proc setdt(){}")
h.dt = 2 * (1. / 64. + 1. / 128)

pc = h.ParallelContext()
rank = int(pc.id())
nhost = int(pc.nhost())

import params
nmitral = params.Nmitral
nmtufted = params.Nmtufted
ngranule = params.Ngranule
nblanes = params.NBlanes
ncell = nmitral + nmtufted + ngranule + nblanes

from modeldata import getmodel
Пример #16
0
from neuron import h
import math

pc = h.ParallelContext()


def f(arg):
    for i in range(1000000):
        x = math.sin(i * 0.0001 / math.pi)
    return x


pc.runworker()

tt = h.startsw()

for i in range(100):
    pc.submit(f, i)

x = 0
while pc.working():
    x = pc.retval()

print(h.startsw() - tt)

pc.done()
h.quit()
Пример #17
0
def prun():
  xx = h.startsw()
  h.run()
  print h.startsw() - xx
Пример #18
0
    return m


def fillall(n, m):
    fillshape(n.soma[0], m.soma)
    fillshape(n.apic[0], m.priden)
    for i, s in enumerate(n.dend):
        fillshape(s, m.secden[i])
    for i, s in enumerate(n.tuft):
        fillshape(s, m.tuftden[i])


def fillshape(s1, s2):
    s2.push()
    h.pt3dclear()
    for x in s1.points:
        h.pt3dadd(x[0], x[1], x[2], x[3])
    h.pop_section()


if __name__ == "__main__":
    cells = []
    x = h.startsw()
    # note 259 has tertiary branches
    for i in range(10):
        print "mid=", i
        cells.append(mkmitral(i))
    print "wall time ", h.startsw() - x, " seconds"
    h.load_file('select.hoc')
Пример #19
0
from neuron import h
startsw = h.startsw()
h.load_file("stdgui.hoc")
import params
pc = h.ParallelContext()
rank = int(pc.id())
from modeldata import getmodel

nhost = int(pc.nhost())
nmitral = params.Nmitral

import granules

ncell = nmitral + granules.ngranule


Пример #20
0
def get_cell(env, gid, population):
    """

    :param env:
    :param gid:
    :param population:
    :return:
    """
    h.load_file("nrngui.hoc")
    h.load_file("loadbal.hoc")
    h('objref fi_status, fi_checksimtime, pc, nclist, nc, nil')
    h('strdef datasetPath')
    h('numCells = 0')
    h('totalNumCells = 0')
    h('max_walltime_hrs = 0')
    h('mkcellstime = 0')
    h('mkstimtime = 0')
    h('connectcellstime = 0')
    h('connectgjstime = 0')
    h('results_write_time = 0')
    h.nclist = h.List()
    datasetPath = os.path.join(env.datasetPrefix, env.datasetName)
    h.datasetPath = datasetPath
    ##  new ParallelContext object
    # h.pc = h.ParallelContext()
    # env.pc = h.pc
    rank = int(env.pc.id())
    nhosts = int(env.pc.nhost())
    ## polymorphic value template
    h.load_file("./templates/Value.hoc")
    ## randomstream template
    h.load_file("./templates/ranstream.hoc")
    ## stimulus cell template
    h.load_file("./templates/StimCell.hoc")
    h.xopen("./lib.hoc")
    h.dt = env.dt
    h.tstop = env.tstop
    if env.optldbal or env.optlptbal:
        lb = h.LoadBalance()
        if not os.path.isfile("mcomplex.dat"):
            lb.ExperimentalMechComplex()

    if (env.pc.id() == 0):
        mkspikeout(env, env.spikeoutPath)
    env.pc.barrier()
    h.startsw()
    mkcells(env)
    env.mkcellstime = h.stopsw()
    env.pc.barrier()
    if (env.pc.id() == 0):
        print "*** Cells created in %g seconds" % env.mkcellstime
    print "*** Rank %i created %i cells" % (env.pc.id(), len(env.cells))
    h.startsw()
    mkstim(env)
    env.mkstimtime = h.stopsw()
    if (env.pc.id() == 0):
        print "*** Stimuli created in %g seconds" % env.mkstimtime
    env.pc.barrier()
    h.startsw()
    connectcells(env)
    env.connectcellstime = h.stopsw()
    env.pc.barrier()
    if (env.pc.id() == 0):
        print "*** Connections created in %g seconds" % env.connectcellstime
    print "*** Rank %i created %i connections" % (env.pc.id(), int(h.nclist.count()))
    h.startsw()
    # connectgjs(env)
    env.connectgjstime = h.stopsw()
    if (env.pc.id() == 0):
        print "*** Gap junctions created in %g seconds" % env.connectgjstime
    env.pc.setup_transfer()
    env.pc.set_maxstep(10.0)
    h.max_walltime_hrs = env.max_walltime_hrs
    h.mkcellstime = env.mkcellstime
    h.mkstimtime = env.mkstimtime
    h.connectcellstime = env.connectcellstime
    h.connectgjstime = env.connectgjstime
    h.results_write_time = env.results_write_time
    h.fi_checksimtime = h.FInitializeHandler("checksimtime(pc)")
    if (env.pc.id() == 0):
        print "dt = %g" % h.dt
        print "tstop = %g" % h.tstop
        h.fi_status = h.FInitializeHandler("simstatus()")
    h.v_init = env.v_init
    h.stdinit()
    h.finitialize(env.v_init)
    env.pc.barrier()
    if env.optldbal or env.optlptbal:
        cx(env)
        ld_bal(env)
        if env.optlptbal:
            lpt_bal(env)
Пример #21
0
 def run_simulation(self):
     start = h.startsw()
     h.stdinit()
     self.pc.psolve(self.tstop)
     self.pc.barrier()
     self.calc_time = h.startsw() - start