Recent

Author Topic: NumCPULib4Pascal  (Read 6545 times)

ASBzone

  • Hero Member
  • *****
  • Posts: 678
  • Automation leads to relaxation...
    • Free Console Utilities for Windows (and a few for Linux) from BrainWaveCC
Re: NumCPULib4Pascal
« Reply #30 on: August 08, 2019, 03:16:54 am »
NumCPULib4Pascal is a Library that enables you to Count the number of CPUs on the current machine.
This Library aims to provide support for those Oses that are not supported by System.CPUCount ( or those in which System.CPUCount defaults to 1).

Awesome!  And thanks!   I was researching code for this very thing in June...
-ASB: https://www.BrainWaveCC.com/

Lazarus v2.2.7-ada7a90186 / FPC v3.2.3-706-gaadb53e72c
(Windows 64-bit install w/Win32 and Linux/Arm cross-compiles via FpcUpDeluxe on both instances)

My Systems: Windows 10/11 Pro x64 (Current)

Xor-el

  • Sr. Member
  • ****
  • Posts: 404
Re: NumCPULib4Pascal
« Reply #31 on: August 08, 2019, 12:12:47 pm »
NumCPULib4Pascal is a Library that enables you to Count the number of CPUs on the current machine.
This Library aims to provide support for those Oses that are not supported by System.CPUCount ( or those in which System.CPUCount defaults to 1).

Awesome!  And thanks!   I was researching code for this very thing in June...

Glad I could help.  8)

Thaddy

  • Hero Member
  • *****
  • Posts: 14210
  • Probably until I exterminate Putin.
Re: NumCPULib4Pascal
« Reply #32 on: August 08, 2019, 02:10:49 pm »
@Xor-el
I have one remark:
You designed it with int32 and exceptions.
I would prefer it without exceptions and an unsigned type.
For some platforms that would require maybe a local variable of a signed type.
After all you have a fall-back to one, and it can't be processed at all of there is no processor  :D 8-)
Specialize a type, not a var.

Xor-el

  • Sr. Member
  • ****
  • Posts: 404
Re: NumCPULib4Pascal
« Reply #33 on: August 08, 2019, 02:59:43 pm »
@Xor-el
I have one remark:
You designed it with int32 and exceptions.
I would prefer it without exceptions and an unsigned type.
For some platforms that would require maybe a local variable of a signed type.
After all you have a fall-back to one, and it can't be processed at all of there is no processor  :D 8-)

thanks for the remark, will look into it. :)

Xor-el

  • Sr. Member
  • ****
  • Posts: 404
Re: NumCPULib4Pascal
« Reply #34 on: August 08, 2019, 06:46:00 pm »
@Xor-el
I have one remark:
You designed it with int32 and exceptions.
I would prefer it without exceptions and an unsigned type.
For some platforms that would require maybe a local variable of a signed type.
After all you have a fall-back to one, and it can't be processed at all of there is no processor  :D 8-)

@Thaddy, as promised
https://github.com/Xor-el/NumCPULib4Pascal/blob/travis/NumCPULib/src/NumCPULib.pas
Can you please confirm that I have implemented your remark so I can merge it to master?

Thaddy

  • Hero Member
  • *****
  • Posts: 14210
  • Probably until I exterminate Putin.
Re: NumCPULib4Pascal
« Reply #35 on: August 08, 2019, 06:55:02 pm »
need 24 hours for proper reply. Looks good.
Specialize a type, not a var.

winni

  • Hero Member
  • *****
  • Posts: 3197
Re: NumCPULib4Pascal
« Reply #36 on: August 08, 2019, 08:12:42 pm »
@Xor-el

Just tested the version https://github.com/Xor-el/NumCPULib4Pascal/blob/travis/NumCPULib/src/NumCPULib.pas

Yeah, now with info from /proc/cpuinfo everythings looks fine.

For my Ryzen  is reported

Logical CPU Count is 8
Physical CPU Count is 4

Have a nice day
Winni

Xor-el

  • Sr. Member
  • ****
  • Posts: 404
Re: NumCPULib4Pascal
« Reply #37 on: August 08, 2019, 08:55:38 pm »
@Xor-el

Just tested the version https://github.com/Xor-el/NumCPULib4Pascal/blob/travis/NumCPULib/src/NumCPULib.pas

Yeah, now with info from /proc/cpuinfo everythings looks fine.

For my Ryzen  is reported

Logical CPU Count is 8
Physical CPU Count is 4

Have a nice day
Winni

@winni, yes I did make some minor changes as regards multiple sockets PC.
was not making a unique count before so duplicates were counted.

Thanks for testing though.

ASBzone

  • Hero Member
  • *****
  • Posts: 678
  • Automation leads to relaxation...
    • Free Console Utilities for Windows (and a few for Linux) from BrainWaveCC
Re: NumCPULib4Pascal
« Reply #38 on: August 08, 2019, 10:16:28 pm »

@winni, yes I did make some minor changes as regards multiple sockets PC.
was not making a unique count before so duplicates were counted.

Thanks for testing though.


Question, @Xor-el.   At present, do you plan to be able to distinguish a system with 2 sockets, each containing quad-core processors, with hyperthreading, vs a single 8-core CPU with hyperthreading?

Both would have 8 physical CPUs and 16 logical CPUs, but it would be nice to be able to distinguish two-socket or four-socket server system.
-ASB: https://www.BrainWaveCC.com/

Lazarus v2.2.7-ada7a90186 / FPC v3.2.3-706-gaadb53e72c
(Windows 64-bit install w/Win32 and Linux/Arm cross-compiles via FpcUpDeluxe on both instances)

My Systems: Windows 10/11 Pro x64 (Current)

Xor-el

  • Sr. Member
  • ****
  • Posts: 404
Re: NumCPULib4Pascal
« Reply #39 on: August 08, 2019, 10:44:51 pm »

Question, @Xor-el.   At present, do you plan to be able to distinguish a system with 2 sockets, each containing quad-core processors, with hyperthreading, vs a single 8-core CPU with hyperthreading?

Both would have 8 physical CPUs and 16 logical CPUs, but it would be nice to be able to distinguish two-socket or four-socket server system.

@ASBzone, might be a research area for me in the future but for now nothing at the moment.  :)

ASBzone

  • Hero Member
  • *****
  • Posts: 678
  • Automation leads to relaxation...
    • Free Console Utilities for Windows (and a few for Linux) from BrainWaveCC
Re: NumCPULib4Pascal
« Reply #40 on: August 10, 2019, 12:34:01 am »
@ASBzone, might be a research area for me in the future but for now nothing at the moment.  :)


Fair enough.  Thanks for the work in any event.  It is much appreciated.  I recently spent a good part of June looking for code that would do just this, and had to put everything on hold.  But now, your unit saves the day.  Thank you kindly.
-ASB: https://www.BrainWaveCC.com/

Lazarus v2.2.7-ada7a90186 / FPC v3.2.3-706-gaadb53e72c
(Windows 64-bit install w/Win32 and Linux/Arm cross-compiles via FpcUpDeluxe on both instances)

My Systems: Windows 10/11 Pro x64 (Current)

 

TinyPortal © 2005-2018