Skip to content

[WIP] primefield: add "fused" ops to FieldExt#1840

Draft
tarcieri wants to merge 1 commit into
masterfrom
primefield/fieldex-fused-ops
Draft

[WIP] primefield: add "fused" ops to FieldExt#1840
tarcieri wants to merge 1 commit into
masterfrom
primefield/fieldex-fused-ops

Conversation

@tarcieri

Copy link
Copy Markdown
Member

Exploring what might make sense here. Starting with:

  • add_mul: (a + b) * c
  • sub_mul: (a - b) * c

The only field backend where I've done an optimization for these is p521. Notably its multiply takes a LooseFieldElement so there is further potential for another add/sub operation in place of c, e.g. (a + b) * (c + d).

Before going any farther down this road it would be good to look at:

  • what works well for the k256 field element implementation
  • what we could potentially add to primefield::MontyFieldElement in a generic implementation

Exploring what might make sense here. Starting with:

- `add_mul`: (a + b) * c
- `sub_mul`: (a - b) * c

The only field backend where I've done an optimization for these is
`p521`. Notably its multiply takes a `LooseFieldElement` so there is
further potential for another add/sub operation in place of `c`, e.g.
`(a + b) * (c + d)`.

Before going any farther down this road it would be good to look at:
- what works well for the `k256` field element implementation
- what we could potentially add to `primefield::MontyFieldElement`
  in a generic implementation
@tarcieri

Copy link
Copy Markdown
Member Author

I'll note whether you do an add/sub-style operation first versus a mul is important to how these fusions would get leveraged in an algorithm like RCB, so I don't think the right answer is we should provide both add_mul and mul_add because e.g. p521 can't optimize mul_add but can optimize add_mul, so it doesn't help if a downstream user thinks mul_add is more convenient only to discover it offers no performance benefits.

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.

1 participant