Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Counting the number of procs and cores (WIN32) - Can you help me test?

  • 17-11-2006 11:03am
    #1
    Closed Accounts Posts: 1,193 ✭✭✭


    Hi Guys,

    I've written some code which uses CPUID combined with the Win32 API GetSystemInfo() to determined the number of processors and the number of cores on those processors.

    I've tested it successfully on:

    // a) AMD Athlon64 based single processor system
    // b) Intel Pentium III based dual processor system
    // c) Intel Pentium 4 HT based single processor system (HT on and off)
    // d) Intel Pentium 4 D based single processor system
    // e) Intel Core 2 Duo based single processor system
    // f) Intel Pentium 4 based single processor system
    // g) AMD Athlon (early socket) based single processor system
    // h) AMD Athlon (slot) based single processor system
    // i) Intel Pentium 4 based single processor system
    // j) AMD Sempron based single processor system
    // k) Intel Celeron based single processor system

    Which pretty much represents the range of machines I can get my hands on at the moment. The old single core machines were just tested to ensure that the program is generally "safe" and I didn't record specifc information about chip types.

    I'm interested in testing on more machine types: Intel quad-core, AMD dual-processor, AMD Dual-core, quad-processor machines, multi-core/multi-processor. Can people help me out? The source code can be obtained from ftp://www.mcs.com/downloads/cupidwin_src.zip. It's dialog-based MFC application with a VC 6.0 workspace. All the action happens in the dialog's OnInitDialog. The CPUID calls are in inline ASM. If you're competent to do so, can you build and run a copy and post the details here?

    If you can't build a copy yourself but you know me or know somone who will vouch for me, PM me with your email address and I'll send you binary. Can I remind you that you shouldn't ever run binaries supplied by people you don't know, for obvious reasons... (even though it would suit me in this instance)

    Thanks in advance,

    Kieran


Comments

  • Closed Accounts Posts: 1,567 ✭✭✭Martyr


    well..i couldn't download the archive, ftp required username/password.
    the problem with using GetSystemInfo() was that it didn't properly report "logical" cores on some brands..i.e intel
    but there is GetLogicalProcessorInformation() api, only available in vista/win2k3 though.(for moment, perhaps this will change in SP3 for XP)
    so, it would be interesting to see your code :)


  • Closed Accounts Posts: 1,193 ✭✭✭Kix


    well..i couldn't download the archive, ftp required username/password.
    the problem with using GetSystemInfo() was that it didn't properly report "logical" cores on some brands..i.e intel
    but there is GetLogicalProcessorInformation() api, only available in vista/win2k3 though.(for moment, perhaps this will change in SP3 for XP)
    so, it would be interesting to see your code :)

    Gah, sorry Joe. Same address but use HTTP:. I have FTP access, others wouldn't.

    I recognise the problem with GetSystemInfo which is why it's only part of the answer - CPUID is used to qualify the answer Windows gives. we want something that is going to work until we can rely on GetLogicalProcessorInformation being generally available.

    Anyhow thanks for the reply, hope you get to take a look at it. I haven't copyrighted the code so if it's of use to anyone else...


  • Registered Users, Registered Users 2 Posts: 885 ✭✭✭clearz


    CPU: Intel Core 2 Duo E6600

    CPU_Spec.jpg


  • Registered Users, Registered Users 2 Posts: 6,289 ✭✭✭Talisman


    AMD Athlon 64 X2 Dual Core 4800+ Processor

    CPU Vendor : AMD
    Processor Cores: 2
    Logical CPUs: 1
    Processors (WINAPI): 2
    Interpretation:
    Processors: 1
    Cores: 2

    I'll try to run it on some of the Intel servers in work later and post the results for you.

    Here are the servers details:
    Intel Pentium 3 650MHz
    CPU Vendor : Intel (or other)
    Processor Cores: 1
    Logical CPUs: 1
    Processors (WINAPI): 1
    Interpretation:
    Processors: 1
    Cores: 1

    Dual Processor Intel Pentium 3 550MHz
    CPU Vendor : Intel (or other)
    Processor Cores: 1
    Logical CPUs: 1
    Processors (WINAPI): 2
    Interpretation:
    Processors: 2
    Cores: 1

    Quad Processor Intel Pentium 3 550MHz
    CPU Vendor : Intel (or other)
    Processor Cores: 1
    Logical CPUs: 1
    Processors (WINAPI): 4
    Interpretation:
    Processors: 4
    Cores: 1

    Dual Core Intel Pentium 4 3.0GHz
    CPU Vendor : Intel (or other)
    Processor Cores: 1
    Logical CPUs: 2
    Processors (WINAPI): 2
    Interpretation:
    Processors: 1
    Cores: 1


  • Closed Accounts Posts: 1,193 ✭✭✭Kix


    Many thanks guys, the only one it's getting wrong at present is that situation where it decides zero processors in some cases (technically a half a processor cast to an int). I need to to review my logic on that one :)

    CPUID says 2 cores and 2 logical processors, Windows sees 2 processors, which is all correct; the answer should clearly be 1 dual-core processor.

    EDIT: I also see that it seems to be getting that Dual Core Pentium 4 3.0 GHz wrong as well :( Missed that first time. Talisman, if you can provide me any more info on that chip, I'd be very grateful. It's mistaking it for a Pentium 4 HT. Maybe you can use WCPUID on it and send me the log?


  • Advertisement
  • Closed Accounts Posts: 1,193 ✭✭✭Kix


    I see that I fluffed my re-implemetation of the results interpretation when I moved this to a MFC dialog app...

    The algorithm for determining the true number of processors was intended to have been expressed as:

    Where:

    C = number of cores reported by CPUID
    L = number of logical processors reported by CPUID
    W = number of processors reported by Windows
    T = true number of packages (CPUs)

    T = W / (C * MIN((L/C),W))

    rather than:

    T = W / (C * MIN(L,W))

    which was what was coded.

    I knew I'd tested a Pentium 4 D and a Core 2 Duo successfully :)

    If anyone is interested, I've uploaded the source again with this minor change. I still need to figure out that one erroneous result posted by Talsiman. Hopefully it's really a Pentium 4 HT and not some odd stepping that I'll have to post a special case for. Intel documentation don't give any indication that there may be a possibility that a dual-core machine will return 0 for CPUID.4.EAX[31:26] as this one seems to be doing.

    If I get the chance, I'm looking to update the code a little more based on Intel document # 276613 Detecting Multi-Core Processor Topology in an IA-32 Platform to provide some future-proofing in a multi-core, HT-enabled future. If I do, I'll post the source again.


  • Registered Users, Registered Users 2 Posts: 6,289 ✭✭✭Talisman


    I wouldn't get too hung up on the last Intel processor I posted even Intel's processor identifier utility identifies it as a single processor.


  • Registered Users, Registered Users 2 Posts: 6,762 ✭✭✭WizZard


    Post an EXE and I can test it against multi processor and multi core Xeon and AMD based servers (test lab).
    I don't have the older version of VS any more to build it :(


Advertisement