Skip to content

[=]: optimize the gf inversion calculation#503

Merged
cherylsy merged 2 commits into
alibaba:mainfrom
penglei0:perf/optimize-gf-inversion-calculate
Nov 3, 2025
Merged

[=]: optimize the gf inversion calculation#503
cherylsy merged 2 commits into
alibaba:mainfrom
penglei0:perf/optimize-gf-inversion-calculate

Conversation

@penglei0

@penglei0 penglei0 commented Sep 2, 2025

Copy link
Copy Markdown
Contributor

Optimize the gf inversion calculation:

    1. do inversion calculation by lookup table
    1. inversion table is generated by the following python code:
import logging
import galois

def gen_inverse_table(degree: int = 8, irreducible_poly: str = "x^8 + x^4 + x^3 + x^2 + 1"):
    """
        Generate GF(2^degree) inverse table
    """
    GF = galois.GF(2**degree, irreducible_poly=irreducible_poly)
    size = 2**degree
    inv = [0] * size
    one = GF(1)
    for a in range(1, size):
        inv[a] = int(one / GF(a))  # 1/a in GF
    array_str = ", ".join(str(x) for x in inv)
    c_block = f"static const unsigned char xqc_galois_inv_table[{size}] = {{ {array_str} }};\n\n"
    logging.info("Inverse table generated for GF(2^%d) with irreducible polynomial %s",
                 degree, irreducible_poly)
    logging.info("Inverse table: %s", c_block)


if __name__ == '__main__':
    logging.basicConfig(level=logging.INFO)
    gen_inverse_table()

- 1. do inversion calculation by lookup table
@CLAassistant

CLAassistant commented Sep 2, 2025

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@cherylsy cherylsy left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good.

Comment thread src/transport/fec_schemes/xqc_galois_calculation.h
@cherylsy cherylsy merged commit b0f380e into alibaba:main Nov 3, 2025
6 of 8 checks passed
@penglei0 penglei0 deleted the perf/optimize-gf-inversion-calculate branch March 7, 2026 04:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants