Enable crc32c accelleration for arm64 on OSX
authorJens Axboe <axboe@kernel.dk>
Wed, 25 Jan 2023 15:01:30 +0000 (08:01 -0700)
committerJens Axboe <axboe@kernel.dk>
Wed, 25 Jan 2023 15:01:30 +0000 (08:01 -0700)
Before:

jensaxboe@Jenss-MacBook-Pro fio % ./fio --crctest=crc32c
crc32c:   440.18 MiB/sec

After:

ensaxboe@Jenss-MacBook-Pro fio % ./fio --crctest=crc32c
crc32c: 23923.00 MiB/sec

We know we have it on osx on arm hardware, enabling it is pretty
straightforward with that assumption.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
configure
os/os-mac.h

index a17d1cda1091e0419fbd0e2bec757604d2ae5929..182cd3c3c98d558a2ca964f119bd778faeaa639d 100755 (executable)
--- a/configure
+++ b/configure
@@ -2685,20 +2685,22 @@ print_config "libblkio engine" "$libblkio"
 
 ##########################################
 # check march=armv8-a+crc+crypto
-if test "$march_armv8_a_crc_crypto" != "yes" ; then
-  march_armv8_a_crc_crypto="no"
-fi
+march_armv8_a_crc_crypto="no"
 if test "$cpu" = "arm64" ; then
   cat > $TMPC <<EOF
+#if __linux__
 #include <arm_acle.h>
 #include <arm_neon.h>
 #include <sys/auxv.h>
+#endif
 
 int main(void)
 {
   /* Can we also do a runtime probe? */
 #if __linux__
   return getauxval(AT_HWCAP);
+#elif defined(__APPLE__)
+  return 0;
 #else
 # error "Don't know how to do runtime probe for ARM CRC32c"
 #endif
index ec2cc1e555f43c2bc5afce2cc35396ebd7adfc1d..c9103c45ac44afe0a79e6878d7f604f49b9dae18 100644 (file)
 #include <machine/endian.h>
 #include <libkern/OSByteOrder.h>
 
+#include "../arch/arch.h"
 #include "../file.h"
 
 #define FIO_USE_GENERIC_INIT_RANDOM_STATE
 #define FIO_HAVE_GETTID
 #define FIO_HAVE_CHARDEV_SIZE
 #define FIO_HAVE_NATIVE_FALLOCATE
+#define FIO_HAVE_CPU_HAS
 
 #define OS_MAP_ANON            MAP_ANON
 
@@ -106,4 +108,12 @@ static inline bool fio_fallocate(struct fio_file *f, uint64_t offset, uint64_t l
        return false;
 }
 
+static inline bool os_cpu_has(cpu_features feature)
+{
+       /* just check for arm on OSX for now, we know that has it */
+       if (feature != CPU_ARM64_CRC32C)
+               return false;
+       return FIO_ARCH == arch_aarch64;
+}
+
 #endif