Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: SFML already use 4 threads (include main)?  (Read 9585 times)

0 Members and 1 Guest are viewing this topic.

Lyosha12

  • Newbie
  • *
  • Posts: 6
    • View Profile
    • Email
SFML already use 4 threads (include main)?
« 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? 
« Last Edit: July 27, 2020, 06:36:34 pm by Lyosha12 »

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: SFML already use 4 threads (include main)?
« Reply #1 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.
Laurent Gomila - SFML developer

Lyosha12

  • Newbie
  • *
  • Posts: 6
    • View Profile
    • Email
Re: SFML already use 4 threads (include main)?
« Reply #2 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
« Last Edit: July 27, 2020, 08:05:22 pm by Lyosha12 »

Lyosha12

  • Newbie
  • *
  • Posts: 6
    • View Profile
    • Email
Re: SFML already use 4 threads (include main)?
« Reply #3 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)
« Last Edit: July 27, 2020, 08:27:05 pm by Lyosha12 »

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: SFML already use 4 threads (include main)?
« Reply #4 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.
Laurent Gomila - SFML developer

Lyosha12

  • Newbie
  • *
  • Posts: 6
    • View Profile
    • Email
Re: SFML already use 4 threads (include main)?
« Reply #5 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

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: SFML already use 4 threads (include main)?
« Reply #6 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.
Laurent Gomila - SFML developer