Recent

Author Topic: Apple Developer Transition Kit  (Read 17084 times)

Igor Kokarev

  • Sr. Member
  • ****
  • Posts: 314
Re: Apple Developer Transition Kit
« Reply #120 on: November 14, 2020, 02:14:25 pm »
skalogryz,

Thanks, I'll try NSProcessInfo processInfo.processorCount
It would be a simpliest code for macOS.

Jonas,

Did you see any articles or confirmations about using of 8-cores in Apple DTK or M1?

Quote
"The Geekbench 5 result reports the DTK as having only four cores while it is known that the A12Z has, in fact, eight CPU cores. It is very well possible that Rosetta 2 is seeing only the four high performance cores and not the efficiency ones."
https://www.notebookcheck.net/First-A12Z-Bionic-DTK-Geekbench-5-benchmarks-show-Apple-s-transition-holds-immense-promise-only-a-28-in-drop-seen-in-single-core-score-compared-to-the-MacBook-Air-2020.477595.0.html

Jonas Maebe

  • Hero Member
  • *****
  • Posts: 828
Re: Apple Developer Transition Kit
« Reply #121 on: November 14, 2020, 03:13:52 pm »
You don't need external confirmation since you have a DTK yourself. Just create a program that starts 7 threads that execute "while true do ;" (and do the same in the main program) and look at the cpu usage reported by top (or Activity Viewer). Then try the same with 3 threads and 11 threads. You'll get ~390%/~790%/~790% reported cpu usage for respectively 4/8/12 loops executing concurrently.
« Last Edit: November 14, 2020, 03:19:51 pm by Jonas Maebe »

Igor Kokarev

  • Sr. Member
  • ****
  • Posts: 314
Re: Apple Developer Transition Kit
« Reply #122 on: November 16, 2020, 09:24:23 am »
Jonas,

You're right. It's easy to check.

The only question - performance of last 4 cores. Probably the total performance of these high-efficienty cores would be as 2 high-performance cores.

Igor Kokarev

  • Sr. Member
  • ****
  • Posts: 314
Re: Apple Developer Transition Kit
« Reply #123 on: November 16, 2020, 12:50:56 pm »

What about processorCount?

The code might look like thise
Code: Pascal  [Select][+][-]
  1. uses
  2.   CocoaAll;
  3. {$modeswitch objectiveC2}
  4.  
  5. begin
  6.   writeln('proc count: ', NSProcessInfo processInfo.processorCount);
  7. end.  

skalogryz,

I can't compile this code on any Mac.

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2558
    • havefunsoft.com
Re: Apple Developer Transition Kit
« Reply #124 on: November 16, 2020, 01:40:39 pm »
Code: Pascal  [Select][+][-]
  1. uses
  2.   CocoaAll;
  3. {$modeswitch objectiveC2}
  4.  
  5. begin
  6.   writeln('proc count: ', NSProcessInfo.processInfo.processorCount);
  7. end.
Patron Cocoa Widgetset development https://www.patreon.com/skalogryz

JdeHaan

  • Jr. Member
  • **
  • Posts: 60
Re: Apple Developer Transition Kit
« Reply #125 on: November 16, 2020, 02:01:42 pm »
The mode switch should be above the uses clause.
Code: Pascal  [Select][+][-]
  1. program processorcount;
  2. {$modeswitch objectiveC2}
  3.  
  4. uses
  5.   CocoaAll;
  6.  
  7. begin
  8.   writeln('proc count: ', NSProcessInfo.processInfo.processorCount);
  9. end.
  10.  

Igor Kokarev

  • Sr. Member
  • ****
  • Posts: 314
Re: Apple Developer Transition Kit
« Reply #126 on: November 16, 2020, 04:44:04 pm »
Thanks, it works now.

Jonas Maebe

  • Hero Member
  • *****
  • Posts: 828
Re: Apple Developer Transition Kit
« Reply #127 on: November 16, 2020, 07:54:10 pm »
Jonas,

You're right. It's easy to check.

The only question - performance of last 4 cores. Probably the total performance of these high-efficienty cores would be as 2 high-performance cores.
Not necessarily. Performance wins usually decrease exponentially as cores become more powerful/complex, so it could easily be more than that. It also illustrates the limited use of a singular "processorcount" value. Other cases where it means little is in case of NUMA configurations and hyperthreading.

trev

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1269
  • Former Delphi 1-7, 10.2 User
