Skip to content

Commit db4bdde

Browse files
Scottcjnclaude
andcommitted
gh-138114: Enable HACL BLAKE2 SIMD128 vectorization on PowerPC64
The HACL* library's libintvector.h already contains a complete PowerPC64 AltiVec/VSX implementation of vec128 operations (lines 800-926), but CPython's configure never enables it because the SIMD128 detection only checks for x86 SSE. This adds PowerPC64 detection as a fallback in the SSE check's else-branch of configure.ac, testing for -maltivec -mvsx compiler flags, which enables SIMD-accelerated BLAKE2s hashing on POWER8+. This implements the TODO at configure.ac line 8113: "This can be extended here to detect e.g. Power8, which HACL* should also support." Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 70c7e04 commit db4bdde

File tree

3 files changed

+74
-2
lines changed

3 files changed

+74
-2
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Enable HACL* BLAKE2s SIMD128 vectorization on PowerPC64 (POWER8+) using
2+
AltiVec/VSX instructions. The HACL* library already contained a complete
3+
PowerPC64 vec128 implementation but CPython's configure never enabled it.

configure

Lines changed: 56 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

configure.ac

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8110,7 +8110,7 @@ fi
81108110
if test "$ac_sys_system" != "Linux-android" -a "$ac_sys_system" != "WASI" || \
81118111
{ test -n "$ANDROID_API_LEVEL" && test "$ANDROID_API_LEVEL" -ge 28; }
81128112
then
8113-
dnl This can be extended here to detect e.g. Power8, which HACL* should also support.
8113+
dnl Check for x86 SSE support (SIMD128)
81148114
AX_CHECK_COMPILE_FLAG([-msse -msse2 -msse3 -msse4.1 -msse4.2],[
81158115
[LIBHACL_SIMD128_FLAGS="-msse -msse2 -msse3 -msse4.1 -msse4.2"]
81168116
@@ -8129,7 +8129,20 @@ then
81298129
AC_MSG_RESULT([standard])
81308130
fi
81318131
8132-
], [], [-Werror])
8132+
], [
8133+
dnl x86 SSE not available; check for PowerPC AltiVec/VSX (Power8+).
8134+
dnl HACL* libintvector.h has a complete vec128 implementation for __powerpc64__.
8135+
AX_CHECK_COMPILE_FLAG([-maltivec -mvsx],[
8136+
[LIBHACL_SIMD128_FLAGS="-maltivec -mvsx"]
8137+
8138+
AC_DEFINE([_Py_HACL_CAN_COMPILE_VEC128], [1], [
8139+
HACL* library can compile SIMD128 implementations])
8140+
8141+
[LIBHACL_BLAKE2_SIMD128_OBJS="Modules/_hacl/Hacl_Hash_Blake2s_Simd128.o"]
8142+
AC_MSG_CHECKING([for HACL* SIMD128 implementation])
8143+
AC_MSG_RESULT([PowerPC AltiVec/VSX])
8144+
], [], [-Werror])
8145+
], [-Werror])
81338146
fi
81348147
AC_SUBST([LIBHACL_SIMD128_FLAGS])
81358148
AC_SUBST([LIBHACL_BLAKE2_SIMD128_OBJS])

0 commit comments

Comments
 (0)