Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Apple's transitioning of Macs to new ARM CPU & GPU #3827

Closed
CharlieFenton opened this issue Jun 11, 2020 · 24 comments · Fixed by #3956
Closed

Support Apple's transitioning of Macs to new ARM CPU & GPU #3827

CharlieFenton opened this issue Jun 11, 2020 · 24 comments · Fixed by #3956

Comments

@CharlieFenton
Copy link
Contributor

Bloomberg and others report that Apple is developing its own ARM processors for use in Macs starting in 2021, gradually replacing the current Intel processors in various Mac models.

https://www.bloomberg.com/news/articles/2020-04-23/apple-aims-to-sell-macs-with-its-own-chips-starting-in-2021

When Apple transitioned Macs from PowerPC to Intel CPUs in 2006, they temporarily provided an emulator (which Apple called "Rosetta") to allow the new computers to run the older software. They also added a capability in the development tools to create "fat binaries", which contained two copies of software, one for PowerPC architecture and one for Intel architecture. It seems likely that Apple will use a similar approach again.

Rosetta was introduced in Mac OS 10.4.4 (January 2006) and discontinued as of OS 10.7 (July 2011.) The ability to generate both PowerPC and Intel code and generate a fat binary was introduced in Xcode 2.1 (June 2005); PowerPC code generation was discontinued as of Xcode 4 (March 2011.)

Assuming Apple follows the same pattern, current Intel-based BOINC code will probably run on the new ARM based Macs for a few years, though at a reduced efficiency due to emulation. However, it is not clear whether BOINC Mac GPU code will be able to run on the Apple GPU.

To take full advantage of the new Mac hardware, we will need to update all Xcode projects, build scripts and autoconf / make files to build both Apple ARM and Intel architectures and release fat binaries. Note that this applies to building all the dependent libraries (cURL, OpenSSL, wxWidgets, etc.), as well as BOINC projects.

I hope that some of the Mac developers who have more recently expressed interest in helping BOINC will be able to take this on. I especially want to bring this to the attention of @ShanghaiTimes and @RoboticMind.

@RoboticMind
Copy link

As much as i would like to help with this, I am not a Mac developer. I don't really know how Xcode works very well. I could potentially help with checking arm compatibility with my raspberry pi, but I don't know how to help much past that

@nicolas17
Copy link
Contributor

The move to ARM has now been officially announced. It's possible to compile ARM apps on an Intel Mac (needs macOS Catalina and Xcode 12 beta), so some initial porting work can be done already, but it's not possible to execute and test the result yet. Unless you trade your soul for a Developer Transition Kit.

We need a BOINC platform name for Mac on ARM. I was concerned about the obvious choice aarch64-apple-darwin because on the off chance we get BOINC on iOS in the future, I thought it would be better to have different platform identifiers like "aarch64-apple-macos" and "aarch64-apple-ios". However, after some more research, it turns out they are far more similar and compatible than I expected. So... let's go with "aarch64-apple-darwin".

@davidpanderson
Copy link
Contributor

I added that to the platform name list.

@CharlieFenton
Copy link
Contributor Author

CharlieFenton commented Jun 24, 2020

I don't yet know what designation Apple plans to use for their new Mac architecture. Apple has used the names powerpc, i686 and x86_64 for its previous 3 Mac architectures, and we have kept BOINC's platform names consistent with Apple's designations: powerpc-apple-darwin, i686-apple-darwin and x86_64-apple-darwin. I recommend we continue to keep BOINC's platform names for Macs consistent with Apple's nomenclature. Apple's press release and other materials I have seen calls their new architecture "Apple silicon." @nicolas17 do you know for certain that Apple plans to call their new architecture aarch64? A quick check of Xcode 10 for iOS offers these architecture names: arm64, arm64e, armv7, armv7s.

We have named the downloadable files for BOINC's Mac installers boinc_x.y.z_macOSX_universal.zip, boinc_x.y.z_macOSX_i686.zip and boinc_x.y.z_macOSX_x86_64.zip for the different architectures. We named the downloadable bare client (without Manager, installer, uninstaller or screensaver) boinc_x.y.z_universal-apple-darwin.zip, boinc_x.y.z_i686-apple-darwin.zip, boinc_x.y.z_x86_64-apple-darwin.zip.

Apple facilitated its transition from the PowerPC to the Intel 32-bit architecture by doing two things:

  • For several years, macOS for Intel Macs included a PowerPC emulator which Apple called Rosetta; it ran PowerPC code on Intel hardware with surprising efficiency.
  • Apple's developer tools allowed building "universal" or "fat" binaries, which contained both PowerPC and i686 copies of the code in the same file. The OS on the target computer automatically ran the correct version for the machine's native architecture. This allowed us to distribute the "universal" versions of BOINC code which would run on either type of Mac.

Apple's press release (referenced above) indicates they will be using the same strategy for this transition form Intel to "Apple silicon" Macs:

Using Universal 2 application binaries, developers will be able to easily create a single app that taps into the native power and performance of the new Macs with Apple silicon, while still supporting Intel-based Macs. With the translation technology of Rosetta 2, users will be able to run existing Mac apps that have not yet been updated, including those with plug-ins. Virtualization technology allows users to run Linux.

