Threads=x?

posts related to the RMark library, which may not be of general interest to users of 'classic' MARK

Threads=x?

Postby j.harv3y » Mon Jun 24, 2019 8:34 am

Hi,
I'm not sure if I've missed this in the handbook, but I can't seem to find an explanation to the threads= command? I've gathered its something to do with the processing in MARK, but am unsure what number I need to put after threads. Could someone explain please?

Code: Select all
e.g model.1=mark(crdms.data,ddl=crdms.ddl,
   model.parameters=list(S=S.dot,
      p=p.session,
      Psi=Psi.markov),threads=2)


Thanks a million!

Jess
j.harv3y
 
Posts: 45
Joined: Mon Oct 08, 2018 4:45 am

Re: Threads=x?

Postby cooch » Mon Jun 24, 2019 8:55 am

The threads command line defaults to 0, which means it uses all the threads available to run. Meaning, using the default will run fastest, but at the expense of tying up the CPU for other tasks. If you want to use fewer than the maximum number of threads, you debit from the default:

--threads=0 <-- use all possible threads (i.e., the debit from maximum is 0)

--threads=-1 <-- use one thread less than maximum

--threads=-2 <-- use two threads less than maximum

and so on. The maximum number of threads is determined by the architecture of the CPU -- some chips have more threads than others (note: more threads does not always make things run faster -- it only benefits routines that are coded to take advantage of multi-threaded execution. For MARK, there is definitely a gain in using more threads, but generally the gain is only noticeable for bug data sets anbd complex models).
cooch
 
Posts: 1628
Joined: Thu May 15, 2003 4:11 pm
Location: Cornell University

Re: Threads=x?

Postby jlaake » Mon Jun 24, 2019 3:21 pm

Every argument to a function in RMark is documented in the help to the function. See ?mark. That is the case with any R package on Cran. I had to use thread=2 in the examples to satisfy Cran requirements.
jlaake
 
Posts: 1417
Joined: Fri May 12, 2006 12:50 pm
Location: Escondido, CA

Re: Threads=x?

Postby cooch » Mon Jun 24, 2019 4:04 pm

Jeff -- just for completeness -- the CLI syntax for threads is

mark.exe --threads=-2 etc. etc.

In other words, the --threads argument is either 0 (use all the threads) or negative (being the number ,less than all threads). So, --threads=-2 would be 2 less than maximum number of threads.

In your example, you have threads=2, (i.e., positive 2) which actually wouldn't be interpreted correctly by mark.exe. Is the RMark threads argument a wrapper that changes things to the right thing to pass to mark.exe?
cooch
 
Posts: 1628
Joined: Thu May 15, 2003 4:11 pm
Location: Cornell University

Re: Threads=x?

Postby jlaake » Mon Jun 24, 2019 4:19 pm

Okay. What I thought Gary told me was 0 for all CPUs, positive to specify the number to use and negative to set aside a set of CPUs. Are you saying a positive value doesn't work? Because I believe I checked that.
jlaake
 
Posts: 1417
Joined: Fri May 12, 2006 12:50 pm
Location: Escondido, CA

Re: Threads=x?

Postby cooch » Mon Jun 24, 2019 4:45 pm

jlaake wrote:Okay. What I thought Gary told me was 0 for all CPUs, positive to specify the number to use and negative to set aside a set of CPUs. Are you saying a positive value doesn't work? Because I believe I checked that.



You're correct. From the MARK helpfile:

A value of 0 tells MARK to use all possible threads, a positive value says to use that many threads <= the maximum available, and a negative value says to use that many less than the maximum number of threads possible. The default value is zero, i.e., use all the threads available on a machine.


I was basing my 'insight' (or lack thereof, it seems) on an earlier incarnation of threading in MARK. So, if your CPU has 4 threads, then using --threads=2 or threads=-2 would amount to the same thing. OTOH, --threads=1 would mean...1 thread, whereas --threads=-1 would mean (4-3)=3 threads.
cooch
 
Posts: 1628
Joined: Thu May 15, 2003 4:11 pm
Location: Cornell University

Re: Threads=x?

Postby j.harv3y » Tue Jul 02, 2019 5:02 am

Amazing, thanks so much
j.harv3y
 
Posts: 45
Joined: Mon Oct 08, 2018 4:45 am


Return to RMark

Who is online

Users browsing this forum: No registered users and 11 guests

cron