Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions dev/ppc64le/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,5 @@

# ppc64le backend (little endian)

This directory contains a native backend for little endian POWER 9 (ppc64le) and above systems.
Or, Power systems supporting ISA 2.07 and above.

This directory contains a native backend for little endian PPC64.
It requires POWER8 or above as well as the AltiVec and VSX extensions.
36 changes: 16 additions & 20 deletions dev/ppc64le/meta.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,52 +28,48 @@
MLK_MUST_CHECK_RETURN_VALUE
static MLK_INLINE int mlk_ntt_native(int16_t data[MLKEM_N])
{
#if defined(__POWER8_VECTOR__)
if (!mlk_sys_check_capability(MLK_SYS_CAP_PPC64LE_POWER8_VECTOR))
{
return MLK_NATIVE_FUNC_FALLBACK;
}
mlk_ntt_ppc_asm(data, mlk_ppc_qdata);
return MLK_NATIVE_FUNC_SUCCESS;
#else
(void)data;
return MLK_NATIVE_FUNC_FALLBACK;
#endif
}

#if !defined(MLK_CONFIG_NO_ENCAPS_API) || !defined(MLK_CONFIG_NO_DECAPS_API)
MLK_MUST_CHECK_RETURN_VALUE
static MLK_INLINE int mlk_intt_native(int16_t data[MLKEM_N])
{
#if defined(__POWER8_VECTOR__)
if (!mlk_sys_check_capability(MLK_SYS_CAP_PPC64LE_POWER8_VECTOR))
{
return MLK_NATIVE_FUNC_FALLBACK;
}
mlk_intt_ppc_asm(data, mlk_ppc_qdata);
return MLK_NATIVE_FUNC_SUCCESS;
#else
(void)data;
return MLK_NATIVE_FUNC_FALLBACK;
#endif
}
#endif /* !MLK_CONFIG_NO_ENCAPS_API || !MLK_CONFIG_NO_DECAPS_API */

MLK_MUST_CHECK_RETURN_VALUE
static MLK_INLINE int mlk_poly_reduce_native(int16_t data[MLKEM_N])
{
#if defined(__POWER8_VECTOR__)
if (!mlk_sys_check_capability(MLK_SYS_CAP_PPC64LE_POWER8_VECTOR))
{
return MLK_NATIVE_FUNC_FALLBACK;
}
mlk_reduce_ppc_asm(data, mlk_ppc_qdata);
return MLK_NATIVE_FUNC_SUCCESS;
#else
(void)data;
return MLK_NATIVE_FUNC_FALLBACK;
#endif
}

#if !defined(MLK_CONFIG_NO_KEYPAIR_API)
MLK_MUST_CHECK_RETURN_VALUE
static MLK_INLINE int mlk_poly_tomont_native(int16_t data[MLKEM_N])
{
#if defined(__POWER8_VECTOR__)
if (!mlk_sys_check_capability(MLK_SYS_CAP_PPC64LE_POWER8_VECTOR))
{
return MLK_NATIVE_FUNC_FALLBACK;
}
mlk_poly_tomont_ppc_asm(data, mlk_ppc_qdata);
return MLK_NATIVE_FUNC_SUCCESS;
#else
(void)data;
return MLK_NATIVE_FUNC_FALLBACK;
#endif
}
#endif /* !MLK_CONFIG_NO_KEYPAIR_API */
#endif /* !__ASSEMBLER__ */
Expand Down
4 changes: 2 additions & 2 deletions dev/ppc64le/src/consts.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#include "../../../common.h"

#if defined(MLK_ARITH_BACKEND_PPC64LE_DEFAULT) && \
!defined(MLK_CONFIG_MULTILEVEL_NO_SHARED) && defined(__POWER8_VECTOR__)
!defined(MLK_CONFIG_MULTILEVEL_NO_SHARED)

#include "consts.h"

