1

I want to make my Matlab project faster using Parallel Computing Toolbox. In my PC there are 2 processors with 12 cores (each processor). So, I have 24 cores. The problem is that Matlab always finds only 12 cores. As I understand it uses only cores in one processor, where Matlab's project is running. But I want to use all my 24 cores. Is it possible? If yes, how can I do it? I guess, I should build cluster, but for cluster I have to buy MATLAB Distributed Computing Server. I don’t want to do it because I don’t want to use a lot of computers...just only my PC with 24 cores... Thank you for your time and consideration

Marharyta
  • 21
  • 1
  • 1
    post the code of how you have set up your parallel session – Dan Sep 18 '15 at 07:23
  • 2
    Are you sure it is 12 *cores* in each processor, and not 6 cores with 12 threads? – hbaderts Sep 18 '15 at 07:25
  • 1
    I suspect you have two hexa-core processors with multi/hyper threading. That makes it *virtually* 24 cores, but MATLAB sees only physical cores. – Adriaan Sep 18 '15 at 07:36
  • I’m sure, I have very powerful computer. But the main point of my question is “How can I use all threads of computer with Matlab?”. Matlab write me: Starting parallel pool (parpool) using the 'local' profile ... connected to 12 workers – Marharyta Sep 18 '15 at 08:06

3 Answers3

1

There's several ways to determine the amount of workers in your parallel pool. E.g. using parpool:

parpool(poolsize)

opens a parallel pool with poolsize workers, provided that number of workers is possible on your machine.

The other possibility is to go to the home->preference->parallel preferences tab and within there create a profile containing the number of workers you want. You can then call a pool using:

parpool(profilename,poolsize)

where profilename is the name you gave to that pool profile. The poolsize argument is optional here, if you do not specify it, it will use the default number of workers as specified under the parallel preferences.

Note that matlabpool was removed in R2014a, so you cannot use that anymore to open your pool. Another possibility is gcp, but this is mainly to Get Current Pool and the parameters of that pool.

As a remark: always make sure your code is the fastest possible in serial before trying to go parallel. Parallel computing is not like a magic want which you wave around to improve speeds, it's a specialised tool which works optimal on efficient programs, see here.

Community
  • 1
  • 1
Adriaan
  • 17,741
  • 7
  • 42
  • 75
  • Thank you for your reply I have already changed the number of threads. Parallel Computing Toolbox Preferences don't help me. Matlab don't want to use more threads – Marharyta Sep 18 '15 at 08:41
  • What version of MATLAB are you using? As @AnonMe pointed out, with the removal of `matlabpool` the maximum of 12 workers was removed. Thus, if you use version R2013b or older, you won't be able to use more workers. – Adriaan Sep 18 '15 at 11:28
  • I use Matlab R2013b. Thank you – Marharyta Sep 18 '15 at 11:46
1

MATLAB (and Parallel Computing Toolbox) by default consider only "real" cores, and not hyper-threaded cores. This is because experience has shown that this actually improves performance in most cases. However, you can override MATLAB's default choice by executing:

maxNumCompThreads(24)

Or, for Parallel Computing Toolbox, you can use the Cluster Profile Manager to edit your 'local' profile, and set the number of workers to 24.

EDIT: Just noticed that the OP is using R2013b. In which case, you cannot use more than 12 local workers. Upgrading to R2014a or later will fix that.

Edric
  • 23,676
  • 2
  • 38
  • 40
  • Thank you very much. Your answer is really useful. Now I understand that I can’t use more workers with my Matlab version. So, Now I can start the CUDA-part. =) – Marharyta Sep 18 '15 at 12:34
0

Depending on your Matlab version, it may be licencing issue. For older versions you need the MATLAB Distributed Computing Server (MDCS). The limit to 12 workers was removed with R2014a.

AnonMe
  • 11