How to find out the number of cores or processors available in C
I got a following program to return the number of cores:
struct cpu_raw_data_t raw;
struct cpu_id_t data;
printf("No. of Physical Core(s) : %d\n", data.num_cores);
I am getting error on #include <libcpuid.h>. I am working on ubuntu 18.04.
Can somebody please guide me how to find the number of cores?
Why don't you tell us what the error is? We can't control your computer.
I see directions for installation here: https://github.com/anrieff/libcpuid
(scroll down to the Readme).
For the compiler commands of the test program, see: http://libcpuid.sourceforge.net/documentation.html
If your error is that it can't find the .h file,
|The development headers must be placed in your search path. Under UNIX-like OSes with pkg-config, this is achieved with "pkg-config libcpuid --cflags".|
I don't currently have the ability to install it myself, but try to understand both of those pages.