How to query the current maximum number of threads?

question
performance

#1

I have just found JULIA_NUM_THREADS in the documentation, and I wonder if Julia is already doing a good job on picking up the number of CPU cores on my laptop. Is there a command to find the number of threads available?


#2

Threads.nthreads(). It doesn’t add threads by default, but Juno does.


#3

I tried setting the variable JULIA_NUM_THREADS on my .juliarc.jl file but it doesn’t affect Threads.nthreads(). Is it already implemented?


#4

That won’t work.


#5

JULIA_NUM_THREADS is supposed to be an environment variable set before Julia is opened.


#6

Thank you all, I have the variable set on my .bashrc, and it works now. Though I think this should be widely spread to other Julians, I’d have set this variable a long time ago.


#7

No please don’t. It is highly experimental.


#8

What is not highly experimental in Julia? :slight_smile:


#9

Well, there are the kind of code that is expected to work and there are features that aren’t.