From 9918d667e38327d7e6ed536c32483a6e7a7044aa Mon Sep 17 00:00:00 2001 From: Joshua Morgan Date: Sat, 28 Nov 2020 15:07:52 +1030 Subject: [PATCH 01/14] Update temperature.cpp to support arm64 --- plat/macosx/temperature.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/plat/macosx/temperature.cpp b/plat/macosx/temperature.cpp index 6db8f8590..50423756e 100644 --- a/plat/macosx/temperature.cpp +++ b/plat/macosx/temperature.cpp @@ -246,7 +246,10 @@ 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__) + if (kIOReturnSuccess == IOConnectCallStructMethod(connection, 2, + &smc_input, input_size, &smc_output, &output_size)) { +#elif defined(__arm64__) if (kIOReturnSuccess == IOConnectCallStructMethod(connection, 2, &smc_input, input_size, &smc_output, &output_size)) { #else @@ -263,6 +266,9 @@ static UInt32 _SMCread(UInt32 key, io_connect_t connection) #if defined(__x86_64__) if (kIOReturnSuccess == IOConnectCallStructMethod(connection, 2, &smc_input, input_size, &smc_output, &output_size)) { +#elif defined(__arm64__) + if (kIOReturnSuccess == IOConnectCallStructMethod(connection, 2, + &smc_input, input_size, &smc_output, &output_size)) { #else if (kIOReturnSuccess == IOConnectMethodStructureIStructureO(connection, 2, input_size, &output_size, &smc_input, &smc_output)) { From 8abb18846172af7ad12cc4e717217415fe8929b8 Mon Sep 17 00:00:00 2001 From: Joshua Morgan Date: Sat, 28 Nov 2020 16:12:34 +1030 Subject: [PATCH 02/14] Update .gitignore Added .DS_Store to .gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 5633a9b27..a01d58d23 100644 --- a/.gitignore +++ b/.gitignore @@ -19,3 +19,4 @@ logfile*.log trace.out output/ +.DS_Store From aacce904c1a25abb9641160395c2e7dfc39e810d Mon Sep 17 00:00:00 2001 From: Joshua Morgan Date: Sat, 28 Nov 2020 17:40:08 +1030 Subject: [PATCH 03/14] Update clisync.h It doesn't seem arm64 & OpenCL was originally planned. Added an exception for ARM64 & OpenCL. --- common/clisync.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/clisync.h b/common/clisync.h index 8c3c85158..78fb030cc 100644 --- a/common/clisync.h +++ b/common/clisync.h @@ -182,7 +182,7 @@ 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__)) typedef volatile long fastlock_t; From ab03bb7921b18125e9ebe5c9772975e8f0a36acd Mon Sep 17 00:00:00 2001 From: Joshua Morgan Date: Sat, 28 Nov 2020 17:41:59 +1030 Subject: [PATCH 04/14] Update configure Update to configure to include macosx-arm64-opencl. Although arm64 support is macOS 11 is technically in macOS 11 not Mac OS X, it has more in common. Consider adding a new OS to the list and updating. --- configure | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/configure b/configure index 639165625..32932eb07 100755 --- a/configure +++ b/configure @@ -120,7 +120,7 @@ OGR="ogr" # select the projects to include in the client HAVE_RC5_72="1" -HAVE_OGR="1" +HAVE_OGR="0" HAVE_OGR_P2="0" # define these to "0" in add_sources() if you add your own list of cores + options @@ -3491,6 +3491,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" "arm64" + ;; + ###### Unknown *list) egrep "^[ ]*\*" $0 | grep -v internal | more From f94435d066b03521add39f2f9c5285dc6cf1a6c4 Mon Sep 17 00:00:00 2001 From: Joshua Morgan Date: Sat, 28 Nov 2020 17:55:53 +1030 Subject: [PATCH 05/14] Update cputypes.h Added OPENCL and ARM64 as a vaild combination. --- common/cputypes.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/cputypes.h b/common/cputypes.h index 8839f24ec..8a83d1c74 100644 --- a/common/cputypes.h +++ b/common/cputypes.h @@ -455,7 +455,7 @@ #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 From 554155d685d66debf9adb8a8f451bb2fa0ab1e43 Mon Sep 17 00:00:00 2001 From: Joshua Morgan Date: Sat, 28 Nov 2020 18:02:43 +1030 Subject: [PATCH 06/14] Update cputypes.h Added a (bad) assumption that if you're using an Apple arm64 processor with OpenCL it's not iOS. --- common/cputypes.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/cputypes.h b/common/cputypes.h index 8a83d1c74..9beb4a910 100644 --- a/common/cputypes.h +++ b/common/cputypes.h @@ -438,7 +438,7 @@ #define HAVE_POSIX_THREADS #endif #elif defined(__APPLE__) - #if defined(__arm64__) + #if defined(__arm64__) && !defined(OPENCL) #define CLIENT_OS_NAME "iOS" #define CLIENT_OS OS_IOS #define CLIENT_CPU CPU_ARM64 From a2c3aa60d42d07f47cf121cef9be458111243a2b Mon Sep 17 00:00:00 2001 From: Joshua Morgan Date: Sat, 28 Nov 2020 18:04:30 +1030 Subject: [PATCH 07/14] Update configure Turn OGR back on in configure --- configure | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure b/configure index 32932eb07..d7f626bf6 100755 --- a/configure +++ b/configure @@ -120,7 +120,7 @@ OGR="ogr" # select the projects to include in the client HAVE_RC5_72="1" -HAVE_OGR="0" +HAVE_OGR="1" HAVE_OGR_P2="0" # define these to "0" in add_sources() if you add your own list of cores + options From 12f7be0890f5426b56739b89f32f9e7fcc9cae77 Mon Sep 17 00:00:00 2001 From: Joshua Morgan Date: Sat, 28 Nov 2020 18:09:10 +1030 Subject: [PATCH 08/14] Update configure Determined arm64 in add_sources is not required with OpenCL. --- configure | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure b/configure index d7f626bf6..fcbe1fa37 100755 --- a/configure +++ b/configure @@ -3498,7 +3498,7 @@ case "$1" in TARGET_LDFLAGS="$TARGET_plat" TARGET_DOCFILES="docs/readme._ix docs/readme.opencl" #platform specific docfile TARGET_TARBALL="macosx-arm64-opencl" - add_sources "macosx" "opencl" "arm64" + add_sources "macosx" "opencl" ;; ###### Unknown From 76704884078619e65313618111f7904449eb40a0 Mon Sep 17 00:00:00 2001 From: Joshua Morgan Date: Sat, 28 Nov 2020 18:12:28 +1030 Subject: [PATCH 09/14] Update temperature.cpp Tidied up macOS defintions to a single line. --- plat/macosx/temperature.cpp | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/plat/macosx/temperature.cpp b/plat/macosx/temperature.cpp index 50423756e..0b025ba01 100644 --- a/plat/macosx/temperature.cpp +++ b/plat/macosx/temperature.cpp @@ -246,10 +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 (kIOReturnSuccess == IOConnectCallStructMethod(connection, 2, - &smc_input, input_size, &smc_output, &output_size)) { -#elif defined(__arm64__) +#if defined(__x86_64__) || defined(__arm64__) if (kIOReturnSuccess == IOConnectCallStructMethod(connection, 2, &smc_input, input_size, &smc_output, &output_size)) { #else @@ -263,10 +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 (kIOReturnSuccess == IOConnectCallStructMethod(connection, 2, - &smc_input, input_size, &smc_output, &output_size)) { -#elif defined(__arm64__) +#if defined(__x86_64__) || defined(__arm64__) if (kIOReturnSuccess == IOConnectCallStructMethod(connection, 2, &smc_input, input_size, &smc_output, &output_size)) { #else From b801b4b73b14449103062062538673a61a70bd52 Mon Sep 17 00:00:00 2001 From: Joshua Morgan Date: Sat, 28 Nov 2020 20:48:49 +1030 Subject: [PATCH 10/14] Update cputypes.h Added ARM64 & ARM to CPU list rather than directly under APPLE --- common/cputypes.h | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/common/cputypes.h b/common/cputypes.h index 9beb4a910..e994664f2 100644 --- a/common/cputypes.h +++ b/common/cputypes.h @@ -438,14 +438,14 @@ #define HAVE_POSIX_THREADS #endif #elif defined(__APPLE__) - #if defined(__arm64__) && !defined(OPENCL) + #if defined(__arm64__) && !defined(OPENCL) #define CLIENT_OS_NAME "iOS" #define CLIENT_OS OS_IOS - #define CLIENT_CPU CPU_ARM64 + #define CLIENT_CPU CPU_ARM64 #elif defined(__arm__) || defined(ARM) #define CLIENT_OS_NAME "iOS" #define CLIENT_OS OS_IOS - #define CLIENT_CPU CPU_ARM + #define CLIENT_CPU CPU_ARM #else #define CLIENT_OS_NAME "Mac OS X" #define CLIENT_OS OS_MACOSX @@ -463,6 +463,10 @@ #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? */ From 70a14dd553dc22733ed257f27d02a9cd34b972f9 Mon Sep 17 00:00:00 2001 From: Joshua Morgan Date: Sat, 28 Nov 2020 21:19:56 +1030 Subject: [PATCH 11/14] Update cputypes.h Fixed spacing --- common/cputypes.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/common/cputypes.h b/common/cputypes.h index e994664f2..2681901cf 100644 --- a/common/cputypes.h +++ b/common/cputypes.h @@ -441,11 +441,11 @@ #if defined(__arm64__) && !defined(OPENCL) #define CLIENT_OS_NAME "iOS" #define CLIENT_OS OS_IOS - #define CLIENT_CPU CPU_ARM64 + #define CLIENT_CPU CPU_ARM64 #elif defined(__arm__) || defined(ARM) #define CLIENT_OS_NAME "iOS" #define CLIENT_OS OS_IOS - #define CLIENT_CPU CPU_ARM + #define CLIENT_CPU CPU_ARM #else #define CLIENT_OS_NAME "Mac OS X" #define CLIENT_OS OS_MACOSX From 7deabab3f1a67344ea4d2f467872d98cfb2e5919 Mon Sep 17 00:00:00 2001 From: Joshua Morgan Date: Mon, 30 Nov 2020 22:37:19 +1030 Subject: [PATCH 12/14] Add pre-processor definitions for APPLE in ARM64 scalarfusion core. OSX: leading underscore required on assembler functions that are going to be global and visible to C/C++ code. --- rc5-72/arm64/r72-ks-scalarfusion.S | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/rc5-72/arm64/r72-ks-scalarfusion.S b/rc5-72/arm64/r72-ks-scalarfusion.S index 35fef4691..1812dcbf1 100644 --- a/rc5-72/arm64/r72-ks-scalarfusion.S +++ b/rc5-72/arm64/r72-ks-scalarfusion.S @@ -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]! From 63f05595d92e9c3ddd4a77f981e013a642297472 Mon Sep 17 00:00:00 2001 From: Joshua Morgan Date: Mon, 30 Nov 2020 23:25:15 +1030 Subject: [PATCH 13/14] Added macosx-arm64 support Added maxosx-arm64 support for OGR-NG cores, and ANSI RC5-72 cores. ScalarFusion not currently functional. --- common/clisync.h | 3 ++- common/cputypes.h | 15 +++++++-------- configure | 16 ++++++++++++++-- 3 files changed, 23 insertions(+), 11 deletions(-) diff --git a/common/clisync.h b/common/clisync.h index 78fb030cc..3cff04c52 100644 --- a/common/clisync.h +++ b/common/clisync.h @@ -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) && !defined(__arm64__)|| ((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; diff --git a/common/cputypes.h b/common/cputypes.h index 2681901cf..0b3e94044 100644 --- a/common/cputypes.h +++ b/common/cputypes.h @@ -438,18 +438,17 @@ #define HAVE_POSIX_THREADS #endif #elif defined(__APPLE__) - #if defined(__arm64__) && !defined(OPENCL) + #if defined (IOS) #define CLIENT_OS_NAME "iOS" #define CLIENT_OS OS_IOS - #define CLIENT_CPU CPU_ARM64 - #elif defined(__arm__) || defined(ARM) - #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 diff --git a/configure b/configure index fcbe1fa37..bdf76eb0b 100755 --- a/configure +++ b/configure @@ -1763,8 +1763,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 @@ -1774,7 +1775,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 @@ -1783,6 +1784,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) From 2dc341c25f5b92ec467030f268c19af5ceeaa141 Mon Sep 17 00:00:00 2001 From: Joshua Morgan Date: Mon, 30 Nov 2020 23:39:40 +1030 Subject: [PATCH 14/14] Added exclusions for ScalarFusion Core for OSX ScalarFusion not currently passing tests for MacOS ARM64. --- common/core_r72.cpp | 8 ++++++-- configure | 8 +++++--- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/common/core_r72.cpp b/common/core_r72.cpp index b85b89edc..bbbf09710 100644 --- a/common/core_r72.cpp +++ b/common/core_r72.cpp @@ -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", @@ -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; diff --git a/configure b/configure index bdf76eb0b..ca6264a17 100755 --- a/configure +++ b/configure @@ -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