Re: Apple Developer Transition Kit
« Reply #128 on: November 16, 2020, 10:58:50 pm »
HW selectors for sysctlbyname which are useful in this context:

* hw.ncpu   - The maximum number of processors that could be available this boot
* hw.activecpu   - The number of processors currently available for executing threads
* hw.physicalcpu - The number of physical processors available in the current power management mode
* hw.logicalcpu  - The number of logical processors available in the current power management mode

See the Wiki article Accessing macOS System Information.
Lazarus 2.1 r64368 FPC 3.3.1 r48100 macOS 10.14.6 Xcode 11.3.1
Lazarus 2.1 r64455 3.3.1 r48688  macOS 11.2 aarch64 Xcode 12.4
Lazarus 2.1 r61574 3.3.1 r42318 FreeBSD 12.1 amd64 VMware VM
Lazarus 2.1 r61574 3.0.4 Ubuntu 20.04 Parallels VM
Lazarus 2.0.10 3.2.0 Win10 Parallels VM

Igor Kokarev

  • Sr. Member
  • ****
  • Posts: 314
Re: Apple Developer Transition Kit
« Reply #129 on: November 17, 2020, 09:10:10 pm »
Thanks! Great info. I'll learn it more.

marcov

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 9082
  • FPC developer.
Re: Apple Developer Transition Kit
« Reply #130 on: November 17, 2020, 10:43:34 pm »
Not necessarily. Performance wins usually decrease exponentially as cores become more powerful/complex, so it could easily be more than that. It also illustrates the limited use of a singular "processorcount" value. Other cases where it means little is in case of NUMA configurations and hyperthreading.

There are also some reports that the extreme bandwidth of the fast cores leads to memory bandwidth saturation, where the slower core could eat memory bandwidth of the faster cores.

https://www.anandtech.com/show/16252/mac-mini-apple-m1-tested

Igor Kokarev

  • Sr. Member
  • ****
  • Posts: 314
Re: Apple Developer Transition Kit
« Reply #131 on: November 19, 2020, 02:02:18 pm »
Currently FPC trunk can compile to "arm64" target for macOS.

In the final release of Big Sur Apple compiles own apps in "arm64e". You can check it using
lipo -archs /Applications/Safari.app/Contents/MacOS/Safari

It seems that arm64e is a new generation of arm64:

- Pointer authentication
- Nested virtualization
- Advanced SIMD complex number support
- Improved Javascript data type conversion support
- A change to the memory consistency model
- ID mechanism support for larger system-visible caches

Is it possible that "arm64" will be declared as deprecated in nearest future?

Can FPC compile to arm64e ?

https://stackoverflow.com/questions/52624308/xcode-arm64-vs-arm64e

Jonas Maebe

  • Hero Member
  • *****
  • Posts: 828
Re: Apple Developer Transition Kit
« Reply #132 on: November 19, 2020, 02:40:47 pm »
Quote
In the final release of Big Sur Apple compiles own apps in "arm64e".
Apple has been doing that since several betas already (maybe even from the first beta, but I didn't have a DTK yet at that point).

Quote
It seems that arm64e is a new generation of arm64:
No, it's just an extension.

Quote
Is it possible that "arm64" will be declared as deprecated in nearest future?
Definitely not in the nearest future, since building your own applications for arm64e is not even supported yet by Apple itself: https://developer.apple.com/forums/thread/652340

Most likely not afterwards either.

Quote
Can FPC compile to arm64e ?
Currently only by using the LLVM backend.

Igor Kokarev

  • Sr. Member
  • ****
  • Posts: 314
Re: Apple Developer Transition Kit
« Reply #133 on: November 19, 2020, 04:13:47 pm »
Jonas,

Thank you very much for the detailed reply!

Igor Kokarev

  • Sr. Member
  • ****
  • Posts: 314
Re: Apple Developer Transition Kit
« Reply #134 on: November 19, 2020, 06:54:45 pm »
Jonas,

I plan to compile a final version of our app as Universal Binary (Intel + AARCH64).

You explained me how to configure cross compilation on Intel Mac.

What is better:
A. Use a stable Lazarus 2.0.10 with FPC Trunk 3.3.1?
B. Or Lazarus Trunk + FPC Trunk 3.3.1?

I guess that official release of Lazarus with FPC will not be released soon.
« Last Edit: November 19, 2020, 07:11:33 pm by Igor Kokarev »

 

TinyPortal © 2005-2018