I had a question regarding batch processing and parallel pool. Is it a requirement to have a parfor or spmd command in the code to call the parallel pool if using batch processing with 60 cores to reduce the execution time of the code? Can batch processing speed up the computation without calling the parfor or spmd commands i.e just by increasing the number of cores utilized

 채택된 답변

Walter Roberson
Walter Roberson 2017년 1월 9일

0 개 추천

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.

댓글 수: 3

Shalin Parikh
Shalin Parikh 2017년 1월 10일
Hello walter, Thanks for your reply. Pardon me if this may seem a trivial question. I saw the syntax for batch command and this line "An integer specifying the number of workers to make into a parallel pool for the job in addition to the worker running the batch job itself. The script or function uses this pool for execution of statements such as parfor and spmd that are inside the batch code". mentions the command parfor and spmd to be inside the code.
My question is, if i don't have parfor or spmd in the code, then will the batch processing work ?
That text is part of the description of the optional 'Pool' name/value pair. You do not need to pass anything there. If your code does not have parfor or spmd then it will not benefit from requesting a pool. You can use batch() for functions that do not use parfor or spmd -- the very first example is given as:
Run a batch script on a worker, without using a parallel pool:
j = batch('script1');
Edric Ellis
Edric Ellis 2017년 1월 10일
Yes, you can use batch without your function/script using parfor or spmd - but in that case, you do not need to specify the 'Pool' argument.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Parallel Computing Fundamentals에 대해 자세히 알아보기

질문:

2017년 1월 9일

댓글:

2017년 1월 10일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by