btafantastic.blogg.se

C how to get core id
C how to get core id












c how to get core id

  • You need to be careful of the term CPU as it means different things in different contextsįor the answer not to be confusing, you need to understand a couple of simple computer architecture concepts:.
  • You need to be aware of sockets, cores and threads.
  • $ lscpu -all -parse=CPU,SOCKET,CORE | grep -v '^#' The lscpu command has a number of useful options that you may like to check out, for example: $ lscpu -all -extended In the case of the server system listed above we expect to see 8 cores per socket and 16 threads per socket: $ sudo dmidecode -t 4 | grep -E 'Socket Designation|Count'

    c how to get core id

    To specifically answer your question you tell how many cores you have by multiplying the number of cores you have per socket by the number of sockets you have.įor the example systems above the desktop has 4 cores: $ echo "Cores = $(( $(lscpu | awk '/^Socket\(s\)/') ))"Īnother useful utility is dmidecode which outputs per socket information.

    c how to get core id

    For the desktop machine above this should match the 4 Core(s) per socket reported by lscpu: $ grep -m 1 'cpu cores' /proc/cpuinfo The cpu cores reported by /proc/cpuinfo corresponds to the Core(s) per socket reported by lscpu. The output of /proc/cpuinfo should match this information, for example on the desktop system above we can see there are 8 processors (CPUs) and 4 cores (core id 0-3): $ grep -E 'processor|core id' /proc/cpuinfo For the desktop machine above this should match the 8 CPU(s) reported by lscpu: $ nproc -all The output of nproc corresponds to the CPU count from lscpu. Here is an example from a desktop machine: $ lscpu | grep -E '^Thread|^Core|^Socket|^CPU\('Īnd a server: $ lscpu | grep -E '^Thread|^Core|^Socket|^CPU\(' Wa_cq_url: "/content/If you multiply these numbers you will get the number of CPUs on your system.ĬPUs = Threads per core X cores per socket X socketsĬPUs are what you see when you run htop (these do not equate to physical CPUs). Wa_audience: "emtaudience:business/btssbusinesstechnologysolutionspecialist/developer/softwaredeveloper", Wa_subject: "emtsubject:itinformationtechnology/codemodernization,emtsubject:itinformationtechnology/codemodernization/parallelcomputing,emtsubject:itinformationtechnology/codemodernization/parallelcomputing/vectorization", Wa_emtsubject: "emtsubject:itinformationtechnology/codemodernization/parallelcomputing,emtsubject:itinformationtechnology/codemodernization,emtsubject:itinformationtechnology/codemodernization/parallelcomputing/vectorization", Wa_curated: "curated:donotuseinexternalfilters/hidefromuam", Wa_emtcontenttype: "emtcontenttype:salesandmarketingmaterials/marketingtools/topicoverviews",














    C how to get core id