-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Set -march/mcpu to native when building the runtime if no targets are set #50031
Conversation
CC += -mtune=$(MTUNE) | ||
CXX += -mtune=$(MTUNE) | ||
FC += -mtune=$(MTUNE) | ||
JULIA_CPU_TARGET ?= $(MTUNE) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the only thing I'm unsure about; can JULIA_CPU_TARGET
take anything MTUNE
can? Also, if the user set MARCH
but not MTUNE
, should we set JULIA_CPU_TARGET
to something?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
MTUNE
behaves the same as MCPU
so I assume so. And also maybe incorrectly if we set MARCH
we just pass it to JULIA_CPU_TARGET.
I think they're all supported because it get's passed into a clang like command line.
|
||
#If nothing is set default to native | ||
ifeq ($(MARCH)$(MCPU)$(MTUNE)$(JULIA_CPU_TARGET),) | ||
MARCH=native |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think march=native doesn't exist on aarch64?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this was an M1 issue but I have to check.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, I don't have a reference at hand on the phone, but on aarch64 you shouldn't set march at all, that's wrong (besides march=native specifically giving an error)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With apple clang 14 it built fine but not sure for other versions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is about mtune Vs march in general: https://lemire.me/blog/2018/07/25/it-is-more-complicated-than-i-thought-mtune-march-in-gcc/. But I'm pretty sure there was something about aarch64 specifically. In BinaryBuilder we don't use march for many arm targets https://github.com/JuliaPackaging/BinaryBuilderBase.jl/blob/8ce1e2700dae921aff69cd12b9aef4429913e90c/src/Platforms.jl#L118-L173
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From ARM itself they say march is fine.
As long as you’re not cross compiling, the simplest and easiest way to get the best performance on Arm with both GNU compilers and LLVM-compilers is to use only -mcpu=native and actively avoid using -mtune or -march.
-march=X: Tells the compiler that X is the minimal architecture the binary must run on. The compiler is free to use architecture-specific instructions. This flag behaves differently on Arm and x86. On Arm, -march does not override -mtune, but on x86 -march will override both -mtune and -mcpu.
-mtune=X: Tells the compiler to optimize for microarchitecture X but does not allow the compiler to change the ABI or make assumptions about available instructions. This flag has the more-or-less the same meaning on Arm and x86.
-mcpu=X: On Arm, this flag is a combination of -march and -mtune. It simultaneously specifies the target architecture and optimizes for a given microarchitecture. On x86 this flag is a deprecated synonym for -mtune.
Good to go? |
IMO yes, it's probably not going to affect many people, but for those who build from source it might. |
Let's try it then |
@vchuravy noted that we don't set these flags even when building locally, even though we set the sysimg to
native
. This probably doesn't make too much of a difference but it might save a couple % on from source builds.Also add the option to set
mtune
which is what GCC wants