# Is there any limitation on threads' num for cpu without SMT？

**URL:** <https://discourse.julialang.org/t/is-there-any-limitation-on-threads-num-for-cpu-without-smt/46104>\
**Category:** Performance\
**Created:** [September 5, 2020, 2:30pm UTC](https://discourse.julialang.org/t/is-there-any-limitation-on-threads-num-for-cpu-without-smt/46104 "2020-09-05T14:30:14Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![N5N3](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/n5n3/32/17663_2.png) [@N5N3](https://discourse.julialang.org/u/N5N3)\
**Post date:** [September 5, 2020, 2:30pm UTC](https://discourse.julialang.org/t/is-there-any-limitation-on-threads-num-for-cpu-without-smt/46104/1 "2020-09-05T14:30:14Z")

</div>

I’m using 9600KF with 6 cores and 6 threads, the following confuse me:  
If I start julia with 6 threads, then the cost of `schedule(t::Task) = enq_work(t)` increases sharply somtime, while everythings seems ok with threads under 6.

```julia
FFTW.fftw_vendor # :mkl
FFTW.set_num_threads(5)
# initialization
a = randn(ComplexF32,512,6)
b = randn(ComplexF32,512,6)
c = similar(a)
# bench function
test(a,b,c) = begin
plan = FFTW.plan_fft(a, 1)
for k = 1:1000
    mul!(b,plan,a)
    tasks = ntuple(1) do i # even i start only 2 tasks
        Threads.@spawn @views c[:,i] .= a[:,i] .* b[:,i]
    end
    @views c[:,6] .= a[:,6] .* b[:,6]
    map(wait,tasks)
end
end
# use Juno.@profiler
@profiler test(a,b,c)

```

Here’s the profile result:

 ![新建文本文档 ()](https://global.discourse-cdn.com/julialang/original/3X/e/e/ee87f6029b40333149f022d12fe3d3b67813485c.jpeg)

Is this a bug or something else? I found the default threads in Juno for 9600KF is 3, althought it says `auto` means the number of cpu cores.

---

<div class="post-metadata">

**Author:** ![ufechner7](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ufechner7/32/51363_2.png) [@ufechner7](https://discourse.julialang.org/u/ufechner7)\
**Post date:** [September 5, 2020, 2:41pm UTC](https://discourse.julialang.org/t/is-there-any-limitation-on-threads-num-for-cpu-without-smt/46104/2 "2020-09-05T14:41:49Z")

</div>

Well, leaving one CPU core for the operating system is often a good idea…

---

<div class="post-metadata">

**Author:** ![N5N3](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/n5n3/32/17663_2.png) [@N5N3](https://discourse.julialang.org/u/N5N3)\
**Post date:** [September 5, 2020, 3:01pm UTC](https://discourse.julialang.org/t/is-there-any-limitation-on-threads-num-for-cpu-without-smt/46104/3 "2020-09-05T15:01:52Z")

</div>

In fact, I only find this if @spawn is used with MKL’s fftw (MKL’s BLAS is ok). 😅.  
And default FFTW3 is ok…, Maybe I should post a issue to FFTW.jl ? 🤔
