# MKL Distributed slower！

**URL:** <https://discourse.julialang.org/t/mkl-distributed-slower/97561>\
**Category:** Performance\
**Tags:** package, mkl, distributed\
**Created:** [April 17, 2023, 4:55am UTC](https://discourse.julialang.org/t/mkl-distributed-slower/97561 "2023-04-17T04:55:05Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![13299118606](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/13299118606/32/49095_2.png) [@13299118606](https://discourse.julialang.org/u/13299118606)\
**Post date:** [April 17, 2023, 4:55am UTC](https://discourse.julialang.org/t/mkl-distributed-slower/97561/1 "2023-04-17T04:55:05Z")

</div>

I am using MKL to accelerate svd,  
using MKL  
svd will be 5-10 times faster  
But it is far from enough in parallel:  
Add the original svd 1.3s  
using mkl will change to 0.15s

Then parallel each time 0.6s

If I declare in each process:  
He will be slower than before without parallel.

> Blockquote  
> @everywhere using MKL  
> From worker 2: 1.596812 seconds (24.28 k allocations: 128.745 MiB, 0.67% gc time)  
> From worker 3: 1.621169 seconds (24.28 k allocations: 128.745 MiB, 0.38% gc time)  
> From worker 4: 1.599108 seconds (24.28 k allocations: 128.745 MiB, 0.35% gc time)

---

<div class="post-metadata">

**Author:** ![carstenbauer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/carstenbauer/32/4981_2.png) [@carstenbauer](https://discourse.julialang.org/u/carstenbauer)\
**Post date:** [April 17, 2023, 5:41am UTC](https://discourse.julialang.org/t/mkl-distributed-slower/97561/2 "2023-04-17T05:41:31Z")

</div>

Try setting `MKL_NUM_THREADS=1` and rerun all benchmarks. What do you get?

---

<div class="post-metadata">

**Author:** ![13299118606](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/13299118606/32/49095_2.png) [@13299118606](https://discourse.julialang.org/u/13299118606)\
**Post date:** [April 17, 2023, 10:21am UTC](https://discourse.julialang.org/t/mkl-distributed-slower/97561/3 "2023-04-17T10:21:06Z")

</div>

> [@carstenbauer](#):
>
> MKL\_NUM\_THREADS

Thank you for your answer. It is indeed caused by MKL’s automatic distribution of threads. I set too many startup processes to cause thread congestion. For this reason, I set it to MKL\_NUM\_THREADS=1. Although it will slow down the non-parallel speed, the parallel speed does speed up. quite a lot