Though the first Macs using "Apple silicon" will be released at the end of 2020, Apple expects to continue releasing new Macs with Intel chips into 2022.

As @nicolas17 wrote, Apple is offering developers a Developer Transition Kit for $500, which includes a temporary loan of a prototype Apple silicon based Mac and the use of beta software. But I think it is a bit early to start developing for the new architecture. In my experience, Apple's beta software can be pretty unreliable (you must use both a beta OS and beta development tools), and the new ARM based Macs should continue to run Intel software under emulation.

Note that not only BOINC's code, but also the dependent libraries will need to be compiled for both architectures. I have provided shell scripts for building all the libraries, and we were building universal binaries as late as BOINC 6.12.43 (11 July 2011), which involved building universal binary versions of the dependent libraries. Although those universal binaries were for PowerPC and i686 architectures, those scripts can serve as a guide / reminder for how to update the current scripts for multiple architectures.

@Ageless93
Copy link
Contributor

What I understand from all the news articles and is also said in the article Charlie points to, is that this ARM CPU is being designed by Apple themselves, so it may not be possible to compare this one to existing ARM CPUs out there.

For over a decade, Apple’s world-class silicon design team has been building and refining Apple SoCs. The result is a scalable architecture custom designed for iPhone, iPad, and Apple Watch that leads the industry in unique features and performance per watt, and makes each of them best in class. Building upon this architecture, Apple is designing a family of SoCs for the Mac.

@nicolas17
Copy link
Contributor

I don't yet know what designation Apple plans to use for their new Mac architecture. Apple has used the names powerpc, i686 and x86_64 for its previous 3 Mac architectures, and we have kept BOINC's platform names consistent with Apple's designations: powerpc-apple-darwin, i686-apple-darwin and x86_64-apple-darwin. I recommend we continue to keep BOINC's platform names for Macs consistent with Apple's nomenclature. Apple's press release and other materials I have seen calls their new architecture "Apple silicon." @nicolas17 do you know for certain that Apple plans to call their new architecture aarch64? A quick check of Xcode 10 for iOS offers these architecture names: arm64, arm64e, armv7, armv7s.

Ugh, you have a good point. I was worrying about what to use as OS name and didn't really think of the CPU architecture in the first component. I used aarch64 for consistency with the other BOINC platform strings: Linux and Android call it "aarch64", and the existing "powerpc", "i686" and "x86_64" match between Linux and Mac. But Apple calls it "arm64" (compiler -arch flag, uname, etc) just like on iOS. I don't know if it's more important to have consistency with Apple or consistency with other platform strings, that choice is best left to you :)

Note that Apple officially uses "x86_64-apple-macos10.12" as the target triple when running the compiler (yes, they even include the OS "minimum deployment version"), while autoconf has always used "darwin" as the third component, so we were already not using their exact platform string.

@CharlieFenton
Copy link
Contributor Author

Today I received an email from Apple pointing to this web page which says:

Xcode 12 builds Universal apps by default to support Mac with Apple Silicon, often without changing a single line of code.

and

When you open your project in Xcode 12, your app is automatically updated to produce release builds and archives as Universal apps. When you build your app, Xcode produces one binary “slice” for Apple Silicon and one for the Intel x86_64 CPU, then wraps them together as a single app bundle

That implies that BOINC's existing Xcode project should automatically build code that can run on both Intel and Apple silicon Macs without any changes, as long as we build using Xcode 12. Since the BuildMacBOINC.sh script invokes xcodebuild, that should probably do the same. Note, however, that the dependent libraries are built using configure / make, so their build scripts will probably need to be updated.

@truboxl
Copy link
Contributor

truboxl commented Jun 25, 2020

If the Macs have big.LITTLE configuration, the current benchmark will not reflect its potential. So some work are needed there.

@CharlieFenton
Copy link
Contributor Author

@davidpanderson

I added that to the platform name list.

Please change the platform name to arm64-apple-darwin instead of aarch64-apple-darwin to be consistent with BOINC's other Macintosh platform names i686-apple-darwin and x86_64-apple-darwin and ppc-apple-darwin, as this is the platform name I added in my PR#3956.

@davidpanderson
Copy link
Contributor

Done.

@AustinConlon
Copy link

AustinConlon commented Sep 21, 2020

I have a Developer Transition Kit (Apple Silicon Mac). Can I be added to receive BOINC test builds for macOS @davidpanderson?

@davidpanderson
Copy link
Contributor

I believe that the Mac version of 7.16.11 will run natively on ARM; Charlie Fenton could say for sure. However, I don't think any projects have Mac/ARM app versions yet.

@CharlieFenton
Copy link
Contributor Author

@AustinConlon: That's great! Thank you. I'm a bit surprised they are still shipping them, since industry analysts have been predicting that the first production Apple Silicon Macs will be out soon.

