PyMFEM icon indicating copy to clipboard operation
PyMFEM copied to clipboard

PyMFEM on M1

Open jbschroder opened this issue 3 years ago • 3 comments

Hi All,

First, thank you for PyMFEM! I use it on ubuntu, and it's great. But, I'm having issues installing on an M1 Mac, with homebrew underneath.

First, I had to update the CMakeLists.txt that appears in external/mfem/miniapps/performance to use
-mcpu=apple-m1 instead of -march=native

And that resolved a clang error. But, now while installing, it seems that I've hit a Swig bug ( I think).

++++++++++++++++ array_wrap.cxx:3377:42: error: no matching constructor for initialization of 'mfem::Array' result = (mfem::Array< int > *)new mfem::Array< int >(arg1,arg2); ^ ~~~~~~~~~ /Users/jacobschroder/.local/lib/ser/include/mfem/general/array.hpp:76:11: note: candidate constructor not viable: no known conversion from 'int' to 'int *' for 1st argument; take the address of the argument with & inline Array(T *data_, int asize) ^ /Users/jacobschroder/.local/lib/ser/include/mfem/general/array.hpp:67:11: note: candidate constructor not viable: requires single argument 'mt', but 2 arguments were provided inline Array(MemoryType mt) : size(0) { data.Reset(mt); } ^ /Users/jacobschroder/.local/lib/ser/include/mfem/general/array.hpp:70:20: note: candidate constructor not viable: requires single argument 'asize', but 2 arguments were provided explicit inline Array(int asize) ^ /Users/jacobschroder/.local/lib/ser/include/mfem/general/array.hpp:81:11: note: candidate constructor not viable: requires single argument 'src', but 2 arguments were provided inline Array(const Array &src); ^ /Users/jacobschroder/.local/lib/ser/include/mfem/general/array.hpp:85:11: note: candidate constructor template not viable: requires single argument 'src', but 2 arguments were provided inline Array(const Array<CT> &src); ^ /Users/jacobschroder/.local/lib/ser/include/mfem/general/array.hpp:89:20: note: candidate constructor template not viable: requires single argument 'values', but 2 arguments were provided explicit inline Array(const CT (&values)[N]); ^ /Users/jacobschroder/.local/lib/ser/include/mfem/general/array.hpp:64:11: note: candidate constructor not viable: requires 0 arguments, but 2 were provided inline Array() : size(0) { data.Reset(); }

Anyway, I'm installing only PyMFEM serial from the current repo head with $ python3 setup.py install --prefix=~/.local/lib/ --CC=gcc --CXX=g++ And my Swig is version 4.02 from Homebrew. +++++++++++++

Any advice would be much appreciated!

jbschroder avatar Dec 10 '21 00:12 jbschroder

Did you clone it from github? If so, --mfem-branch=master flag is necessary, as shown in front page README. If you haven't done this, please try it. Besides, thank you for testing it and reporting the necessary change for M1.

sshiraiwa avatar Dec 10 '21 13:12 sshiraiwa

Hi,

No, I hadn't been using the master flag. Somehow I missed that on the front page. Sorry about that. I manage to get ex1.py running properly with the following,

  • clone from website
  • python3 setup.py install --prefix=~/.local/ --CC=gcc --CXX=g++ --mfem-branch=master
  • replace " -march=native " with " -mcpu=apple-m1 " in external/mfem/miniapps/performance/CMakeLists.txt
  • python3 setup.py install --prefix=~/.local --CC=gcc --CXX=g++

It seems the only real issue is Clang on M1 macs not supporting (at least yet) the native architecture flag, although the mcpu flag accomplishes a similar optimization (I think)(.

Cool! I look forward to using PyMFEM on my new Mac.

Thanks for the quick response!

Jacob

On Fri, Dec 10, 2021 at 7:00 AM sshiraiwa @.***> wrote:

Did you clone it from github? If so, --mfem-branch=master flag is necessary, as shown in front page README. If you haven't done this, please try it. Besides, thank you for testing it and reporting the necessary change for M1.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/mfem/PyMFEM/issues/113#issuecomment-990996582, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABEMHYYJWEUAT2CQMTOVGULUQIBWPANCNFSM5JX3AIEQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

jbschroder avatar Dec 10 '21 15:12 jbschroder

Hi @jbschroder,

Do you want to add a fix for this in mfem, similar to https://github.com/mfem/mfem/pull/2273?

Tzanio

tzanio avatar Dec 10 '21 18:12 tzanio