# How can I make expm running on many cores?

1 vue (au cours des 30 derniers jours)
Stefano le 16 Juin 2022
I need to compute the exponential of large matrices. I am using the instruction expm and I would like to make it running on a parallel manner.
How can I make this function running on many cores? For instance the example below is still running on one core.
delete (gcp('nocreate'))
parpool(4);
ntot=2^12
Atot=rand(ntot,ntot);
expm(Atot);
##### 0 commentairesAfficher -2 commentaires plus anciensMasquer -2 commentaires plus anciens

Connectez-vous pour commenter.

### Réponse acceptée

Raymond Norris le 16 Juin 2022
Starting a parallel pool doesn't run subsequent MATLAB code in parallel, it simple starts a colletion of headless MATLAB processes. You need to use a parallel construct (e.g., parfor, gpuArray, etc.) to explicitly parallelize the code.
Regarding your code, expm is already using multi-core. You can test this via the following example. For this I'm running MATLAB R2022a on a 12-core VM.
ntot=2^12;
Atot=rand(ntot,ntot);
tic, expm(Atot); toc
Elapsed time is 27.851388 seconds.
ntot=2^12;
Atot=rand(ntot,ntot);
tic, expm(Atot); toc
Elapsed time is 7.882113 seconds.
ntot=2^12;
Atot=rand(ntot,ntot);
tic, expm(Atot); toc
Elapsed time is 3.815132 seconds.
MATLAB is already implicitly parallelizing expm.
##### 0 commentairesAfficher -2 commentaires plus anciensMasquer -2 commentaires plus anciens

Connectez-vous pour commenter.

### Catégories

En savoir plus sur Parallel Computing Fundamentals dans Help Center et File Exchange

### Community Treasure Hunt

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

Start Hunting!

Translated by