SFML community forums

Help => System => Topic started by: Lyosha12 on July 27, 2020, 06:35:01 pm

Title: SFML already use 4 threads (include main)?
Post by: Lyosha12 on July 27, 2020, 06:35:01 pm
My debugger shows to me that I have already 4 threads:
(click to show/hide)

If I create two more threads thereat I have 6 threads already:
(click to show/hide)
Does it mean that I be able to create only
std::thread::hardware_concurrency() - 4
threads?
May I disable threads which I don't know for what? 
Title: Re: SFML already use 4 threads (include main)?
Post by: Laurent on July 27, 2020, 06:43:45 pm
There's no internal thread created by SFML if you don't use the audio module, is that the case?

Don't forget that the OS and drivers create threads as well. There are also many other processes with potentially multiple threads running on your system... which doesn't mean that they are all active and eat CPU, most of them are background threads. So you can consider that only the threads that you create eat a significant amount of CPU, and create as much as you need.
Title: Re: SFML already use 4 threads (include main)?
Post by: Lyosha12 on July 27, 2020, 07:57:17 pm
I'm not using audio-module. If I even remove sfml-audio from my CMake script these threads aren't gone.
(click to show/hide)

I want to calc Mandelbrot fractal via pass a pixel row to a separate thread and I'm need to use all of available threads. I know that in my system about 2000 thread and I know that they are not be able to active in one moment.

I assume that only my program witch now is active will take mostly place in my cores. So I need use all of them. But I don't know are this 3 threads is active and if not I want to remove them from my program but don't know how. Please hint me about it
Title: Re: SFML already use 4 threads (include main)?
Post by: Lyosha12 on July 27, 2020, 08:21:19 pm
It's funny. I have made sample program and I have 10 threads. Why so?

(click to show/hide)
(click to show/hide)
(click to show/hide)
Title: Re: SFML already use 4 threads (include main)?
Post by: Laurent on July 27, 2020, 08:25:02 pm
As I said, it's driver / OpenGL / OS / ... stuff, nobody knows! Profile them if you really want to be sure that they are not consuming CPU.
Title: Re: SFML already use 4 threads (include main)?
Post by: Lyosha12 on July 27, 2020, 08:54:55 pm
He-he. I had inserted that one code into my main of fractal and I had 12 threads. How I can test that are these threads are not consuming CPU? There is some tool? I use CLion and his internal debugger, I can't set breakpoints into disassembler's code of those threads
Title: Re: SFML already use 4 threads (include main)?
Post by: Laurent on July 27, 2020, 10:34:03 pm
I think that VerySleepy (a Windows profiler) can show CPU usage of each thread in a monitored process. You can try it, it's straight-forward to use.