From a55f514e1757ac53b6827b89135668d538ed114e Mon Sep 17 00:00:00 2001 From: "John M. Schanck" Date: Tue, 30 Mar 2021 12:21:19 -0400 Subject: [PATCH] HQC/avx2: align input to compute_syndromes --- ...ed_Implementation_hqc-rmrs-128_src_reed_solomon.c | 12 +++++++++--- ...ed_Implementation_hqc-rmrs-192_src_reed_solomon.c | 12 +++++++++--- ...ed_Implementation_hqc-rmrs-256_src_reed_solomon.c | 12 +++++++++--- hqc/update_patches.sh | 2 +- 4 files changed, 28 insertions(+), 10 deletions(-) diff --git a/hqc/patches/Optimized_Implementation_hqc-rmrs-128_src_reed_solomon.c b/hqc/patches/Optimized_Implementation_hqc-rmrs-128_src_reed_solomon.c index 7d5fd9d..2d5a486 100644 --- a/hqc/patches/Optimized_Implementation_hqc-rmrs-128_src_reed_solomon.c +++ b/hqc/patches/Optimized_Implementation_hqc-rmrs-128_src_reed_solomon.c @@ -357,14 +357,20 @@ } delta_counter += found; } -@@ -469,23 +437,20 @@ +@@ -469,23 +437,25 @@ * @param[out] msg Array of size VEC_K_SIZE_64 receiving the decoded message * @param[in] cdw Array of size VEC_N1_SIZE_64 storing the received word */ -void reed_solomon_decode(uint64_t* msg, uint64_t* cdw) { - uint8_t cdw_bytes[PARAM_N1] = {0}; +- uint16_t syndromes[2 * PARAM_DELTA] = {0}; +void reed_solomon_decode(uint8_t* msg, uint8_t* cdw) { - uint16_t syndromes[2 * PARAM_DELTA] = {0}; ++ union { ++ uint16_t arr16[16*CEIL_DIVIDE(2*PARAM_DELTA,16)]; ++ __m256i dummy; ++ } syndromes_aligned = {0}; ++ uint16_t *syndromes = syndromes_aligned.arr16; ++ uint16_t sigma[1 << PARAM_FFT] = {0}; uint8_t error[1 << PARAM_M] = {0}; uint16_t z[PARAM_N1] = {0}; @@ -385,7 +391,7 @@ // Compute the error polynomial error compute_roots(error, sigma); -@@ -497,10 +462,10 @@ +@@ -497,10 +467,10 @@ compute_error_values(error_values, z, error); // Correct the errors diff --git a/hqc/patches/Optimized_Implementation_hqc-rmrs-192_src_reed_solomon.c b/hqc/patches/Optimized_Implementation_hqc-rmrs-192_src_reed_solomon.c index e539636..4ea560f 100644 --- a/hqc/patches/Optimized_Implementation_hqc-rmrs-192_src_reed_solomon.c +++ b/hqc/patches/Optimized_Implementation_hqc-rmrs-192_src_reed_solomon.c @@ -354,14 +354,20 @@ } delta_counter += found; } -@@ -483,23 +447,20 @@ +@@ -483,23 +447,25 @@ * @param[out] msg Array of size VEC_K_SIZE_64 receiving the decoded message * @param[in] cdw Array of size VEC_N1_SIZE_64 storing the received word */ -void reed_solomon_decode(uint64_t* msg, uint64_t* cdw) { - uint8_t cdw_bytes[PARAM_N1] = {0}; +- uint16_t syndromes[2 * PARAM_DELTA] = {0}; +void reed_solomon_decode(uint8_t* msg, uint8_t* cdw) { - uint16_t syndromes[2 * PARAM_DELTA] = {0}; ++ union { ++ uint16_t arr16[16*CEIL_DIVIDE(2*PARAM_DELTA,16)]; ++ __m256i dummy; ++ } syndromes_aligned = {0}; ++ uint16_t *syndromes = syndromes_aligned.arr16; ++ uint16_t sigma[1 << PARAM_FFT] = {0}; uint8_t error[1 << PARAM_M] = {0}; uint16_t z[PARAM_N1] = {0}; @@ -382,7 +388,7 @@ // Compute the error polynomial error compute_roots(error, sigma); -@@ -511,10 +472,10 @@ +@@ -511,10 +477,10 @@ compute_error_values(error_values, z, error); // Correct the errors diff --git a/hqc/patches/Optimized_Implementation_hqc-rmrs-256_src_reed_solomon.c b/hqc/patches/Optimized_Implementation_hqc-rmrs-256_src_reed_solomon.c index 1d70ac9..a3f000f 100644 --- a/hqc/patches/Optimized_Implementation_hqc-rmrs-256_src_reed_solomon.c +++ b/hqc/patches/Optimized_Implementation_hqc-rmrs-256_src_reed_solomon.c @@ -365,14 +365,20 @@ } delta_counter += found; } -@@ -747,23 +715,20 @@ +@@ -747,23 +715,25 @@ * @param[out] msg Array of size VEC_K_SIZE_64 receiving the decoded message * @param[in] cdw Array of size VEC_N1_SIZE_64 storing the received word */ -void reed_solomon_decode(uint64_t* msg, uint64_t* cdw) { - uint8_t cdw_bytes[PARAM_N1] = {0}; +- uint16_t syndromes[2 * PARAM_DELTA] = {0}; +void reed_solomon_decode(uint8_t* msg, uint8_t* cdw) { - uint16_t syndromes[2 * PARAM_DELTA] = {0}; ++ union { ++ uint16_t arr16[16*CEIL_DIVIDE(2*PARAM_DELTA,16)]; ++ __m256i dummy; ++ } syndromes_aligned = {0}; ++ uint16_t *syndromes = syndromes_aligned.arr16; ++ uint16_t sigma[1 << PARAM_FFT] = {0}; uint8_t error[1 << PARAM_M] = {0}; uint16_t z[PARAM_N1] = {0}; @@ -393,7 +399,7 @@ // Compute the error polynomial error compute_roots(error, sigma); -@@ -775,10 +740,10 @@ +@@ -775,10 +745,10 @@ compute_error_values(error_values, z, error); // Correct the errors diff --git a/hqc/update_patches.sh b/hqc/update_patches.sh index 76a4d36..9e11f83 100755 --- a/hqc/update_patches.sh +++ b/hqc/update_patches.sh @@ -25,7 +25,7 @@ fi rm -rf ${PATCHES} mkdir -p ${PATCHES}/tmp/ -diff -ru --no-dereference ${V1} ${V2} > ${PATCHES}/tmp/p +diff -ruN --no-dereference ${V1} ${V2} > ${PATCHES}/tmp/p ( cd ${PATCHES}/tmp/ splitpatch ${PATCHES}/tmp/p