Skip to content

Commit e76183f

Browse files
committed
MDEV-11075: Power - runtime detection of optimized instructions
Signed-off-by: Daniel Black <daniel.black@au.ibm.com>
1 parent 9320d8a commit e76183f

File tree

2 files changed

+22
-4
lines changed

2 files changed

+22
-4
lines changed

storage/innobase/ut/ut0crc32.cc

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,12 @@ mysys/my_perf.c, contributed by Facebook under the following license.
8383
#include "my_config.h"
8484
#include <string.h>
8585

86+
#if defined(__linux__) && defined(HAVE_CRC32_VPMSUM)
87+
/* Used to detect at runtime if we have vpmsum instructions (PowerISA 2.07) */
88+
#include <sys/auxv.h>
89+
#include <bits/hwcap.h>
90+
#endif
91+
8692
#include "univ.i"
8793
#include "ut0crc32.h"
8894

@@ -740,8 +746,14 @@ ut_crc32_init()
740746
}
741747

742748
#elif defined(HAVE_CRC32_VPMSUM)
743-
ut_crc32 = ut_crc32_power8;
744-
ut_crc32_implementation = "Using POWER8 crc32 instructions";
749+
#if defined(__linux__)
750+
if (getauxval(AT_HWCAP2) & PPC_FEATURE2_ARCH_2_07) {
751+
#endif
752+
ut_crc32 = ut_crc32_power8;
753+
ut_crc32_implementation = "Using POWER8 crc32 instructions";
754+
#if defined(__linux__)
755+
}
756+
#endif
745757
#endif
746758

747759
}

storage/xtradb/ut/ut0crc32.cc

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,13 @@ ut_crc32_init()
336336
}
337337

338338
#elif defined(HAVE_CRC32_VPMSUM)
339-
ut_crc32 = ut_crc32_power8;
340-
ut_crc32_implementation = "Using POWER8 crc32 instructions";
339+
#if defined(__linux__)
340+
if (getauxval(AT_HWCAP2) & PPC_FEATURE2_ARCH_2_07) {
341+
#endif
342+
ut_crc32 = ut_crc32_power8;
343+
ut_crc32_implementation = "Using POWER8 crc32 instructions";
344+
#if defined(__linux__)
345+
}
346+
#endif
341347
#endif
342348
}

0 commit comments

Comments
 (0)