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:
Douglas Stebila 2021-08-05 09:41:26 -04:00 committed by GitHub
parent 1d31f51fa4
commit 2049555b7c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 22 additions and 3 deletions

View File

@ -66,6 +66,8 @@ if(OQS_ENABLE_KEM_bike_l1 OR OQS_ENABLE_KEM_bike_l3)
else()
set(CPP_DEFS_R3 ${CPP_DEFS_R3} DISABLE_VPCLMUL)
endif()
else()
set(CPP_DEFS_R3 ${CPP_DEFS_R3} DISABLE_VPCLMUL)
endif()
if(ARCH_X86_64)

View File

@ -61,17 +61,22 @@ typedef struct decode_ctx_st {
_INLINE_ void decode_ctx_init(decode_ctx *ctx)
{
#if defined(X86_64)
#if defined(OQS_DIST_X86_64_BUILD) || defined(OQS_USE_AVX512_INSTRUCTIONS)
if(is_avx512_enabled()) {
ctx->rotate_right = rotate_right_avx512;
ctx->dup = dup_avx512;
ctx->bit_sliced_adder = bit_sliced_adder_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->dup = dup_avx2;
ctx->bit_sliced_adder = bit_sliced_adder_avx2;
ctx->bit_slice_full_subtract = bit_slice_full_subtract_avx2;
} else
#endif
#endif
{
ctx->rotate_right = rotate_right_port;

View File

@ -131,19 +131,24 @@ void gf2x_mod_mul_with_ctx(OUT pad_r_t *c,
_INLINE_ void gf2x_ctx_init(gf2x_ctx *ctx)
{
#if defined(X86_64)
#if defined(OQS_DIST_X86_64_BUILD) || defined(OQS_USE_AVX512_INSTRUCTIONS)
if(is_avx512_enabled()) {
ctx->karatzuba_add1 = karatzuba_add1_avx512;
ctx->karatzuba_add2 = karatzuba_add2_avx512;
ctx->karatzuba_add3 = karatzuba_add3_avx512;
ctx->k_sqr = k_sqr_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_add2 = karatzuba_add2_avx2;
ctx->karatzuba_add3 = karatzuba_add3_avx2;
ctx->k_sqr = k_sqr_avx2;
ctx->red = gf2x_red_avx2;
} else
#endif
#endif
{
ctx->karatzuba_add1 = karatzuba_add1_port;
@ -161,11 +166,13 @@ _INLINE_ void gf2x_ctx_init(gf2x_ctx *ctx)
ctx->sqr = gf2x_sqr_vpclmul;
} else
# endif // DISABLE_VPCLMUL
#if defined(OQS_DIST_X86_64_BUILD) || defined(OQS_USE_PCLMULQDQ_INSTRUCTIONS)
if(is_pclmul_enabled()) {
ctx->mul_base_qwords = GF2X_PCLMUL_BASE_QWORDS;
ctx->mul_base = gf2x_mul_base_pclmul;
ctx->sqr = gf2x_sqr_pclmul;
} else
#endif
#endif
{
ctx->mul_base_qwords = GF2X_PORT_BASE_QWORDS;

View File

@ -46,13 +46,18 @@ typedef struct sampling_ctx_st {
_INLINE_ void sampling_ctx_init(sampling_ctx *ctx)
{
#if defined(X86_64)
#if defined(OQS_DIST_X86_64_BUILD) || defined(OQS_USE_AVX512_INSTRUCTIONS)
if(is_avx512_enabled()) {
ctx->secure_set_bits = secure_set_bits_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->is_new = is_new_avx2;
} else
#endif
#endif
{
ctx->secure_set_bits = secure_set_bits_port;