Recent

Author Topic: NumCPULib4Pascal  (Read 1603 times)

ASBzone

  • Sr. Member
  • ****
  • Posts: 250
  • Automation leads to relaxation...
    • BrainWaveCC Utilities
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.0.5 r62023 / FPC v3.2.0-beta-r43192 (via FpcUpDeluxe) -- Windows 64-bit install w/32-bit cross-compile
Primary System: Windows 10 Pro x64, Version 1903 (Build 18362.356)
Other Systems: Windows 10 Pro x64, Version 1809 or greater

Xor-el

  • Sr. Member
  • ****
  • Posts: 371
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: 8880
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-)
Most people that want to use threading should learn to patch their jeans first: use a needle.

Xor-el

  • Sr. Member
  • ****
  • Posts: 371
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: 371
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: 8880
Re: NumCPULib4Pascal
« Reply #35 on: August 08, 2019, 06:55:02 pm »
need 24 hours for proper reply. Looks good.
Most people that want to use threading should learn to patch their jeans first: use a needle.

winni

  • Sr. Member
  • ****
  • Posts: 307
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: 371
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

  • Sr. Member
  • ****
  • Posts: 250
  • Automation leads to relaxation...
    • BrainWaveCC Utilities
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.0.5 r62023 / FPC v3.2.0-beta-r43192 (via FpcUpDeluxe) -- Windows 64-bit install w/32-bit cross-compile
Primary System: Windows 10 Pro x64, Version 1903 (Build 18362.356)
Other Systems: Windows 10 Pro x64, Version 1809 or greater

Xor-el

  • Sr. Member
  • ****
  • Posts: 371
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

  • Sr. Member
  • ****
  • Posts: 250
  • Automation leads to relaxation...
    • BrainWaveCC Utilities
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.0.5 r62023 / FPC v3.2.0-beta-r43192 (via FpcUpDeluxe) -- Windows 64-bit install w/32-bit cross-compile
Primary System: Windows 10 Pro x64, Version 1903 (Build 18362.356)
Other Systems: Windows 10 Pro x64, Version 1809 or greater