Find the answer to your Linux question:
Results 1 to 3 of 3
From my application code, I want to get number of physical processors present in system (RHEL & SuSE). How do i go about? sysconf( ) - provides only logical CPUs ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Aug 2006
    Posts
    2

    Unhappy How to get number of physical CPUs in RHEL & SuSE


    From my application code, I want to get number of physical processors present in system (RHEL & SuSE). How do i go about?

    sysconf( ) - provides only logical CPUs count, not physical CPUs count

  2. #2
    Just Joined!
    Join Date
    Dec 2006
    Posts
    1

    Number of physical CPUs in RHEL

    Hi,

    Not sure about SuSE, but in RedHat EL you can use the physical id parameter found in /proc/cpuinfo. This will actually give you physical cores as opposed to sockets.

    Single CPU Xeon system with H/T (2 logical) would show as 1.
    Dual CPU AMD Opteron (4 physical cores, 2 sockets) would show as 4.

    grep "^physical is" /proc/cpuinfo | awk '{print $NF}' | uniq | wc -l

    Hope that helps - Lee

  3. #3
    Just Joined! vwvr9's Avatar
    Join Date
    Aug 2006
    Location
    Penang, Malaysia
    Posts
    26
    cat /proc/cpuinfo | egrep "processor|physical\ id|core\ id|cpu\ cores"

    Look at the "physical\ id" for physical CPU count and "cpu\ cores" for the core count

    Code:
    [root@abibi ~]# cat /proc/cpuinfo | egrep "processor|physical\ id|core\ id|cpu\ cores"
    processor       : 0
    physical id     : 0
    core id         : 0
    cpu cores       : 4
    processor       : 1
    physical id     : 0
    core id         : 1
    cpu cores       : 4
    processor       : 2
    physical id     : 0
    core id         : 2
    cpu cores       : 4
    processor       : 3
    physical id     : 0
    core id         : 3
    cpu cores       : 4
    processor       : 4
    physical id     : 1
    core id         : 0
    cpu cores       : 4
    processor       : 5
    physical id     : 1
    core id         : 1
    cpu cores       : 4
    processor       : 6
    physical id     : 1
    core id         : 2
    cpu cores       : 4
    processor       : 7
    physical id     : 1
    core id         : 3
    cpu cores       : 4
    [root@abibi ~]#

  4. $spacer_open
    $spacer_close

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •