Skip to content

Added support for ARM64/OpenCL (RC5-72) and ARM64 (OGR-NG & ANSI RC5-72) on macOS 11 (Apple Silicon) #16

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

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
Open
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ logfile*.log
trace.out

output/
.DS_Store
3 changes: 2 additions & 1 deletion common/clisync.h
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,8 @@
return 1;
}

#elif (CLIENT_CPU == CPU_X86) || (CLIENT_CPU == CPU_AMD64) || (CLIENT_CPU == CPU_CUDA) || (CLIENT_CPU == CPU_ATI_STREAM) || (CLIENT_CPU == CPU_OPENCL) || ((CLIENT_CPU == CPU_ARM) && !defined(__GNUC__))
#elif (CLIENT_CPU == CPU_X86) || (CLIENT_CPU == CPU_AMD64) || (CLIENT_CPU == CPU_CUDA) || (CLIENT_CPU == CPU_ATI_STREAM) || ((CLIENT_CPU == CPU_OPENCL) && !defined(__arm64__)) || \
((CLIENT_CPU == CPU_ARM) && !defined(__GNUC__)) || ((CLIENT_CPU == CPU_ARM64) && !defined(__GNUC__))

typedef volatile long fastlock_t;

Expand Down
8 changes: 6 additions & 2 deletions common/core_r72.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -207,11 +207,15 @@ const char **corenames_for_contest_rc572()
"KKS 2-pipe",
"AnBe 1-pipe",
"AnBe 2-pipe",
#elif (CLIENT_CPU == CPU_ARM64)
#elif (CLIENT_CPU == CPU_ARM64 && (CLIENT_OS != OS_MACOSX))
"ANSI 4-pipe",
"ANSI 2-pipe",
"ANSI 1-pipe",
"KS-ScalarFusion",
#elif (CLIENT_CPU == CPU_ARM64 && (CLIENT_OS == OS_MACOSX))
"ANSI 4-pipe",
"ANSI 2-pipe",
"ANSI 1-pipe",
#elif (CLIENT_CPU == CPU_MIPS)
"ANSI 4-pipe",
"ANSI 2-pipe",
Expand Down Expand Up @@ -1084,7 +1088,7 @@ int selcoreSelectCore_rc572(Client *client, unsigned int threadindex,
break;
#endif

#if (CLIENT_CPU == CPU_ARM64)
#if (CLIENT_CPU == CPU_ARM64 && (CLIENT_OS != OS_MACOSX))
case 3:
unit_func.gen_72 = rc5_72_unit_func_scalarfusion;
pipeline_count = 1;
Expand Down
21 changes: 12 additions & 9 deletions common/cputypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -438,31 +438,34 @@
#define HAVE_POSIX_THREADS
#endif
#elif defined(__APPLE__)
#if defined(__arm64__)
#define CLIENT_OS_NAME "iOS"
#define CLIENT_OS OS_IOS
#define CLIENT_CPU CPU_ARM64
#elif defined(__arm__) || defined(ARM)
#if defined (IOS)
#define CLIENT_OS_NAME "iOS"
#define CLIENT_OS OS_IOS
#define CLIENT_CPU CPU_ARM
#else
#define CLIENT_OS OS_MACOSX
#if defined(__arm64__)
#define CLIENT_OS_NAME "Mac OS X" // Added this incase we want to identify this as macOS 11 in the future.
#else
#define CLIENT_OS_NAME "Mac OS X"
#define CLIENT_OS OS_MACOSX
#endif
#endif
#endif
#ifndef __unix__
#define __unix__
#endif
#if defined(CUDA) && (defined(__i386__) || defined(__x86_64__))
#define CLIENT_CPU CPU_CUDA
#elif defined(OPENCL) && (defined(__i386__) || defined(__x86_64__))
#elif defined(OPENCL) && (defined(__i386__) || defined(__x86_64__) || defined(__arm64__))
#define CLIENT_CPU CPU_OPENCL
#elif defined(__ppc__) || defined(__ppc64__)
#define CLIENT_CPU CPU_POWERPC
#elif defined(__i386__) || defined(ASM_X86)
#define CLIENT_CPU CPU_X86
#elif defined(ASM_AMD64) || defined(__x86_64__) || defined(__amd64__)
#define CLIENT_CPU CPU_AMD64
#elif defined(__arm64__)
#define CLIENT_CPU CPU_ARM64
#elif defined(__arm__)
#define CLIENT_CPU CPU_ARM
#endif
#elif defined(__BEOS__) || defined(__be_os)
#ifndef __unix__ /* 4.4bsd compatible or not? */
Expand Down
34 changes: 29 additions & 5 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -530,9 +530,11 @@ add_sources() # $1=os, $2=arch, $3=custom
elif [ "$2" = "arm64" ]; then
if [ "$HAVE_RC5_72" = "1" ]; then
DEFAULT_RC5_72="1"
TARGET_ADDASMS="$TARGET_ADDASMS rc5-72/arm64/r72-ks-scalarfusion.S"
TARGET_ADDSRCS="$TARGET_ADDSRCS $OGR_GENERAL_SRCS rc5-72/arm64/r72-ks-scalarfusion.cpp"
fi # HAVE_RC5_72
if ["$1" -ne "macosx"]; then
TARGET_ADDASMS="$TARGET_ADDASMS rc5-72/arm64/r72-ks-scalarfusion.S"
TARGET_ADDSRCS="$TARGET_ADDSRCS $OGR_GENERAL_SRCS rc5-72/arm64/r72-ks-scalarfusion.cpp"
fi #if OSX
fi # HAVE_RC5_7

if [ "$HAVE_OGR" = "1" ]; then
DEFAULT_OGRNG="0" # don't add the 32-bit ansi core
Expand Down Expand Up @@ -1763,8 +1765,9 @@ case "$1" in

*ios-arm64) # [zebe] iOS 7+, 64-bit (Xcode >= 6 recommended)
TARGET_plat="-isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk -miphoneos-version-min=7.1 -DIPHONEOS_DEPLOYMENT_TARGET=7.1 -DTARGETED_DEVICE_FAMILY=\"1,2\" -arch arm64"
TARGET_CCFLAGS="$OPTS_CLANGCC -Os -DHAVE_POSIX_THREADS $TARGET_plat"
TARGET_CCFLAGS="$OPTS_CLANGCC -Os -DIOS -DHAVE_POSIX_THREADS $TARGET_plat"
TARGET_LIBS="-framework CoreFoundation"
TARGET_AS="gcc -c $TARGET_CCFLAGS"
TARGET_LDFLAGS="$TARGET_plat"
TARGET_IS_CROSSCOMPILE=1
TARGET_DOCFILES="docs/readme._ix" #platform specific docfile
Expand All @@ -1774,7 +1777,7 @@ case "$1" in

*ios-arm) # [zebe] iOS 5+, 32-bit (Xcode >= 5 recommended)
TARGET_plat="-isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk -miphoneos-version-min=5.1 -DIPHONEOS_DEPLOYMENT_TARGET=5.1 -DTARGETED_DEVICE_FAMILY=\"1,2\" -arch armv7"
TARGET_CCFLAGS="$OPTS_CLANGCC -Os -DHAVE_POSIX_THREADS $TARGET_plat"
TARGET_CCFLAGS="$OPTS_CLANGCC -Os -DIOS -DHAVE_POSIX_THREADS $TARGET_plat"
TARGET_LIBS="-framework CoreFoundation"
TARGET_LDFLAGS="$TARGET_plat"
TARGET_IS_CROSSCOMPILE=1
Expand All @@ -1783,6 +1786,17 @@ case "$1" in
add_sources "ios" "generic"
;;

*macosx-arm64)
TARGET_plat="-mmacosx-version-min=11.0 -DMACOSX_DEPLOYMENT_TARGET=11.0 -arch arm64"
TARGET_CCFLAGS="$OPTS_CLANGCC -DHAVE_POSIX_THREADS $TARGET_plat"
TARGET_AS="gcc -c $TARGET_CCFLAGS"
TARGET_LIBS="-framework CoreFoundation -framework IOKit"
TARGET_LDFLAGS="$TARGET_plat"
TARGET_TARBALL="macosx-arm64"
TARGET_DOCFILES="docs/readme._ix"
add_sources "macosx" "arm64"
;;

# IA64 *****************************************************************

*linux-ia64)
Expand Down Expand Up @@ -3491,6 +3505,16 @@ case "$1" in
add_sources "macosx" "opencl"
;;

*macosx-arm64-opencl) # macOS 11 64-bit, Darwin
TARGET_plat="-mmacosx-version-min=11.0 -DMACOSX_DEPLOYMENT_TARGET=11.0 -arch arm64"
TARGET_CCFLAGS="$OPTS_CLANGCC -DOPENCL -DDYN_TIMESLICE $TARGET_plat"
TARGET_LIBS="-framework IOKit -framework CoreFoundation -framework OpenCL"
TARGET_LDFLAGS="$TARGET_plat"
TARGET_DOCFILES="docs/readme._ix docs/readme.opencl" #platform specific docfile
TARGET_TARBALL="macosx-arm64-opencl"
add_sources "macosx" "opencl"
;;

###### Unknown
*list)
egrep "^[ ]*\*" $0 | grep -v internal | more
Expand Down
4 changes: 2 additions & 2 deletions plat/macosx/temperature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ static UInt32 _SMCread(UInt32 key, io_connect_t connection)
smc_input.key = key;
smc_input.cmd = SMC_READ_KEYINFO;

#if defined(__x86_64__)
#if defined(__x86_64__) || defined(__arm64__)
if (kIOReturnSuccess == IOConnectCallStructMethod(connection, 2,
&smc_input, input_size, &smc_output, &output_size)) {
#else
Expand All @@ -260,7 +260,7 @@ static UInt32 _SMCread(UInt32 key, io_connect_t connection)
if (smc_input.size == 0)
return 0; // Unknown key.

#if defined(__x86_64__)
#if defined(__x86_64__) || defined(__arm64__)
if (kIOReturnSuccess == IOConnectCallStructMethod(connection, 2,
&smc_input, input_size, &smc_output, &output_size)) {
#else
Expand Down
5 changes: 5 additions & 0 deletions rc5-72/arm64/r72-ks-scalarfusion.S
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,13 @@
// Returns completed A and B, needs C++ support file for final checks

.text
#if defined(__APPLE__)
.globl _scalarFusionEntry
_scalarFusionEntry:
#else
.globl scalarFusionEntry
scalarFusionEntry:
#endif
// push fp and lr
stp x29, x30, [sp, #-16]!

Expand Down