Open FabianSchuetze opened 3 weeks ago
Doesn't core affinity only ensure that the main thread stays on the same CPU, not that the main thread is unable to start new threads?
https://man7.org/linux/man-pages/man1/taskset.1.html
The taskset command is used to set or retrieve the CPU affinity
of a running process given its pid, or to launch a new command
with a given CPU affinity. CPU affinity is a scheduler property
that "bonds" a process to a given set of CPUs on the system. The
Linux scheduler will honor the given CPU affinity and the process
will not run on any other CPUs.
I agree.
What's the meaning of Run on (24 X 4700 MHz CPU s)
then?
That does not indicate any threading decisions by benchmark instead it enumerates the number of CPU cores of the test system? Equivalently, if taskset
is not used, Run on (24 X 4700 MHz CPU s)
also don't indicate that the benchmark run parallel on different cores.
I think so, yes. https://github.com/google/benchmark/blob/main/src/sysinfo.cc seems to temporarily unset core affinity to read CPU frequencies, but i don't think it ever reports what the actual affinity is. But again, i'm not sure what happens for all the extra threading that may happen (either libbenchmark-induced, or in the snippet-under-measurement).
we could fix the PrintBasicContext
section to report on the number of CPUs used if we got the current affinity somewhere i guess?
That would be wonderful, but I wonder if that solves only one-half of the issue?
If no affinity is set (0xFFFFFFF is returned), should the benchmark report that it runs on all cores? I think the benchmark is not scheduled to run in parallel on different cores, or?
However, particularly when the system is a hybrid architecture and consists of "performance" and "efficient" cores, reporting the affinity is useful, I think.
Describe the bug I would like to run the benchmark on a particular CPU core. The [docs]( says:
However, when I run the
basic_test
app, I see the following:I think it might be reporting here that is wrong. Looking at
top
, I can verify that only core 0 is used. The code inreporter
[https://github.com/google/benchmark/blob/main/src/reporter.cc#L49C29-L49C37) seems to use a static number of cores.System Which OS, compiler, and compiler version are you using:
To reproduce Steps to reproduce the behavior:
ea71a14891474943fc1f34d359f9e0e82476ffe1
cmake -D BENCHMARK_DOWNLOAD_DEPENDENCIES=1 -S . -B build
cmake --build build/ -j20
taskset -c 0 ./build/test/basic_test
Expected behavior I would expect the test to run only on core 0 and the output of the test be:
Run on (1 X 4700 MHz CPU s)
instead ofRun on (24 X 4700 MHz CPU s)