jackfolla wrote:now I would like to collect the execution times, calculating, for each family of simulations, the average of this times, by varying:
In the case of the serial code: number of cells and number of threads.
In the case of the parallel code: number of cells and number of processors.
If possible, I would like to automate this.
This is doable by a combination of hoc and shell programming. Very briefly, the number of cells and the number of processors must be specified by statements on the command line in a shell script. The number of threads can be specified by a "for loop" in your hoc program. See below for more detail.
You told me that the procedures mkcells(), connectcells() etc. only have to be called once.
True as long as the number of cells does not change. If the number of cells changes, it is best to exit NEURON and start anew.
The steps required to do what you want are:
1. Revise the serial and parallel implementations so that they report the run time. Do this with startsw() (documented in the Programmer's Reference). For example
Code: Select all
runtime=startsw()
run()
runtime=startsw()-runtime
print runtime
2. Revise the serial and parallel implementations so that the number of cells in the network can be specified by a command line statement. In case you aren't already aware of this feature of NEURON,
nrniv -c "statement" foo.hoc
executes "statement" before executing foo.hoc
So if foo.hoc is a program in which a parameter NCELLS controls the number of cells that will be created, then
nrniv -c "NCELLS=9" foo.hoc
will set NCELLS to 9 before executing foo.hoc
Now focus on the serial implementation.
3. Use the ParallelContext class to specify the number of threads used by the serial implementation. After the end of model setup, but before calling run(), insert
objref pc
pc = new ParallelContext()
pc.nthread(nthreads)
where the value of nthreads is specified by a simple assignment statement.
After you have this working, revise your run control code so that it uses a "for loop" to execute a series of runs, each run having a different number of threads, e.g.
Code: Select all
objref pc
pc = new ParallelContext()
for nthreads=1,MAXNTHREADS {
pc.nthread(nthreads)
. . . whatever else you have to do before calling run . . .
runtime=startsw()
run()
runtime=startsw()-runtime
. . . whatever else you have to do after this point . . .
}
4. Create a shell script that executes the serial implementation multiple times--each time specifying a different number of cells for the network. Details of the shell script will depend on your software environment and what you want to do. For a very simple example, see
Automating tasks: -c "statement" and batch runs
http://www.neuron.yale.edu/phpBB/viewto ... =28&t=1747
Finally, turning to the parallel implementation--
5. NEURON has no way to change the number of processors used by a distributed model. This must be specified on the command line. For this you need a shell script that will execute a series of commands similar to these:
mpiexec -np 2 nrniv -mpi -c "NUMCELLS=3" ringpar.hoc
mpiexec -np 2 nrniv -mpi -c "NUMCELLS=4" ringpar.hoc
mpiexec -np 2 nrniv -mpi -c "NUMCELLS=5" ringpar.hoc
. . .
mpiexec -np 4 nrniv -mpi -c "NUMCELLS=3" ringpar.hoc
mpiexec -np 4 nrniv -mpi -c "NUMCELLS=4" ringpar.hoc
mpiexec -np 4 nrniv -mpi -c "NUMCELLS=5" ringpar.hoc
This is easily done with a pair of nested "for" loops, but details depend on your operating system and shell.
As always, test at each step to make sure that your revisions work properly.