Parallel version of a model

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

Moderator: hines

Post Reply
Nikolas Andre
Posts: 3
Joined: Sat Feb 23, 2019 9:08 am

Parallel version of a model

Post by Nikolas Andre »

Hope you are well.

When I tried to run the parallel version of the Cutsuridis 2010 model ( https://senselab.med.yale.edu/modeldb/S ... 815#tabs-2 ), the program loads the GUI, but when I try to start the simulation, the screen freezes, and I couldn't do anything else. No errors. Just a freezing screen.

When I commented out the "prun" procedure (line 741), the program's executed as if it was the serial version (which runs smoothly). Still, I have zero clues about what the problem may be.

Any help would be much appreciated.

NEURON version: 7.8.1
MSWin
Parallel code of the model adapted from Hines' "ran3par.hoc".
ted
Site Admin
Posts: 6286
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: Parallel version of a model

Post by ted »

When I tried to run the parallel version
And how did you do that?
Nikolas Andre
Posts: 3
Joined: Sat Feb 23, 2019 9:08 am

Re: Parallel version of a model

Post by Nikolas Andre »

Thank you for the quick response. I am sorry I forgot to mention it.

In the folder, there are two files:
"HAM_StoRec_ser.hoc" which is for the serial version, and the
"HAM_StoRec_par.hoc" which is for the parallel version (here is the "prun" procedure).

We can either double click the file or call it through the "mosinit.hoc": load_file("HAM_StoRec_ser.hoc") or load_file("HAM_StoRec_par.hoc").
ted
Site Admin
Posts: 6286
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: Parallel version of a model

Post by ted »

You'll want to use the command line when dealing with parallelized code. Double clicking on a hoc file will result in serial execution. The syntax for parallel execution is

mpiexec -n N nrniv -mpi foo.hoc

where N is the number of cores to use in the simulation and foo.hoc is the name of the parallelized hoc file.

Why is the command line so long? The first part tells mpiexec how many processors to use. The -mpi in the second part of the line is there because NEURON needs to be "told" that it is being executed under MPI.


Using NEURON 8.0.dev-194-g8570e8e+ master (8570e8e+) 2020-10-14, I had no problem launching a parallel simulation with
mpiexec -n 2 nrniv -mpi HAM_StoRec_par.hoc

Nor was there any problem with serial execution of the parallelized hoc code
nrngui HAM_StoRec_par.hoc
(or
mpiexec -n 1 nrniv -mpi HAM_StoRec_par.hoc
).

Of course, the simulation runs for a long time (with only 1 or two processors), so there is no external evidence that anything useful is happening. But you can always shorten the "duration of the simulation" by slight edits to the source code; I did that by changing STARTDEL to 5, THETA to 25, GAMMA to 15, and SIMDUR to STARTDEL + THETA, just to get results quickly. This reduced run time to a few seconds.

For reasons that are unclear to me, the run() call in the serial version of the program HAM_StoRec_ser.hoc was commented out so executing that file merely set up the model but didn't actually launch a simulation. Not a big deal; this is easily undone with a text editor.
ted
Site Admin
Posts: 6286
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: Parallel version of a model

Post by ted »

This model entry's README file should really provide instructions for parallel execution.
Nikolas Andre
Posts: 3
Joined: Sat Feb 23, 2019 9:08 am

Re: Parallel version of a model

Post by Nikolas Andre »

Thank you very much for your quick responses and your help. It works just fine now. I noticed a small decrease in the execution time, but not something important (from 800 ms to 655 ms).

Also, I have a few more questions about the parallel procedure.

1st) When I run the serial code, I double click the .hoc file, then the GUI appears and I control the duration of simulations and see the real-time for each simulation. Is there any way I can do that with the parallel execution? Because when I use the "mpiexec -n N nrniv -mpi foo. hoc" command, the model launches the simulation without the GUI, and I cannot actually see how much real-time it took to complete the whole simulation.

2nd) The first time I tried to run a parallel simulation was a multithreaded one. I followed the instructions from these sources
( https://neuron.yale.edu/neuron/docs/mul ... lelization ) and
( viewtopic.php?t=3395 ).

Some NMDOL files weren't "thread-safe", so first I used the "mkthreadsafe" command, but it didn't work, and then I added THREADSAFE to its NEURON block. That created additional problems, such as "Segmentation violation" at some point. I do not know if this is an MSWin problem or I am missing something. The only thing I used without any problem was the "cache efficient" which indeed reduced the execution time. What am I doing wrong?

Thank you in advance for your time.
ted
Site Admin
Posts: 6286
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: Parallel version of a model

Post by ted »

When I run the serial code, I double click the .hoc file, then the GUI appears and I control the duration of simulations and see the real-time for each simulation. Is there any way I can do that with the parallel execution?
Read about "time" in the Programmer's Reference.
2nd) The first time I tried to run a parallel simulation was a multithreaded one. I followed the instructions from these sources . . .
What am I doing wrong?
Can't tell without seeing everything you did to make your mod files threadsafe. However, the unfortunate truth is that multithreaded execution generally produces only a modest reduction of runtime--if N is the number of threads, runtime is typically reduced to 1/M where M is smaller than N, and the larger you make N, the less effect you have on M. Another way of saying this is that speedup is not just sublinear but often markedly sublinear. Unless you have a burning need to run thread parallel simulations, stick with MPI parallel especially since this particular model code was written for MPI parallell execution. And when trying to eke out higher code performance, always remember: computer time is cheap, programmer time is precious.
Post Reply