Expand Down Expand Up @@ -296,4 +296,4 @@ MLK_ALIGN MLK_INTERNAL_DATA_DEFINITION const int16_t mlk_ppc_qdata[2072] = {
/* clang-format on */

#endif /* MLK_ARITH_BACKEND_PPC64LE_DEFAULT && \
!MLK_CONFIG_MULTILEVEL_NO_SHARED && __POWER8_VECTOR__ */
!MLK_CONFIG_MULTILEVEL_NO_SHARED */
7 changes: 3 additions & 4 deletions dev/ppc64le/src/mlkem_intt_ppc_asm.S
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

#include "../../../common.h"
#if defined(MLK_ARITH_BACKEND_PPC64LE_DEFAULT) && \
!defined(MLK_CONFIG_MULTILEVEL_NO_SHARED) && defined(__POWER8_VECTOR__) && \
!defined(MLK_CONFIG_MULTILEVEL_NO_SHARED) && \
(!defined(MLK_CONFIG_NO_ENCAPS_API) || \
!defined(MLK_CONFIG_NO_DECAPS_API))
/*yaml
Expand All @@ -18,7 +18,7 @@
ABI:
Architecture: powerpc64le
CallingConvention: ELFv2
Features: [VSX]
Features: [POWER8_VECTOR]
r3:
type: buffer
size_bytes: 512
Expand Down Expand Up @@ -1004,5 +1004,4 @@ mlk_intt_ppc_asm_Loopf:

/* simpasm: footer-start */
#endif /* MLK_ARITH_BACKEND_PPC64LE_DEFAULT && !MLK_CONFIG_MULTILEVEL_NO_SHARED \
&& __POWER8_VECTOR__ && (!MLK_CONFIG_NO_ENCAPS_API || \
!MLK_CONFIG_NO_DECAPS_API) */
&& (!MLK_CONFIG_NO_ENCAPS_API || !MLK_CONFIG_NO_DECAPS_API) */
6 changes: 3 additions & 3 deletions dev/ppc64le/src/mlkem_ntt_ppc_asm.S
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@

#include "../../../common.h"
#if defined(MLK_ARITH_BACKEND_PPC64LE_DEFAULT) && \
!defined(MLK_CONFIG_MULTILEVEL_NO_SHARED) && defined(__POWER8_VECTOR__)
!defined(MLK_CONFIG_MULTILEVEL_NO_SHARED)
/*yaml
Name: ntt_ppc_asm
Description: PowerPC64 VSX forward NTT
Signature: void mlk_ntt_ppc_asm(int16_t *r, const int16_t *qdata)
ABI:
Architecture: powerpc64le
CallingConvention: ELFv2
Features: [VSX]
Features: [POWER8_VECTOR]
r3:
type: buffer
size_bytes: 512
Expand Down Expand Up @@ -767,4 +767,4 @@ MLK_ASM_FN_SYMBOL(ntt_ppc_asm)

/* simpasm: footer-start */
#endif /* MLK_ARITH_BACKEND_PPC64LE_DEFAULT && !MLK_CONFIG_MULTILEVEL_NO_SHARED \
&& __POWER8_VECTOR__ */
*/
6 changes: 3 additions & 3 deletions dev/ppc64le/src/mlkem_poly_tomont_ppc_asm.S
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

#include "../../../common.h"
#if defined(MLK_ARITH_BACKEND_PPC64LE_DEFAULT) && \
!defined(MLK_CONFIG_MULTILEVEL_NO_SHARED) && defined(__POWER8_VECTOR__) && \
!defined(MLK_CONFIG_MULTILEVEL_NO_SHARED) && \
!defined(MLK_CONFIG_NO_KEYPAIR_API)
/*yaml
Name: poly_tomont_ppc_asm
Expand All @@ -24,7 +24,7 @@
ABI:
Architecture: powerpc64le
CallingConvention: ELFv2
Features: [VSX]
Features: [POWER8_VECTOR]
r3:
type: buffer
size_bytes: 512
Expand Down Expand Up @@ -242,4 +242,4 @@ MLK_ASM_FN_SYMBOL(poly_tomont_ppc_asm)

/* simpasm: footer-start */
#endif /* MLK_ARITH_BACKEND_PPC64LE_DEFAULT && !MLK_CONFIG_MULTILEVEL_NO_SHARED \
&& __POWER8_VECTOR__ && !MLK_CONFIG_NO_KEYPAIR_API */
&& !MLK_CONFIG_NO_KEYPAIR_API */
6 changes: 3 additions & 3 deletions dev/ppc64le/src/mlkem_reduce_ppc_asm.S
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@
*/
#include "../../../common.h"
#if defined(MLK_ARITH_BACKEND_PPC64LE_DEFAULT) && \
!defined(MLK_CONFIG_MULTILEVEL_NO_SHARED) && defined(__POWER8_VECTOR__)
!defined(MLK_CONFIG_MULTILEVEL_NO_SHARED)
/*yaml
Name: reduce_ppc_asm
Description: PowerPC64 VSX modular reduction
Signature: void mlk_reduce_ppc_asm(int16_t *r, const int16_t *qdata)
ABI:
Architecture: powerpc64le
CallingConvention: ELFv2
Features: [VSX]
Features: [POWER8_VECTOR]
r3:
type: buffer
size_bytes: 512
Expand Down Expand Up @@ -463,4 +463,4 @@ MLK_ASM_FN_SYMBOL(reduce_ppc_asm)

/* simpasm: footer-start */
#endif /* MLK_ARITH_BACKEND_PPC64LE_DEFAULT && !MLK_CONFIG_MULTILEVEL_NO_SHARED \
&& __POWER8_VECTOR__ */
*/
1 change: 1 addition & 0 deletions mlkem/mlkem_native.c
Original file line number Diff line number Diff line change
Expand Up @@ -684,6 +684,7 @@
#undef MLK_SYS_LINUX
#undef MLK_SYS_LITTLE_ENDIAN
#undef MLK_SYS_PPC64LE
#undef MLK_SYS_PPC64LE_POWER8_VECTOR
#undef MLK_SYS_RISCV32
#undef MLK_SYS_RISCV64
#undef MLK_SYS_RISCV64_RVV
Expand Down
1 change: 1 addition & 0 deletions mlkem/mlkem_native_asm.S
Original file line number Diff line number Diff line change
Expand Up @@ -715,6 +715,7 @@
#undef MLK_SYS_LINUX
#undef MLK_SYS_LITTLE_ENDIAN
#undef MLK_SYS_PPC64LE
#undef MLK_SYS_PPC64LE_POWER8_VECTOR
#undef MLK_SYS_RISCV32
#undef MLK_SYS_RISCV64
#undef MLK_SYS_RISCV64_RVV
Expand Down
4 changes: 2 additions & 2 deletions mlkem/src/native/meta.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
*/
#include "../sys.h"

#ifdef MLK_SYS_AARCH64_NEON
#if defined(MLK_SYS_AARCH64_NEON)
#include "aarch64/meta.h"
#endif

Expand All @@ -23,7 +23,7 @@
#include "riscv64/meta.h"
#endif

#ifdef MLK_SYS_PPC64LE
#if defined(MLK_SYS_PPC64LE_POWER8_VECTOR)
#include "ppc64le/meta.h"
#endif

Expand Down
4 changes: 2 additions & 2 deletions mlkem/src/native/ppc64le/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@

# ppc64le backend (little endian)

This directory contains a native backend for little endian POWER 9 (ppc64le) and above systems.
Or, Power systems supporting ISA 2.07 and above.
This directory contains a native backend for little endian PPC64.
It requires POWER8 or above as well as the AltiVec and VSX extensions.
36 changes: 16 additions & 20 deletions mlkem/src/native/ppc64le/meta.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,52 +28,48 @@
MLK_MUST_CHECK_RETURN_VALUE
static MLK_INLINE int mlk_ntt_native(int16_t data[MLKEM_N])
{
#if defined(__POWER8_VECTOR__)
if (!mlk_sys_check_capability(MLK_SYS_CAP_PPC64LE_POWER8_VECTOR))
{
return MLK_NATIVE_FUNC_FALLBACK;
}
mlk_ntt_ppc_asm(data, mlk_ppc_qdata);
return MLK_NATIVE_FUNC_SUCCESS;
#else
(void)data;
return MLK_NATIVE_FUNC_FALLBACK;
#endif
}

#if !defined(MLK_CONFIG_NO_ENCAPS_API) || !defined(MLK_CONFIG_NO_DECAPS_API)
MLK_MUST_CHECK_RETURN_VALUE
static MLK_INLINE int mlk_intt_native(int16_t data[MLKEM_N])
{
#if defined(__POWER8_VECTOR__)
if (!mlk_sys_check_capability(MLK_SYS_CAP_PPC64LE_POWER8_VECTOR))
{
return MLK_NATIVE_FUNC_FALLBACK;
}
mlk_intt_ppc_asm(data, mlk_ppc_qdata);
return MLK_NATIVE_FUNC_SUCCESS;
#else
(void)data;
return MLK_NATIVE_FUNC_FALLBACK;
#endif
}
#endif /* !MLK_CONFIG_NO_ENCAPS_API || !MLK_CONFIG_NO_DECAPS_API */

MLK_MUST_CHECK_RETURN_VALUE
static MLK_INLINE int mlk_poly_reduce_native(int16_t data[MLKEM_N])
{
#if defined(__POWER8_VECTOR__)
if (!mlk_sys_check_capability(MLK_SYS_CAP_PPC64LE_POWER8_VECTOR))
{
return MLK_NATIVE_FUNC_FALLBACK;
}
mlk_reduce_ppc_asm(data, mlk_ppc_qdata);
return MLK_NATIVE_FUNC_SUCCESS;
#else
(void)data;
return MLK_NATIVE_FUNC_FALLBACK;
#endif
}

#if !defined(MLK_CONFIG_NO_KEYPAIR_API)
MLK_MUST_CHECK_RETURN_VALUE
static MLK_INLINE int mlk_poly_tomont_native(int16_t data[MLKEM_N])
{
#if defined(__POWER8_VECTOR__)
if (!mlk_sys_check_capability(MLK_SYS_CAP_PPC64LE_POWER8_VECTOR))
{
return MLK_NATIVE_FUNC_FALLBACK;
}
mlk_poly_tomont_ppc_asm(data, mlk_ppc_qdata);
return MLK_NATIVE_FUNC_SUCCESS;
#else
(void)data;
return MLK_NATIVE_FUNC_FALLBACK;
#endif
}
#endif /* !MLK_CONFIG_NO_KEYPAIR_API */
#endif /* !__ASSEMBLER__ */
Expand Down
4 changes: 2 additions & 2 deletions mlkem/src/native/ppc64le/src/consts.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#include "../../../common.h"

#if defined(MLK_ARITH_BACKEND_PPC64LE_DEFAULT) && \
!defined(MLK_CONFIG_MULTILEVEL_NO_SHARED) && defined(__POWER8_VECTOR__)
!defined(MLK_CONFIG_MULTILEVEL_NO_SHARED)

#include "consts.h"

Expand Down Expand Up @@ -296,4 +296,4 @@ MLK_ALIGN MLK_INTERNAL_DATA_DEFINITION const int16_t mlk_ppc_qdata[2072] = {
/* clang-format on */

#endif /* MLK_ARITH_BACKEND_PPC64LE_DEFAULT && \
!MLK_CONFIG_MULTILEVEL_NO_SHARED && __POWER8_VECTOR__ */
!MLK_CONFIG_MULTILEVEL_NO_SHARED */
7 changes: 3 additions & 4 deletions mlkem/src/native/ppc64le/src/mlkem_intt_ppc_asm.S
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

#include "../../../common.h"
#if defined(MLK_ARITH_BACKEND_PPC64LE_DEFAULT) && \
!defined(MLK_CONFIG_MULTILEVEL_NO_SHARED) && defined(__POWER8_VECTOR__) && \
!defined(MLK_CONFIG_MULTILEVEL_NO_SHARED) && \
(!defined(MLK_CONFIG_NO_ENCAPS_API) || \
!defined(MLK_CONFIG_NO_DECAPS_API))
/*yaml
Expand All @@ -18,7 +18,7 @@
ABI:
Architecture: powerpc64le
CallingConvention: ELFv2
Features: [VSX]
Features: [POWER8_VECTOR]
r3:
type: buffer
size_bytes: 512
Expand Down Expand Up @@ -3238,8 +3238,7 @@ mlk_intt_ppc_asm_Loopf:
MLK_ASM_FN_SIZE(intt_ppc_asm)

#endif /* MLK_ARITH_BACKEND_PPC64LE_DEFAULT && !MLK_CONFIG_MULTILEVEL_NO_SHARED \
&& __POWER8_VECTOR__ && (!MLK_CONFIG_NO_ENCAPS_API || \
!MLK_CONFIG_NO_DECAPS_API) */
&& (!MLK_CONFIG_NO_ENCAPS_API || !MLK_CONFIG_NO_DECAPS_API) */

#if defined(__ELF__)
.section .note.GNU-stack,"",%progbits
Expand Down
6 changes: 3 additions & 3 deletions mlkem/src/native/ppc64le/src/mlkem_ntt_ppc_asm.S
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@

#include "../../../common.h"
#if defined(MLK_ARITH_BACKEND_PPC64LE_DEFAULT) && \
!defined(MLK_CONFIG_MULTILEVEL_NO_SHARED) && defined(__POWER8_VECTOR__)
!defined(MLK_CONFIG_MULTILEVEL_NO_SHARED)
/*yaml
Name: ntt_ppc_asm
Description: PowerPC64 VSX forward NTT
Signature: void mlk_ntt_ppc_asm(int16_t *r, const int16_t *qdata)
ABI:
Architecture: powerpc64le
CallingConvention: ELFv2
Features: [VSX]
Features: [POWER8_VECTOR]
r3:
type: buffer
size_bytes: 512
Expand Down Expand Up @@ -1665,7 +1665,7 @@ MLK_ASM_FN_SYMBOL(ntt_ppc_asm)
MLK_ASM_FN_SIZE(ntt_ppc_asm)

#endif /* MLK_ARITH_BACKEND_PPC64LE_DEFAULT && !MLK_CONFIG_MULTILEVEL_NO_SHARED \
&& __POWER8_VECTOR__ */
*/

#if defined(__ELF__)
.section .note.GNU-stack,"",%progbits
Expand Down
6 changes: 3 additions & 3 deletions mlkem/src/native/ppc64le/src/mlkem_poly_tomont_ppc_asm.S
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

#include "../../../common.h"
#if defined(MLK_ARITH_BACKEND_PPC64LE_DEFAULT) && \
!defined(MLK_CONFIG_MULTILEVEL_NO_SHARED) && defined(__POWER8_VECTOR__) && \
!defined(MLK_CONFIG_MULTILEVEL_NO_SHARED) && \
!defined(MLK_CONFIG_NO_KEYPAIR_API)
/*yaml
Name: poly_tomont_ppc_asm
Expand All @@ -24,7 +24,7 @@
ABI:
Architecture: powerpc64le
CallingConvention: ELFv2
Features: [VSX]
Features: [POWER8_VECTOR]
r3:
type: buffer
size_bytes: 512
Expand Down Expand Up @@ -309,7 +309,7 @@ MLK_ASM_FN_SYMBOL(poly_tomont_ppc_asm)
MLK_ASM_FN_SIZE(poly_tomont_ppc_asm)

#endif /* MLK_ARITH_BACKEND_PPC64LE_DEFAULT && !MLK_CONFIG_MULTILEVEL_NO_SHARED \
&& __POWER8_VECTOR__ && !MLK_CONFIG_NO_KEYPAIR_API */
&& !MLK_CONFIG_NO_KEYPAIR_API */

#if defined(__ELF__)
.section .note.GNU-stack,"",%progbits
Expand Down
Loading
Loading