The Mac public release of BOINC version 7.6.11 is Intel only. It won't run natively on an Apple Silicon Mac, but it should run under Rosetta 2. (I don't know if Rosetta 2 uses emulation or a virtual machine.) It is of special interest to know whether Intel-based BOINC OpenCL GPU project applications run correctly, and also whether Intel-based BOINC graphics apps (which use GLUT / OpenGL) run correctly under Rosetta 2.

It would be great if you can test the default BOINC screensaver boincscr as well as project graphics (both running as a screensaver and via the "Show graphics" feature from the BOINC Manager Tasks tab.) You can also run boincscr as a stand-alone graphics app from Terminal as follows:

cd "/Library/Application Support/BOINC Data"
./boincscr

I will privately send you a Universal 2 binary of BOINC 7.6.11 (x86_64 / arm64) which I've built, with more information about things I'd like you to test.

@AustinConlon
Copy link

@CharlieFenton I'm a bit surprised too. Apple did say they'd start shipping Apple Silicon Macs by the end of the year, but it's also been not uncommon for them in the past to have Mac product releases in October.

The Mac public release of BOINC version 7.6.11 is Intel only. It won't run natively on an Apple Silicon Mac, but it should run under Rosetta 2. (I don't know if Rosetta 2 uses emulation or a virtual machine.) It is of special interest to know whether Intel-based BOINC OpenCL GPU project applications run correctly, and also whether Intel-based BOINC graphics apps (which use GLUT / OpenGL) run correctly under Rosetta 2.

It would be great if you can test the default BOINC screensaver boincscr as well as project graphics (both running as a screensaver and via the "Show graphics" feature from the BOINC Manager Tasks tab.) You can also run boincscr as a stand-alone graphics app from Terminal as follows:

cd "/Library/Application Support/BOINC Data"
./boincscr
I will privately send you a Universal 2 binary of BOINC 7.6.11 (x86_64 / arm64) which I've built, with more information about things I'd like you to test.

Noted.

@AustinConlon
Copy link

Rosetta 2 uses translation.

@CharlieFenton
Copy link
Contributor Author

have a Developer Transition Kit (Apple Silicon Mac) arriving on October 8

@AustinConlon I gather from #4040 that you've already received your Developer Transition Kit (and I now see you've edited that comment.) Let me know when you've finished testing BOINC 7.16.11 under Rosetta 2 and I'll build you an ARM64 / x86_64 Universal 2 binary to try, (You should also be able to build it yourself by following the build instructions at mac_build/HowToBuildBOINC_XCode.rtf in the BOINC GitHub client_release/7/7.16 branch.)

My biggest unknown is my build of the OpenSSL libraries libcrypto.a and libssl.a. These are used by the BOINC client when downloading and uploading files from and to projects. The OpenSSL configure script has limited options, so I configured for ios64-cross and then patched the make file to build for arm64-apple-macos10.7. If the code built that way doesn't work, we can try (as a temporary workaround) linking with the dynamic OpenSSL libraries that are normally included as /usr/lib/libcrypto.dylib and /usr/lib/libssl.dylib, though I don't know where they have put them in macOS 11.

@AustinConlon
Copy link

Tested "Show graphics" for the Rosetta@home project and it worked as expected:
Screen Shot 2020-09-29 at 12 45 54 PM
However, the screensaver just says "Starting screensaver graphics. Please wait ..."

@RichardHaselgrove
Copy link
Contributor

RichardHaselgrove commented Sep 30, 2020 via email

@AustinConlon
Copy link

I deleted the comment since the interval passed and the tasks went away. Thanks for clearing up the misunderstanding.

@CharlieFenton
Copy link
Contributor Author

However, the screensaver just says "Starting screensaver graphics. Please wait ..."

I've noticed that the screensaver can show that message for quite some time, especially when the overall Mac system is acting sluggish (for example, when Spotlight is doing a lot of indexing of disk contents after upgrading the OS.)

Please try this: set the manager's Activity menu to "Suspend" and run the screensaver (perhaps by putting the mouse in the appropriate Hot Corner.) Then allow a few minutes to see if the default ("overview") screensaver appears.

@AustinConlon
Copy link

AustinConlon commented Oct 15, 2020

I've noticed that the screensaver can show that message for quite some time, especially when the overall Mac system is acting sluggish (for example, when Spotlight is doing a lot of indexing of disk contents after upgrading the OS.)

Ah okay, I tried shortly after getting the DTK and updating the OS when I commented.

I see the screensaver now with the four credits progress bars.

@CharlieFenton
Copy link
Contributor Author

I see the screensaver now with the four credits progress bars.

That's terrific news! So it appears that BOINC 7.16.11 built for Intel x86_64 is working fully on Apple Silicon. I have one other question: have you tried running any GPU-based project applications? Or does the DTK not have any GPU known to BOINC?

@CharlieFenton
Copy link
Contributor Author

I have cross-compiled BOINC 7.6.11 for Apple Silicon (arm64) and sent it to @AustinConlon privately by email for testing on his DTK.

@AustinConlon
Copy link

Macs with Apple's new SoC ship next week, and macOS Big Sur is being released this Thursday.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants