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

fix: enable native optimization only on x64 #98

Merged
merged 1 commit into from
Mar 7, 2022
Merged

fix: enable native optimization only on x64 #98

merged 1 commit into from
Mar 7, 2022

Conversation

aminya
Copy link
Owner

@aminya aminya commented Mar 6, 2022

Fixes #96

@aminya aminya added the bug Something isn't working label Mar 6, 2022
@ljishen
Copy link

ljishen commented Mar 6, 2022

Would you like to use the trial-and-error approach so that you won't sacrifice the possibility of applying the optimization?

@aminya
Copy link
Owner Author

aminya commented Mar 6, 2022

If there is a deterministic and cross-platform way to do this, I will be open to doing that.

GCC has a separate set of options for different architectures.
https://gcc.gnu.org/onlinedocs/gcc/Submodel-Options.html#Submodel-Options

It specifies -march=native in the arm options section, but it didn't work inside Godbolt.
https://gcc.gnu.org/onlinedocs/gcc/ARM-Options.html#ARM-Options

@aminya
Copy link
Owner Author

aminya commented Mar 6, 2022

For Clang, I see the code for it here: Not sure why it is not enabled though
https://github.com/llvm/llvm-project/blob/17a68065c378da74805e4e1b9a5b78cc9f83e580/clang/lib/Driver/ToolChains/Arch/ARM.cpp#L893

@aminya
Copy link
Owner Author

aminya commented Mar 6, 2022

For M1 Mac, it is under review:
https://reviews.llvm.org/D119788

@ljishen
Copy link

ljishen commented Mar 7, 2022

If there is a deterministic and cross-platform way to do this, I will be open to doing that.

GCC has a separate set of options for different architectures. https://gcc.gnu.org/onlinedocs/gcc/Submodel-Options.html#Submodel-Options

It specifies -march=native in the arm options section, but it didn't work inside Godbolt. https://gcc.gnu.org/onlinedocs/gcc/ARM-Options.html#ARM-Options

I think a cross-platform solution without user input is almost impossible. A deterministic solution is also hard given the continuous (micro)architecture innovations for different CPUs, both GCC and clang are just keep incorporating the new changes. Therefore, I think a trial-and-error approach may be a better option for guiding in this situation, ie, test the flag before applying. I've tested on my ARM machine with the -mcpu=native on GCC and clang, both of them work.

As a relevant suggestion, we may set up an ARM-based environment using the Oracle A1 Instances (which says "Always Free") for better testing this project.

@aminya
Copy link
Owner Author

aminya commented Mar 7, 2022

Yeah, if a trial and error solution is available I am open to adding it.

@aminya aminya merged commit d73c1d1 into main Mar 7, 2022
@aminya aminya deleted the native-fix branch March 7, 2022 03:12
@aminya
Copy link
Owner Author

aminya commented Mar 7, 2022

Changed #96 to reflect this.

@ljishen
Copy link

ljishen commented Mar 7, 2022

Yeah, if a trial and error solution is available I am open to adding it.

For GCC and clang, we can use [gcc/clang] -Werror [the test flag] -E -xc /dev/null and check the return code.
For example, [gcc/clang] -Werror -march=native -E -xc /dev/null or [gcc/clang] -Werror -mcpu=native -E -xc /dev/null.

I guess MSVC will have a similar way to test, but I don't have the environment for testing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Test '-march=native' support for all architectures and platforms
2 participants