M1 Mac for code development

Hello,

I have been using a very old Mac (MacMini (2012 model)) for a long time, but because it cannot install newer MacOS anymore (beyond Catalina) + the machine becomes very hot in summer, I am thinking about buying new Mac with M1 chip. But I am worried about to what extent it can be used practically for code development, because compilers may be still “experimental” and also I sometimes see user reports about runtime issues. Also, there are a lot of products with different number of “P/E-cores” (with different prices), but I am not sure whether I can make good use of them in parallel (e.g. via OpenMP).

So I am wondering…

  • Even if compilers do not support M1 natively, is it possible to use “Rosetta” (= Intel emulator) to run any Intel-based compilers on M1 always (including Gfortran and IntelFortran/OneAPI)? In that case, is it okay to assume that I can compile existing program packages (in Fortran/C/C++) and run them in parallel via Rosetta? If this is possible, I think getting a machine with more cores would be useful, but if Rosetta does not support multi-threaded programs (for example), machines with fewer cores may be more reasonable (for cost performance).

  • The products have “Pro” and “Max” series with 200 and 400 GB/s bandwidth, respectively. I am wondering to what extent the above difference can be significant for numerical calculations. For example, even a very simple PDE (like diffusion equations) can benefit from the greater bandwidth of “Max”, or is the speed gain typically not so much because of other possible bottlenecks etc…?

  • Newer Mac products have different numbers of “P-cores” (performance) and “E-cores” (efficiency) in a single CPU. For numerical calculations, does the performance determined practically by P-cores rather than E-cores? (So for example, if a machine has 6 P-cores, is it okay to expect that parallel performance can scale up to 6 cores, but tends to degrade when E-cores start to be used?)

Because I have no experience with M1 Mac, I would really appreciate any comments/information/experience about these questions.
Thanks much!

1 Like

Yeah I have roughly similar question.

I think there are M1 compatible gfortran version already. But intel OneAPI I do not know if it can be run on M1 chip. Perhaps Dr. Fortran @sblionel could give some hints?

1 Like

The Intel compilers do not generate code for ARM. While you might be able to install the oneAPI compiler on an M1 Mac, at best it would generate x86 binaries which would not get the most out of the processor. If gfortran does what you need, it would be the better direction.

It would not astonish me if Intel decided to drop its Mac product in the next year or two, as Apple moves entirely to ARM.

2 Likes

NAG has their compiler ready; I have not used it. gfortran is included in “brew”
➜ ~ gfortran --version
GNU Fortran (Homebrew GCC 11.2.0_3) 11.2.0

I have to confess as to not having answers to your questions, I haven’t been using this box for any meaningful development … nor is it likely anytime soon.

3 Likes

Thanks very much for your information!

It would not astonish me if Intel decided to drop its Mac product in the next year or two, as Apple moves entirely to ARM.

I am also afraid it can really happen because ARM is probably a competitor of Intel CPU. From a user side, I wish all the CPUs would converge to the same architecture, but the reality seems to be going the opposite…

I think there are M1 compatible gfortran version already.

NAG and gfortran in “brew” (GNU Fortran (Homebrew GCC 11.2.0_3) 11.2.0)

I remember having seen the news of native NAG compiler the last year, which is very nice. Also, if GCC-11 works on M1, that will be great (particularly with OpenMP works).

Actually, I was thinking about moving everything to Linux (including the desktop use), but because of the need of MS office, I am still considering Mac as an option for desktop… (And welcome to the forum!)

1 Like

I use a M1 Macbook air. I know @certik uses Apple Silicon as well.

I know about Questions 1 and 3.

  1. Gfortran generates native ARM code. It works with OpenMP. There are a few corner cases where Gfortran does not work properly. For example, currently, homebrew gfortran release so not work with nested functions. This has been fixed by GCC developers, but binaries are not released yet (see here). It sounds like a much updated Gfortran version should come out with the release of GCC 12, which I’ve heard somewhere should be around April 2022.

I have used Intel ifort compiler via rosetta. It seems to work. But I had issues with C/Fortran interoperability with the Intel compilers.

  1. I’ve done multithreading across all 8 cores on my M1. Seems to scale as well as my old intel with 6 cores. I haven’t look too carefully at this though.
4 Likes

I expect that too, but it is quite unfortunate. It may end up meaning I give up on Intel for all platforms. I definitely have Mac users i have to support, so if I go through all the work of switching to NAG or Gfortran on Mac and it works well enough, I’d probably just use it for all platforms to avoid the hassle. I think it just makes Ifort less relevant overall. Very unfortunate for the overall Fortran ecosystem, since they have had such a great cross-platform compiler for so long.

3 Likes

LFortran supports M1 natively. I use M1 to develop it. LFortran is still in alpha stage, our goal is to bring it to beta this year. I also use GFortran from Conda (conda-forge) and it generates native M1 code and it works great.

4 Likes

Thanks very much for this info! It is very nice to know that Gfortran works natively with OpenMP with good scaling, and the fix for nested functions is now on-going. So I’ve decided to buy a new one and try my codes (in addition to using it for office work as well).

@certik> LFortran supports M1 natively. I use M1 to develop it. LFortran is still in alpha stage, our goal is to bring it to beta this year. I also use GFortran from Conda (conda-forge) and it generates native M1 code and it works great.

Thanks very much! It is reassuring to hear that both LFortran and Gfortran support M1. I am looking forward to trying the beta version of LFortran once it becomes available :slight_smile: