mirror of
https://github.com/open-quantum-safe/liboqs.git
synced 2025-10-08 00:03:38 -04:00
Compile-time guard for some BIKE AVX2 and AVX512 code (#1067)
* Compile-time guard for some BIKE AVX512 code * Compile-time guard for some BIKE AVX2 code * Typo PCLMUL->PCLMULQDQ
This commit is contained in:
parent
1d31f51fa4
commit
2049555b7c
@ -66,6 +66,8 @@ if(OQS_ENABLE_KEM_bike_l1 OR OQS_ENABLE_KEM_bike_l3)
|
|||||||
else()
|
else()
|
||||||
set(CPP_DEFS_R3 ${CPP_DEFS_R3} DISABLE_VPCLMUL)
|
set(CPP_DEFS_R3 ${CPP_DEFS_R3} DISABLE_VPCLMUL)
|
||||||
endif()
|
endif()
|
||||||
|
else()
|
||||||
|
set(CPP_DEFS_R3 ${CPP_DEFS_R3} DISABLE_VPCLMUL)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(ARCH_X86_64)
|
if(ARCH_X86_64)
|
||||||
|
@ -61,17 +61,22 @@ typedef struct decode_ctx_st {
|
|||||||
_INLINE_ void decode_ctx_init(decode_ctx *ctx)
|
_INLINE_ void decode_ctx_init(decode_ctx *ctx)
|
||||||
{
|
{
|
||||||
#if defined(X86_64)
|
#if defined(X86_64)
|
||||||
|
#if defined(OQS_DIST_X86_64_BUILD) || defined(OQS_USE_AVX512_INSTRUCTIONS)
|
||||||
if(is_avx512_enabled()) {
|
if(is_avx512_enabled()) {
|
||||||
ctx->rotate_right = rotate_right_avx512;
|
ctx->rotate_right = rotate_right_avx512;
|
||||||
ctx->dup = dup_avx512;
|
ctx->dup = dup_avx512;
|
||||||
ctx->bit_sliced_adder = bit_sliced_adder_avx512;
|
ctx->bit_sliced_adder = bit_sliced_adder_avx512;
|
||||||
ctx->bit_slice_full_subtract = bit_slice_full_subtract_avx512;
|
ctx->bit_slice_full_subtract = bit_slice_full_subtract_avx512;
|
||||||
} else if(is_avx2_enabled()) {
|
} else
|
||||||
|
#endif
|
||||||
|
#if defined(OQS_DIST_X86_64_BUILD) || defined(OQS_USE_AVX2_INSTRUCTIONS)
|
||||||
|
if(is_avx2_enabled()) {
|
||||||
ctx->rotate_right = rotate_right_avx2;
|
ctx->rotate_right = rotate_right_avx2;
|
||||||
ctx->dup = dup_avx2;
|
ctx->dup = dup_avx2;
|
||||||
ctx->bit_sliced_adder = bit_sliced_adder_avx2;
|
ctx->bit_sliced_adder = bit_sliced_adder_avx2;
|
||||||
ctx->bit_slice_full_subtract = bit_slice_full_subtract_avx2;
|
ctx->bit_slice_full_subtract = bit_slice_full_subtract_avx2;
|
||||||
} else
|
} else
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
ctx->rotate_right = rotate_right_port;
|
ctx->rotate_right = rotate_right_port;
|
||||||
|
@ -131,19 +131,24 @@ void gf2x_mod_mul_with_ctx(OUT pad_r_t *c,
|
|||||||
_INLINE_ void gf2x_ctx_init(gf2x_ctx *ctx)
|
_INLINE_ void gf2x_ctx_init(gf2x_ctx *ctx)
|
||||||
{
|
{
|
||||||
#if defined(X86_64)
|
#if defined(X86_64)
|
||||||
|
#if defined(OQS_DIST_X86_64_BUILD) || defined(OQS_USE_AVX512_INSTRUCTIONS)
|
||||||
if(is_avx512_enabled()) {
|
if(is_avx512_enabled()) {
|
||||||
ctx->karatzuba_add1 = karatzuba_add1_avx512;
|
ctx->karatzuba_add1 = karatzuba_add1_avx512;
|
||||||
ctx->karatzuba_add2 = karatzuba_add2_avx512;
|
ctx->karatzuba_add2 = karatzuba_add2_avx512;
|
||||||
ctx->karatzuba_add3 = karatzuba_add3_avx512;
|
ctx->karatzuba_add3 = karatzuba_add3_avx512;
|
||||||
ctx->k_sqr = k_sqr_avx512;
|
ctx->k_sqr = k_sqr_avx512;
|
||||||
ctx->red = gf2x_red_avx512;
|
ctx->red = gf2x_red_avx512;
|
||||||
} else if(is_avx2_enabled()) {
|
} else
|
||||||
|
#endif
|
||||||
|
#if defined(OQS_DIST_X86_64_BUILD) || defined(OQS_USE_AVX2_INSTRUCTIONS)
|
||||||
|
if(is_avx2_enabled()) {
|
||||||
ctx->karatzuba_add1 = karatzuba_add1_avx2;
|
ctx->karatzuba_add1 = karatzuba_add1_avx2;
|
||||||
ctx->karatzuba_add2 = karatzuba_add2_avx2;
|
ctx->karatzuba_add2 = karatzuba_add2_avx2;
|
||||||
ctx->karatzuba_add3 = karatzuba_add3_avx2;
|
ctx->karatzuba_add3 = karatzuba_add3_avx2;
|
||||||
ctx->k_sqr = k_sqr_avx2;
|
ctx->k_sqr = k_sqr_avx2;
|
||||||
ctx->red = gf2x_red_avx2;
|
ctx->red = gf2x_red_avx2;
|
||||||
} else
|
} else
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
ctx->karatzuba_add1 = karatzuba_add1_port;
|
ctx->karatzuba_add1 = karatzuba_add1_port;
|
||||||
@ -161,11 +166,13 @@ _INLINE_ void gf2x_ctx_init(gf2x_ctx *ctx)
|
|||||||
ctx->sqr = gf2x_sqr_vpclmul;
|
ctx->sqr = gf2x_sqr_vpclmul;
|
||||||
} else
|
} else
|
||||||
# endif // DISABLE_VPCLMUL
|
# endif // DISABLE_VPCLMUL
|
||||||
|
#if defined(OQS_DIST_X86_64_BUILD) || defined(OQS_USE_PCLMULQDQ_INSTRUCTIONS)
|
||||||
if(is_pclmul_enabled()) {
|
if(is_pclmul_enabled()) {
|
||||||
ctx->mul_base_qwords = GF2X_PCLMUL_BASE_QWORDS;
|
ctx->mul_base_qwords = GF2X_PCLMUL_BASE_QWORDS;
|
||||||
ctx->mul_base = gf2x_mul_base_pclmul;
|
ctx->mul_base = gf2x_mul_base_pclmul;
|
||||||
ctx->sqr = gf2x_sqr_pclmul;
|
ctx->sqr = gf2x_sqr_pclmul;
|
||||||
} else
|
} else
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
ctx->mul_base_qwords = GF2X_PORT_BASE_QWORDS;
|
ctx->mul_base_qwords = GF2X_PORT_BASE_QWORDS;
|
||||||
|
@ -46,13 +46,18 @@ typedef struct sampling_ctx_st {
|
|||||||
_INLINE_ void sampling_ctx_init(sampling_ctx *ctx)
|
_INLINE_ void sampling_ctx_init(sampling_ctx *ctx)
|
||||||
{
|
{
|
||||||
#if defined(X86_64)
|
#if defined(X86_64)
|
||||||
|
#if defined(OQS_DIST_X86_64_BUILD) || defined(OQS_USE_AVX512_INSTRUCTIONS)
|
||||||
if(is_avx512_enabled()) {
|
if(is_avx512_enabled()) {
|
||||||
ctx->secure_set_bits = secure_set_bits_avx512;
|
ctx->secure_set_bits = secure_set_bits_avx512;
|
||||||
ctx->is_new = is_new_avx512;
|
ctx->is_new = is_new_avx512;
|
||||||
} else if(is_avx2_enabled()) {
|
} else
|
||||||
|
#endif
|
||||||
|
#if defined(OQS_DIST_X86_64_BUILD) || defined(OQS_USE_AVX2_INSTRUCTIONS)
|
||||||
|
if(is_avx2_enabled()) {
|
||||||
ctx->secure_set_bits = secure_set_bits_avx2;
|
ctx->secure_set_bits = secure_set_bits_avx2;
|
||||||
ctx->is_new = is_new_avx2;
|
ctx->is_new = is_new_avx2;
|
||||||
} else
|
} else
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
ctx->secure_set_bits = secure_set_bits_port;
|
ctx->secure_set_bits = secure_set_bits_port;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user