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

Porting an application to Mac M1 #502

Closed
runburg opened this issue Nov 13, 2021 · 11 comments
Closed

Porting an application to Mac M1 #502

runburg opened this issue Nov 13, 2021 · 11 comments

Comments

@runburg
Copy link

runburg commented Nov 13, 2021

Hi, So I don't know very much about this so my question might be really straightforward to solve. I'm trying to port a cpp to Mac M1 and ran into the issue of not having <mmintrin.h>. So I found this project and thought it would be as straightforward as adding the header file and the compilation flag for ARMv8. But so far I've been thwarted.

I'm getting a bunch of errors. The first one is Unsupported target. Must be either ARMv7-A+NEON or ARMv8-A.. From what I can tell, this is getting thrown because I haven't defined the target correctly, but I'm a little mystified by what this means. Can someone point me to a resource to understand this? I'm on Mac M1 using clang v13 if that's useful.

I'm also getting a lot of unknown type names and use of undeclared identifiers. Any help is much appreciated thanks!

@jserv
Copy link
Member

jserv commented Nov 13, 2021

Hello @runburg! Thanks for your interest in SSE2NEON Project. Take smartdenovo for example. It can be ported to Apple M1 easily with SSE2NEON. Here are the instructions:

git clone https://github.com/ruanjue/smartdenovo
cd smartdenovo
wget https://raw.githubusercontent.com/spack/spack/95ad5b882c990971e74d04261a665ba680f7c4be/var/spack/repos/builtin/packages/smartdenovo/aarch64.patch
patch -p1 < aarch64.patch
wget https://raw.githubusercontent.com/DLTcollab/sse2neon/master/sse2neon.h
make

Then, you will get several executable files such as wtext.

$ file wtext
wtext: Mach-O 64-bit executable arm64

The above were verified on macOS Monterey. Please submit the corresponding issues if any.

@runburg
Copy link
Author

runburg commented Nov 13, 2021

Sorry. I think my comment was not very clear or maybe I'm misunderstanding your comment. I am trying to do the port myself (change includes and add the header files).

What I'm confused about is why I'm seeing the unsupported target message. It seems that I haven't defined certain macros (clang for example) correctly, but I'm new to these kinds of projects so I don't understand where or to what I'm supposed set these macros as.

@jserv
Copy link
Member

jserv commented Nov 13, 2021

What I'm confused about is why I'm seeing the unsupported target message. It seems that I haven't defined certain macros (clang for example) correctly, but I'm new to these kinds of projects so I don't understand where or to what I'm supposed set these macros as.

Can you show me the instructions to reproduce?

@runburg
Copy link
Author

runburg commented Nov 13, 2021

I'll try to come up with a MWE but it may take me a while since the project is pretty sprawling and I don't know which parts are creating this error.

The error I'm getting is from line 118 of sse2neon.h. From what I can tell the macros are not getting defined correctly so the target is not being set correctly. I don't know how the macros should be set on M1 Mac using clang.

@jserv
Copy link
Member

jserv commented Nov 14, 2021

I'll try to come up with a MWE but it may take me a while since the project is pretty sprawling and I don't know which parts are creating this error.

The error I'm getting is from line 118 of sse2neon.h. From what I can tell the macros are not getting defined correctly so the target is not being set correctly. I don't know how the macros should be set on M1 Mac using clang.

Hint: You can get the predefined macros by running gcc -dM -E - < /dev/null | grep -i arm command. Also, please show the version of command line tools for your macOS environment.

@runburg
Copy link
Author

runburg commented Nov 14, 2021

❯ clang -dM -E - < /dev/null | grep -i arm
#define ARM64_ARCH_8 1
#define __ARM_64BIT_STATE 1
#define __ARM_ACLE 200
#define __ARM_ALIGN_MAX_STACK_PWR 4
#define __ARM_ARCH 8
#define ARM_ARCH_8_3 1
#define ARM_ARCH_8_4 1
#define ARM_ARCH_8_5 1
#define __ARM_ARCH_ISA_A64 1
#define __ARM_ARCH_PROFILE 'A'
#define __ARM_FEATURE_ATOMICS 1
#define __ARM_FEATURE_CLZ 1
#define __ARM_FEATURE_COMPLEX 1
#define __ARM_FEATURE_CRC32 1
#define __ARM_FEATURE_CRYPTO 1
#define __ARM_FEATURE_DIRECTED_ROUNDING 1
#define __ARM_FEATURE_DIV 1
#define __ARM_FEATURE_DOTPROD 1
#define __ARM_FEATURE_FMA 1
#define __ARM_FEATURE_FP16FML 1
#define __ARM_FEATURE_FP16_SCALAR_ARITHMETIC 1
#define __ARM_FEATURE_FP16_VECTOR_ARITHMETIC 1
#define __ARM_FEATURE_IDIV 1
#define __ARM_FEATURE_JCVT 1
#define __ARM_FEATURE_LDREX 0xF
#define __ARM_FEATURE_NUMERIC_MAXMIN 1
#define __ARM_FEATURE_QRDMX 1
#define __ARM_FEATURE_UNALIGNED 1
#define __ARM_FP 0xE
#define __ARM_FP16_ARGS 1
#define __ARM_FP16_FORMAT_IEEE 1
#define __ARM_NEON 1
#define __ARM_NEON_FP 0xE
#define ARM_NEON 1
#define __ARM_PCS_AAPCS64 1
#define __ARM_SIZEOF_MINIMAL_ENUM 4
#define __ARM_SIZEOF_WCHAR_T 4
#define __arm64 1
#define arm64 1

❯ xcode-select -v
xcode-select version 2384

I'm on Big Sur 11.6 if that's necessary

@jserv
Copy link
Member

jserv commented Nov 14, 2021

❯ xcode-select -v xcode-select version 2384
I'm on Big Sur 11.6 if that's necessary

It seems to be fine according to the above results. Then, we need a test program to reproduce. Please provide for further investigation.

@dropdeadrus
Copy link

I've encountered almost the same issues with clang; using gcc+11 compiler instead of clang solved them.

@jserv
Copy link
Member

jserv commented Nov 28, 2021

I've encountered almost the same issues with clang; using gcc+11 compiler instead of clang solved them.

@dropdeadrus, Can you share the instructions to reproduce clang specific issues? Thanks.

@jserv
Copy link
Member

jserv commented Jan 29, 2022

No further information. Closing.

@jserv jserv closed this as completed Jan 29, 2022
@benoithudson
Copy link

FYI I just got this error due to trying to do a universal build (x86_64 and arm64). Switching to a strictly arm64 build fixed it.

ddennedy referenced this issue in georgmartius/vid.stab Jan 10, 2024
Added sse2neon for arm compilation.
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

No branches or pull requests

4 participants