|
| 1 | +diff --git a/m4/ax_cache_size.m4 b/m4/ax_cache_size.m4 |
| 2 | +index 72754bb..a11344a 100644 |
| 3 | +--- a/m4/ax_cache_size.m4 |
| 4 | ++++ b/m4/ax_cache_size.m4 |
| 5 | +@@ -41,8 +41,9 @@ AC_DEFUN([AX_CACHE_SIZE], |
| 6 | + |
| 7 | + ax_l1_size= |
| 8 | + ax_l2_size= |
| 9 | ++ ax_l3_size= |
| 10 | + |
| 11 | +- #Check if the variable is present |
| 12 | ++ # Linux sysfs path |
| 13 | + if test -e /sys/devices/system/cpu/cpu0/cache/index0/size; then |
| 14 | + for idx in `seq 0 3`; do |
| 15 | + if test -e /sys/devices/system/cpu/cpu0/cache/index$idx/size ; then |
| 16 | +@@ -57,63 +58,78 @@ AC_DEFUN([AX_CACHE_SIZE], |
| 17 | + ax_l3_size=$CPU0_L3_CACHE |
| 18 | + |
| 19 | + else |
| 20 | +- if test "x$ax_cv_cpu_vendor" != "xUnknown"; then |
| 21 | +- #Or use CPUID |
| 22 | +- AX_GCC_X86_CPUID(0x80000000) |
| 23 | +- cpu_exthigh=`echo $ax_cv_gcc_x86_cpuid_0x80000000 | cut -d ":" -f 1` |
| 24 | +- if test "x$cpu_exthi" \> "x80000004"; then |
| 25 | +- AX_GCC_X86_CPUID(0x80000005) # For L1 cache |
| 26 | +- l1_hexval=`echo $ax_cv_gcc_x86_cpuid_0x80000005 | cut -d ":" -f 4` |
| 27 | +- ax_l1_size=$((0x$l1_hexval >> 24)) |
| 28 | +- fi |
| 29 | ++ # Try CPUID (mostly for Linux without sysfs or during cross-compilation) |
| 30 | ++ if test "x$ax_cv_cpu_vendor" != "xIntel"; then |
| 31 | ++ AX_GCC_X86_CPUID(0x80000000) |
| 32 | ++ cpu_exthigh=`echo $ax_cv_gcc_x86_cpuid_0x80000000 | cut -d ":" -f 1` |
| 33 | ++ if test "x$cpu_exthigh" \> "x80000004"; then |
| 34 | ++ AX_GCC_X86_CPUID(0x80000005) |
| 35 | ++ l1_hexval=`echo $ax_cv_gcc_x86_cpuid_0x80000005 | cut -d ":" -f 4` |
| 36 | ++ ax_l1_size=$((0x$l1_hexval >> 24)) |
| 37 | ++ fi |
| 38 | ++ |
| 39 | ++ if test "x$cpu_exthigh" \> "x80000005"; then |
| 40 | ++ AX_GCC_X86_CPUID(0x80000006) |
| 41 | ++ l2_hexval=`echo $ax_cv_gcc_x86_cpuid_0x80000006 | cut -d ":" -f 3` |
| 42 | ++ ax_l2_size=$((0x$l2_hexval >> 16)) |
| 43 | + |
| 44 | +- if test "x$cpu_exthi" \> "x80000005"; then |
| 45 | +- AX_GCC_X86_CPUID(0x80000006) # For L2 cache |
| 46 | +- l2_hexval=`echo $ax_cv_gcc_x86_cpuid_0x80000006 | cut -d ":" -f 3` |
| 47 | +- ax_l2_size=$((0x$l2_hexval >> 16)) |
| 48 | ++ # L3 info in EDX (bits 31:18) → 512-byte blocks (AMD only) |
| 49 | ++ l3_hexval=`echo $ax_cv_gcc_x86_cpuid_0x80000006 | cut -d ":" -f 4` |
| 50 | ++ ax_l3_size=$(( (0x$l3_hexval >> 18) * 512 )) |
| 51 | ++ fi |
| 52 | + fi |
| 53 | + |
| 54 | +- if test "x$cpu_exthi" \> "x80000005"; then |
| 55 | +- AX_GCC_X86_CPUID(0x80000006) # For L3 cache |
| 56 | +- l2_hexval=`echo $ax_cv_gcc_x86_cpuid_0x80000006 | cut -d ":" -f 4` |
| 57 | +- ax_l2_size=$((0x$l2_hexval >> 18))*512 |
| 58 | ++ # sysctl fallback |
| 59 | ++ sysctl_exe= |
| 60 | ++ if test -x /usr/sbin/sysctl; then |
| 61 | ++ sysctl_exe=/usr/sbin/sysctl |
| 62 | ++ elif test -x /sbin/sysctl; then |
| 63 | ++ sysctl_exe=/sbin/sysctl |
| 64 | + fi |
| 65 | + |
| 66 | +- fi |
| 67 | +- |
| 68 | +- #Or use sysctl |
| 69 | +- sysctl_exe= |
| 70 | +- if test -x /usr/sbin/sysctl ; then |
| 71 | +- sysctl_exe=/usr/sbin/sysctl |
| 72 | +- elif test -x /sbin/sysctl ; then |
| 73 | +- sysctl_exe=/sbin/sysctl |
| 74 | +- fi |
| 75 | +- if test -n "$sysctl_exe"; then |
| 76 | +- if test -z "$ax_l2_size" -o "$ax_l2_size" = "0"; then |
| 77 | +- sysctl_out=`$sysctl_exe -n hw.l2cachesize 2>/dev/null`; |
| 78 | +- if test ! -z "$sysctl_out"; then |
| 79 | +- ax_l2_size=$(($sysctl_out / 1024)) |
| 80 | +- fi; |
| 81 | +- |
| 82 | +- fi |
| 83 | +- if test -z "$ax_l1_size" -o "$ax_l1_size" = "0" ; then |
| 84 | +- sysctl_out=`$sysctl_exe -n hw.l1dcachesize 2>/dev/null`; |
| 85 | +- if test ! -z "$sysctl_out"; then |
| 86 | +- ax_l1_size=$(($sysctl_out / 1024)) |
| 87 | +- fi; |
| 88 | +- fi |
| 89 | +- if test -z "$ax_l1_size" -o "ax_l1_size" = "0" ; then |
| 90 | +- sysctl_out=`$sysctl_exe -n hw.l1cachesize 2>/dev/null`; |
| 91 | +- if test ! -z "$sysctl_out"; then |
| 92 | +- ax_l1_size=$(($sysctl_out / 1024)) |
| 93 | +- fi; |
| 94 | ++ if test -n "$sysctl_exe"; then |
| 95 | ++ # L1 |
| 96 | ++ if test -z "$ax_l1_size" -o "$ax_l1_size" = "0"; then |
| 97 | ++ sysctl_out=`$sysctl_exe -n hw.l1dcachesize 2>/dev/null` |
| 98 | ++ if test -n "$sysctl_out"; then |
| 99 | ++ ax_l1_size=$(($sysctl_out / 1024)) |
| 100 | ++ fi |
| 101 | ++ fi |
| 102 | ++ if test -z "$ax_l1_size" -o "$ax_l1_size" = "0"; then |
| 103 | ++ sysctl_out=`$sysctl_exe -n hw.l1icachesize 2>/dev/null` |
| 104 | ++ if test -n "$sysctl_out"; then |
| 105 | ++ ax_l1_size=$(($sysctl_out / 1024)) |
| 106 | ++ fi |
| 107 | ++ fi |
| 108 | ++ if test -z "$ax_l1_size" -o "$ax_l1_size" = "0"; then |
| 109 | ++ sysctl_out=`$sysctl_exe -n hw.l1cachesize 2>/dev/null` |
| 110 | ++ if test -n "$sysctl_out"; then |
| 111 | ++ ax_l1_size=$(($sysctl_out / 1024)) |
| 112 | ++ fi |
| 113 | ++ fi |
| 114 | ++ |
| 115 | ++ # L2 |
| 116 | ++ if test -z "$ax_l2_size" -o "$ax_l2_size" = "0"; then |
| 117 | ++ sysctl_out=`$sysctl_exe -n hw.l2cachesize 2>/dev/null` |
| 118 | ++ if test -n "$sysctl_out"; then |
| 119 | ++ ax_l2_size=$(($sysctl_out / 1024)) |
| 120 | ++ fi |
| 121 | ++ fi |
| 122 | ++ |
| 123 | ++ # L3 |
| 124 | ++ if test -z "$ax_l3_size" -o "$ax_l3_size" = "0"; then |
| 125 | ++ sysctl_out=`$sysctl_exe -n hw.l3cachesize 2>/dev/null` |
| 126 | ++ if test -n "$sysctl_out"; then |
| 127 | ++ ax_l3_size=$(($sysctl_out / 1024)) |
| 128 | ++ fi |
| 129 | ++ fi |
| 130 | + fi |
| 131 | +- fi |
| 132 | + fi |
| 133 | + |
| 134 | ++ # Final fallbacks |
| 135 | + test -z "$ax_l1_size" && ax_l1_size=0 |
| 136 | + test -z "$ax_l2_size" && ax_l2_size=0 |
| 137 | +- test -z "$ax_l3_size" && ax_l3_size=$ax_l2_size |
| 138 | ++ test -z "$ax_l3_size" && ax_l3_size=0 |
| 139 | + |
| 140 | + # Keep only digits if there is a unit (ie 1024K -> 1024) and convert in Bytes |
| 141 | + AC_MSG_CHECKING(the L1 cache size) |
| 142 | +diff --git a/m4ri/misc.h b/m4ri/misc.h |
| 143 | +index 99fd6bb..64c63bd 100644 |
| 144 | +--- a/m4ri/misc.h |
| 145 | ++++ b/m4ri/misc.h |
| 146 | +@@ -138,7 +138,7 @@ typedef uint64_t word; |
| 147 | + * \brief The number of bits in a word. |
| 148 | + */ |
| 149 | + |
| 150 | +-static int const m4ri_radix = 64; |
| 151 | ++#define m4ri_radix 64 |
| 152 | + |
| 153 | + /** |
| 154 | + * \brief The number one as a word. |
0 commit comments