owl
owl copied to clipboard
Support Arm64 (and apple M1)
Resubmitting as requested
to try this PR on mac use
opam pin -n git+https://github.com/mseri/owl.git#arm64 --with-version=1.1.0
PKG_CONFIG_PATH="/opt/homebrew/opt/openblas/lib/pkgconfig" opam install owl.1.1.0
@jzstark can you test on both the mac and thinkpad. It seems I have some compilation issue on one of my thinkpads. I will also dig a bit deeper.
I tried compiling the code with this PR on my Ubuntu 20.04 desktop, and there are indeed errors and warnings; the current master branch compile normally. Part of the log are pasted below.
File "src/owl/dune", line 56, characters 3-17:
56 | owl_core_utils
^^^^^^^^^^^^^^
In file included from src/owl/core/owl_core.h:9,
from src/owl/core/owl_core_utils.c:6:
src/owl/core/owl_macros.h:90:6: error: #elif with no expression
src/owl/core/owl_core_utils.c:216:6: error: #elif with no expression
cc1: warning: unrecognized command line option ‘-Wno-logical-op-parentheses’
File "src/owl/dune", line 75, characters 3-22:
75 | owl_fftpack_float32
^^^^^^^^^^^^^^^^^^^
In file included from src/owl/core/owl_core.h:9,
from src/owl/fftpack/owl_fftpack_float32.c:8:
src/owl/core/owl_macros.h:90:6: error: #elif with no expression
cc1: warning: unrecognized command line option ‘-Wno-logical-op-parentheses’
File "src/owl/dune", line 76, characters 3-22:
76 | owl_fftpack_float64
^^^^^^^^^^^^^^^^^^^
In file included from src/owl/core/owl_core.h:9,
from src/owl/fftpack/owl_fftpack_float64.c:8:
src/owl/core/owl_macros.h:90:6: error: #elif with no expression
cc1: warning: unrecognized command line option ‘-Wno-logical-op-parentheses’
File "src/owl/dune", line 61, characters 3-28:
61 | owl_ndarray_contract_stub
^^^^^^^^^^^^^^^^^^^^^^^^^
In file included from src/owl/core/owl_core.h:9,
from src/owl/core/owl_ndarray_contract_stub.c:6:
src/owl/core/owl_macros.h:90:6: error: #elif with no expression
cc1: warning: unrecognized command line option ‘-Wno-logical-op-parentheses’
File "src/owl/dune", line 59, characters 3-24:
59 | owl_matrix_check_stub
^^^^^^^^^^^^^^^^^^^^^
In file included from src/owl/core/owl_core.h:9,
from src/owl/core/owl_matrix_check_stub.c:6:
src/owl/core/owl_macros.h:90:6: error: #elif with no expression
cc1: warning: unrecognized command line option ‘-Wno-logical-op-parentheses’
File "src/owl/dune", line 60, characters 3-23:
60 | owl_matrix_swap_stub
^^^^^^^^^^^^^^^^^^^^
...
I tried compiling the code with this PR on my Ubuntu 20.04 desktop, and there are indeed errors and warnings; the current master branch compile normally. Part of the log are pasted below.
File "src/owl/dune", line 56, characters 3-17: 56 | owl_core_utils ^^^^^^^^^^^^^^ In file included from src/owl/core/owl_core.h:9, from src/owl/core/owl_core_utils.c:6: src/owl/core/owl_macros.h:90:6: error: #elif with no expression src/owl/core/owl_core_utils.c:216:6: error: #elif with no expression cc1: warning: unrecognized command line option ‘-Wno-logical-op-parentheses’ File "src/owl/dune", line 75, characters 3-22: 75 | owl_fftpack_float32 ^^^^^^^^^^^^^^^^^^^ In file included from src/owl/core/owl_core.h:9, from src/owl/fftpack/owl_fftpack_float32.c:8: src/owl/core/owl_macros.h:90:6: error: #elif with no expression cc1: warning: unrecognized command line option ‘-Wno-logical-op-parentheses’ File "src/owl/dune", line 76, characters 3-22: 76 | owl_fftpack_float64 ^^^^^^^^^^^^^^^^^^^ In file included from src/owl/core/owl_core.h:9, from src/owl/fftpack/owl_fftpack_float64.c:8: src/owl/core/owl_macros.h:90:6: error: #elif with no expression cc1: warning: unrecognized command line option ‘-Wno-logical-op-parentheses’ File "src/owl/dune", line 61, characters 3-28: 61 | owl_ndarray_contract_stub ^^^^^^^^^^^^^^^^^^^^^^^^^ In file included from src/owl/core/owl_core.h:9, from src/owl/core/owl_ndarray_contract_stub.c:6: src/owl/core/owl_macros.h:90:6: error: #elif with no expression cc1: warning: unrecognized command line option ‘-Wno-logical-op-parentheses’ File "src/owl/dune", line 59, characters 3-24: 59 | owl_matrix_check_stub ^^^^^^^^^^^^^^^^^^^^^ In file included from src/owl/core/owl_core.h:9, from src/owl/core/owl_matrix_check_stub.c:6: src/owl/core/owl_macros.h:90:6: error: #elif with no expression cc1: warning: unrecognized command line option ‘-Wno-logical-op-parentheses’ File "src/owl/dune", line 60, characters 3-23: 60 | owl_matrix_swap_stub ^^^^^^^^^^^^^^^^^^^^ ...
Thanks to confirm, I saw the same error. Removing that option fixed some errors but there are still some other errors. Probably the main issue is using different version of OCaml. I will try to switch to another version later.
Super. I guess it depends on the compiler used. Does this new commit fix it?
Where does -Wno-logical-op-parentheses
come from? I did not add that anywhere
This fixes a lot of warnings, but the error is still there. (I use OCaml 4.14 and dune 3.0.3.)
dune build @install
File "src/owl/dune", line 56, characters 3-17:
56 | owl_core_utils
^^^^^^^^^^^^^^
src/owl/core/owl_core_utils.c:216:6: error: #elif with no expression
cc1: warning: unrecognized command line option ‘-Wno-logical-op-parentheses’
make: *** [Makefile:9: build] Error 1
-Wno-logical-op-parentheses
From here https://github.com/owlbarn/owl/blob/eead31f1920e63b876421e6a30e61c947f29827f/src/owl/config/configure.ml#L115
Actually, we can simply remove get_devmode_cflags, and move [ "-Wall"; "-pedantic"; "-Wextra"; "-Wunused" ] to https://github.com/owlbarn/owl/blob/eead31f1920e63b876421e6a30e61c947f29827f/src/owl/config/configure.ml#L253
I'll make the change, but that line is there from before my PR. It is strange that it fails now and was not failing before. It would be interesting to understand why
At some point we should probably get rid of (or rewrite) default_gcc_path
(outdated in most systems) and openblas_default
(can mix up x86_64 and arm64 libraries on mac for people using homebrew, which uses the old path for x86_64 and a new one, I think /opt/local, for arm64 libraries)
I have created the parent PR on eigen, with these the build should work fine on both M1 and x86_64. I am still having some linking issues with eigen since the last macos update.
I can no-longer test this, eigen fails to build for me with the lastest macos compiler upgrade
Update: I have made a new PR to update the current eigen.0.3.0 build (not using recent dune features which seem to produce linking errors) and backported a fix from eigen to build on clang 3.9. The new PR is here: https://github.com/owlbarn/eigen/pull/36 With that one I seem to be able to use eigen and owl on both macos x86_64 and macos M1
Any update regarding this PR? Now a number of users is using it without problems
It should also fix the linking on debian system which was broken in 1.0.2 in some cases
Any news on this? I have been using it fine on various different mac and linux intel and mac ARM cpus for weeks
opam pin -n git+https://github.com/mseri/owl.git#arm64 --with-version=1.1.0 PKG_CONFIG_PATH="/opt/homebrew/opt/openblas/lib/pkgconfig" opam install owl.1.1.0
This worked for me on a new M1 mac
I can confirm that this works perfectly well with my M1 Mac on macOS Monterey.
I've got:
# (cd _build/default && /Users/thomas/git/hdf5-ocaml/_opam/bin/ocamlmklib.opt -g -o src/owl/owl_stubs src/owl/SFMT.o src/owl/airy.o src/owl/airyf.o src/owl/bdtr.o src/owl/beta.o src/owl/btdtr.o src/owl/cbrt.o src/owl/chbevl.o src/owl/chbevlf.o src/owl/chdtr.o src/owl/const.o src/owl/constf.o src/owl/dawsn.o src/owl/dawsnf.o src/owl/ellie.o src/owl/ellik.o src/owl/ellpe.o src/owl/ellpj.o src/owl[...]
# ld: file not found: @rpath/libquadmath.0.dylib for architecture arm64
Something is off with homebrew. For a similar issue with libgcc one needs to manually fix some paths or create special symlinks
On my Intel mac the installation procedure in the top post is not working. macos 12.6.2. my homebrew installation of openblas says
For compilers to find openblas you may need to set:
export LDFLAGS="-L/usr/local/opt/openblas/lib"
export CPPFLAGS="-I/usr/local/opt/openblas/include"
For pkg-config to find openblas you may need to set:
export PKG_CONFIG_PATH="/usr/local/opt/openblas/lib/pkgconfig"
so the path is a different one. also, my gfortran libquadmath is in /usr/local/gfortran/lib
Needless to say, the current opam version of owl is also not building.
This is still failing for me with:
> clang-11: error: the clang compiler does not support '-mcpu=apple-m1'
Try now: -march=native
is supported on mac arm for recent enough macos, I modified the code to use that
Thank you, it does work now.
Running this on an M3 macOS Sonoma 14.2.1 I get this error:
File "_none_", line 1:
Error: No implementations provided for the following modules:
Unix referenced from /Users/tsmc/code/ocaml/par-matmul-profiling/_opam/lib/owl-base/owl_base.cmxa(Owl_utils),
/Users/tsmc/code/ocaml/par-matmul-profiling/_opam/lib/owl-base/owl_base.cmxa(Owl_log),
/Users/tsmc/code/ocaml/par-matmul-profiling/_opam/lib/owl-base/owl_base.cmxa(Owl_io)
Test case setting up https://github.com/ghennequin/par-matmul-profiling. If you rebase including commits from https://github.com/owlbarn/owl/pull/630 then it works well. To test try using:
opam pin -n git+https://github.com/tmcgilchrist/owl.git#arm64 --with-version=1.1.0
PKG_CONFIG_PATH="/opt/homebrew/opt/openblas/lib/pkgconfig" opam install owl.1.1.0
What is required to get this merged and a release of Owl for MacOS/ARM64 onto opam?
I have merged main to fix the merge conflicts
@jzstark any progress on getting ARM64 support merged?
This would be a good sign that owl is indeed being actively maintained, now that the project conclusion was reverted.