Couple of JSL QuestionsHey all!
I was wondering if anyone knows the answers to the following:
- is there a JSL function to determine the number of threads a host machine can run simultaneously.
- is the simulate capability in JMP Pro multithreaded?
Any thoughts welcome.
Thanks!
MRe: Couple of JSL Questions1) No. but you can infer an answer with JSL like this:
x=j(1000,1,.);
i=0;
parallelassign({q=i++},x[r,c]=q);
show(i);
But that is just *an* answer, not *the* answer. Even a single CPU machine can have 100s of threads. And current CPUs usually have some hyper-threading capability that allows faster thread switching. But the i value above is probably what you want. Explanation: inside the {q=i++} , q is a local variable in each thread instance, and the i++ is an initialization value computed outside of the threads. You should not write code that depends on this behavior, or the apparent order the matrix elements are initialized in.
2) Look at task manager (WIN 7 did a better job showing individual CPUs than 10 does). I'd guess yes.
(MFI is I/O-bound and uses threads to read files and will benefit from the threads on a single CPU machine; the I/O for reading a file in one thread won't stop another thread from using the CPU to parse data already read for another file. But simulate is probably CPU-bound and probably has no I/O; if it is threaded it should benefit from multiple CPUs. ParallelAssign, above, is memory-bound; the bandwidth to the memory will determine the maximum speed the data can be written to the matrix...more CPUs will only help if the computation is slow on the right hand side of x[r,c]= ... )
Re: Couple of JSL QuestionsInteresting questions, @MikeD_Anderson. Can you share what makes you ask?
Re: Couple of JSL QuestionsThanks, @Craige_Hales!. I think that'll work. I was hoping there was a JSL function to ask the host OS how many cores are on the processor. I just tried your snippet and it gave me the same answer (my i9 processor has 6 cores with 2 threads per core = 12 threads).
@Jeff_Perkinson - I'm trying to ballpark a total run time for doing a simulation, i.e. If my model takes 2 seconds to run, then doing 2500 simulations (default), spread over 6 cores at 2 threads per core (assuming simulate is multithreaded), the simulation should take 417 seconds (6 minutes). I want to put in a warning message in an add-in I'm working on to give the user a ballpark of how long the simulation should take. It's not perfect math, but it will at least let me say, "Hey - this simulation is going to take 1 hour to run - are you sure you want to run it?" I can get the processing time for one iteration of the model - no sweat - but figuring out the number of threads was something I was getting stumped on.
best,
M
Re: Couple of JSL QuestionsDoubling the number of CPUs never doubles the speed for any real application that is CPU- and Memory-bound...the usual case. The memory bandwidth always becomes a problem. You could assume 2 or 4 CPUs and still have a pretty good guess, given everything else that can't be controlled. Nobody will complain if it finishes early.