Skip to content

Commit

Permalink
Darwin/ARM64: Set default mcpu target (#36624)
Browse files Browse the repository at this point in the history
And unconditionally require the CRC32 extension on this platform.
All current and future chips should have it.
  • Loading branch information
Keno authored Jul 13, 2020
1 parent 110765a commit 1eb8bb5
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
9 changes: 9 additions & 0 deletions Make.inc
Original file line number Diff line number Diff line change
Expand Up @@ -777,6 +777,11 @@ ifeq ($(ARCH),amd64)
override ARCH := x86_64
endif

# We map arm64 (Apple spelling) to aarch64 to avoid having to deal with both spellings everywhere
ifeq ($(ARCH),arm64)
override ARCH := aarch64
endif

ifeq ($(ARCH),i386)
BINARY:=32
ISX86:=1
Expand Down Expand Up @@ -853,6 +858,10 @@ endif
ifneq (,$(findstring aarch64,$(ARCH)))
OPENBLAS_DYNAMIC_ARCH:=0
OPENBLAS_TARGET_ARCH:=ARMV8
ifeq ($(OS),Darwin)
# Apple Chips are all at least A12Z
MCPU:=apple-a12
endif
endif

# Set MARCH-specific flags
Expand Down
10 changes: 8 additions & 2 deletions src/crc32c.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
#include "julia_internal.h"
#include "processor.h"

#ifdef _CPU_AARCH64_
#if defined(_CPU_AARCH64_) && defined(_OS_LINUX_)
# include <sys/auxv.h>
#endif

Expand Down Expand Up @@ -331,7 +331,11 @@ JL_DLLEXPORT uint32_t jl_crc32c(uint32_t crc, const char *buf, size_t len)
{
return crc32c_armv8(crc, buf, len);
}
# else
# elif defined(_OS_DARWIN_)
// All Apple chips that run Darwin should have crc32 support.
// If that ever changes for some reason, this could be detected via the hw.optional.crc32 sysctl
# error Darwin/ARM64, but no CRC32 support?
# elif defined(_OS_LINUX_)
static crc32c_func_t crc32c_dispatch(unsigned long hwcap)
{
if (hwcap & (1 << JL_AArch64_crc))
Expand All @@ -341,6 +345,8 @@ static crc32c_func_t crc32c_dispatch(unsigned long hwcap)
// For ifdef detection below
# define crc32c_dispatch() crc32c_dispatch(getauxval(AT_HWCAP))
# define crc32c_dispatch_ifunc "crc32c_dispatch"
# else
# warning CRC32 feature detection not implemented for this OS. Falling back to software version.
# endif
#else
// If we don't have any accelerated version to define, just make the _sw version define
Expand Down

0 comments on commit 1eb8bb5

Please sign in to comment.