ARM based macs

105 views
Skip to first unread message

Samuel Johnson

unread,
Oct 18, 2021, 6:00:04 PM10/18/21
to TMB Users
Hi friends,

Anyone have any experience using TMB on M1 Mac hardware? I'm looking for positive and negative experiences.

Thanks!
Sam

Mollie Brooks

unread,
Oct 20, 2021, 9:40:16 AM10/20/21
to Samuel Johnson, TMB Users
Hi Sam,

I recently updated to an M1 Mac. I haven’t had time to test timing, OpenMP, etc., but I got it working. In general, I followed the steps described here http://yiqingxu.org/public/BigSurError.pdf 

In step 4.1 it should say "gcc --version" but the formatting did something. 

In step 5, it’s important to read where it says "Note that “x86_64- apple-darwin20/10.2.0” can be different for you." Mine is "aarch64-apple-darwin20/11.0.0", but yours might be different. Look what’s in "/usr/local/gfortran/lib/gcc/".

I’ll report back when I get into OpenMP, but I would be happy to hear if someone else already did this.

cheers,
Mollie


--
To post to this group, send email to us...@tmb-project.org. Before posting, please check the wiki and issuetracker at https://github.com/kaskr/adcomp/. Please try to create a simple repeatable example to go with your question (e.g issues 154, 134, 51). Use the issuetracker to report bugs.
---
You received this message because you are subscribed to the Google Groups "TMB Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tmb-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/tmb-users/4130c885-14cf-4b36-9c66-b1d52877285bn%40googlegroups.com.

Samuel Johnson

unread,
Nov 1, 2021, 4:05:56 PM11/1/21
to TMB Users
Thanks Mollie, I appreciate the info.

I'm getting an M1 Max mac this weekend, and will be putting it through its paces. My plan is to attempt to get all the software I use for work going without resorting to emulation of an i386 architecture, and comparing performance with my older i7 model and my colleague's i9. Stay tuned for updates on timing. Based on those results, I'll choose between the M1 Max and the i9.

For the wider community, if you have some TMB models that are particularly resource intensive, and use some TMB features that are somewhat uncommon, I'd be happy to try running them and timing them out for benchmarking on the new macs over the next week or so.

Sam

Mikael Jagan

unread,
Nov 30, 2021, 2:15:05 PM11/30/21
to TMB Users
Late to the thread. FWIW, I've been using TMB with OpenMP support on an M1 Mac for several months now, since before CRAN started releasing prebuilt native R binaries. To get it all to work at the time, I had to piece together from different sections of R-admin and R-exts how to build R from sources, with OpenMP support enabled for package installation by default. I documented everything here, and this continues to be workflow that I use to (re)install R on my machine.

Installing R from sources is no longer necessary now that CRAN is releasing native binaries. Currently, what I believe you need to install TMB with OpenMP support are:

(1) A native build of R ... CRAN binary can be downloaded here.

(2) Command Line Tools ... Running

xcode-select --install

on the command line will install the most recent version if you do not have any version installed.

(3) A C/C++ compiler with OpenMP support ... The Apple clang toolchain does not support OpenMP. R-admin suggests as an alternative the LLVM clang toolchain, which you can install (if you use Homebrew) by running

brew update
brew install llvm

Mollie's link suggests using the gcc and g++ provided with the experimental gfortran build from fxcoudert. I'd be curious if people's experiences vary there. LLVM clang may have better warranty...

(4) A $(HOME)/.R/Makevars file specifying compilers and compilation flags that R should use to compile R packages. Here is a provisional version that ought to be sufficient for TMB installation (assuming you have done 1-3):

LIBS_DIR=/opt/R/arm64
LLVM_DIR=/opt/homebrew/opt/llvm
SDK_PATH=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk

CC="${LLVM_DIR}/bin/clang -isysroot ${SDK_PATH} -target arm64-apple-macos11"
CXX="${LLVM_DIR}/bin/clang++ -isysroot ${SDK_PATH} -target arm64-apple-macos11"

CFLAGS="-falign-functions=8 -g -O2 -Wall -pedantic -Wno-implicit-function-declaration"
CXXFLAGS="-g -O2 -Wall -pedantic"

SHLIB_OPENMP_CFLAGS=-fopenmp
SHLIB_OPENMP_CXXFLAGS=-fopenmp

CPPFLAGS="-I${LLVM_DIR}/include -I${LIBS_DIR}/include"
LDFLAGS="-L${LLVM_DIR}/lib -L${LIBS_DIR}/lib"

I haven't tested this recently, so no warranty, as usual... If anyone gets to try before me, then let me know how it goes. If I try and find that these instructions still work (at least on my system), then I'll throw them on GitHub and link here.

Mikael

Samuel Johnson

unread,
Nov 30, 2021, 2:55:05 PM11/30/21
to TMB Users
Mikael, this is great!

Thanks for the input. I do indeed have TMB running on my new M1 machine. I installed the ARM native R from Homebrew, and found that the Mac compilers were fine for getting TMB running without openMP.

I will be attempting this over the weekend when I've cleared some time-sensitive tasks. I've attempted getting openMP running on my old mac once before, and couldn't seem to get it working, so I'm keen to try your method!

Sam

Mikael Jagan

unread,
Nov 30, 2021, 4:38:27 PM11/30/21
to TMB Users
The provisional Makevars in my last message was causing compilation errors. Removing the double quotes around the flags fixed the issue. The instructions work for me! I just successfully installed TMB with OpenMP support enabled, on a CRAN build of R running on an M1 Mac. Updated instructions are available here:


Mikael

Mikael Jagan

unread,
Feb 9, 2022, 3:10:19 PM2/9/22
to TMB Users
Links to my GitHub might be dead now. I have posted new, streamlined instructions here: https://stackoverflow.com/questions/70638118 ...

Mikael
Reply all
Reply to author
Forward
0 new messages