質問

I noticed, that MingW and GCC compilers use multiple cores if available.

For example:

for (long i = 0; i < 100000; ++i)
{
    some_complicated_calculation();
}

If I open up a Task Manager / System Monitor, I can see that multiple (for me: 2) cores are used.

How the compiler decides, which code can run on multiple cores?
How do I force the compiler, to use only one core?

EDIT

My code does not contain any multithreaded code.
I'm curious why my program (not the compiler) is using multiple cores.

役に立ちましたか?

解決

It is using a single core as long as there is nothing special inside some_complicated_calculation() that creates threads or uses async (C++11) or similar.

The activity you see on the task manager cannot be related to the executable that iterates. It could be totally unrelated to what you are working on.

他のヒント

Looks like thread_bind_to_processor provided in GNU software radio is what you're looking for: http://gnuradio.org/doc/doxygen/namespacegr_1_1thread.html#aab5195edcd94db5c71ecbfef9d578fb7

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top