@threads :Static seems not doing static scheduling?

I start julia with set JULIA_EXCLUSIVE=1 and julia -t 2 and I have multi-threaded code. Meanwhile running it, I don’t know why I can not see two cores working with their maximum? but rather a switching between cores although I used static scheduling. This is actually is killing the performance for the parallel code. Any reason for that or to solve it?
Note that when I run the serial version of the code, somehow only two cores works (I don’t know also why not only one) but at least one core with its maximum

There’s no guarantee from the OS that one process thread will be pinned to one core, is there?

1 Like

It seems no guarantee, but then what is the meaning of using :Static with @threads?

static implies that tasks are pinned to threads, and won’t migrate between threads. This means that Threads.threadid() will be a constant throughout in the task. It does not mean that the thread can’t migrate between cores.

2 Likes

For pinning threads to cores (rather than tasks to threads), you should probably use [ANN] Announcing ThreadPinning.jl

1 Like

Based on the screenshots, I assume that the OP is on Windows, which currently isn’t supported by ThreadPinning.jl. Instead, @Amro, you can try setting the environment variable JULIA_EXCLUSIVE=1 before starting Julia.

1 Like

Thanks for your feedback. Yes, it is windows. I have already mentioned that I used it in powershell (do I need to use it in environment variable in windows?). But still no cores are pinned. Does it needs a special care?

Thanks for your feedback. As carstenbauer it is not supported for windows

Thanks for your feedback. Is there a package in windows to pin threads to cores in Julia?