Page 1 of 1

starting gui multisplit from code

Posted: Sun Jun 08, 2014 10:48 am
by oren
Hi
I have what seems to be a weird question. Usually when I want to do multisplit on a model that I am running. I do:
Tools-> Parallel Computing -> threads=8 & Multiplit on
Refresh

and it works. But I can't seems to find the correct commands so that this clicks will be automatically run from the code,
When I do the following code:

pc.nthread(8)
pc.multisplit()

I do not see any improvement in the speed of the simulation. Only when I click on the gui on Multisplit checkbox I then see any effect on the simulation time..
I understand that there need to be some kind of load balance command, but I can't seem to find it.

How can I activate the gui Multisplit() command via code?

Thank You

Re: starting gui multisplit from code

Posted: Sun Jun 08, 2014 3:18 pm
by ted
The simplest way to proceed is to first save a configured ParallelComputeTool to a session file. Then you can load that session file and you'll get multithreaded execution, but the only line of code you have to write is a load_file() or xopen() statement that reads the ses file.

"Oh, but I might want to change the number of threads."

Easy. After you load the ses file, there will be an instance of the ParallelComputeTool class called ParallelComputeTool[0]. Just do this:

Code: Select all

// assumes the number of threads you want is called nthr
objref pct
pct = ParallelComputeTool[0]
object_push(pct)
change_nthread(nthr, 1)
object_pop(pct)
You can also turn multsplit on and off--just substitute
multisplit(1) // 0 to turn off
for the change_nthread() statement.

Be sure to read the Programmer's Reference about object_push() and object_pop(). Also examine the ParallelComputeTool's .ses file, and look in the hoc library at the contents of parcom.hoc and maybe you'll get some new ideas.

Re: starting gui multisplit from code

Posted: Tue Jun 10, 2014 7:56 am
by oren
Thank You,
Working Great!

Re: starting gui multisplit from code

Posted: Tue Jun 10, 2014 10:38 am
by ted
Write as little code as necessary. Saves time and effort, avoids mistakes.