The arguments are passed from program1 is to be considered as input for program2. program2 have to work with these inputs and it iteratively give the results. Now each and every iteration that results have to be used as input to program1.Both have to made simultaneously.Is it possible to make this?kindly give answers.
MATLAB: How to run two Matlab programs simultaneously
running two programs
Related Solutions
Until R2016b, all workers received a single thread. The relevant R2016b release note is:
"Multithreaded Workers: Use multiple computational threads on your MATLAB workers
MATLAB workers used to run in single-threaded mode. Now you can control the number of computational threads so that workers can run in multithreaded mode and use all the cores on your cluster. This enables you to increase the number of computational threads, NumThreads, on each worker, without increasing the number of workers, NumWorkers. If you have more cores available, increase NumThreads to take full advantage of the built-in parallelism provided by the multithreaded nature of many of the underlying MATLAB libraries. For more information, see Create and Modify Cluster Profiles."
The documentation for batch shows examples of creating a batch without opening a parpool, and an example of requesting a pool. No explicit "parpool" statement is used.
If you are running on a cluster, you might need to parcluster() and batch() against that cluster.
Your local machine is making use of maxNumCompThreads, which is set to the number of physical cores on your machine. The 'parallelism' is threads, not processes, that are spawned by eigs onto those cores.
When you call batch, you can pass it a pool argument, specifying how many workers (processes) should start up. batch will request one additional worker to act as your proxy MATLAB client. For example,
j = batch(...,'Pool',3);
will reqest 4 workers run on your cluster. As you've noticed, you don't need additional workers for your code. You just need the single worker that batch will request, which in turn needs to spawn threads (across several cores).
Your question then is, why does eigs run with multiple threads locally, but only a single thread on the cluster? By default, MATLAB will only request a single thread per worker. To increase this, set the number of threads per worker, as such (8 is only an example)
c = parcluster(name-of-cluster-profile);c.NumThreads = 8;j = c.batch('myfile');
If, for some reason, that doesn't work, you can call maxNumCompThreads in myfile. The caveat is that setting NumThreads should request additional cores (needed for the additional threads). If setting NumThreads didn't work, you'll only get a single core. Then, calling maxNumCompThreads may have one of the following consequences
- Starting threads on cores you don't own
- Starting all on the same core, if cgroups are implemented
Neither is desireable.
Best Answer