crypto: Keep the safegcd 128-bit sums out of intx::uint128
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 52/100
- Tipo de issue
- Refactorización
- Claridad
- Bastante claro
- Estado de actividad
- Activo
- Stack tecnológico
- cpp
- Área
- backend, performance
Línea de trabajo
Read modarith.cpp and compare the safegcd matrix sum helpers with the two options described in the issue. First check the intx dependency status for chfast/intx#374 and whether it changes the addmul() workaround in #1803; otherwise, assess using unsigned __int128 under INTX_HAS_BUILTIN_INT128 while retaining the existing helpers for 32-bit targets. Done means the chosen approach preserves 32-bit support and is checked against the reported inversion benchmarks.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
The safegcd inversion (#1806) accumulates its matrix products in intx::uint128. GCC splits their carry chains (20 setb in modinv_scaled<uint256>) and keeps the sums partly in stack slots, the same problem as #1801.
Per inversion, Zen 3, random inputs over 4 moduli:
| GCC 16 | Clang 23 | |
|---|---|---|
| intx v0.15.0 (current) | 4640 cycles | 4119 cycles |
| intx master, with chfast/intx#374 (builtin add/sub for GCC, unreleased) | −2.2% | ±0 |
| intx master, helpers using builtin signed multiply and shift | −4.8% | +0.8% |
sums as unsigned __int128 |
−5.9% | −3.4% |
Options:
- Release intx with chfast/intx#374 and upgrade it here. Check whether this also makes the GCC workaround in
addmul()(#1803) unnecessary. - In
modarith.cpp, useunsigned __int128for the sums whenINTX_HAS_BUILTIN_INT128, keeping theintx::uint128helpers for 32-bit targets. This needs a second set of the 128-bit helpers:
#if INTX_HAS_BUILTIN_INT128
using Int128 = intx::builtin_uint128; // Two's complement.
uint64_t lo(Int128 x) noexcept { return static_cast<uint64_t>(x); }
uint64_t hi(Int128 x) noexcept { return static_cast<uint64_t>(x >> 64); }
Int128 mul_su(int64_t a, uint64_t b) noexcept
{
return Int128{static_cast<uint64_t>(a)} * b - (Int128{b & static_cast<uint64_t>(a >> 63)} << 64);
}
Int128 mul_ss(int64_t a, int64_t b) noexcept { return static_cast<Int128>(static_cast<__int128>(a) * b); }
Int128 sar64(Int128 x) noexcept { return static_cast<Int128>(static_cast<__int128>(x) >> 64); }
Int128 sext(int64_t x) noexcept { return static_cast<Int128>(static_cast<__int128>(x)); }
#else
// The current intx::uint128 versions.
#endif
A single generic version, with only the type alias under #if, gives −2.1% (GCC) and −1.7% (Clang). The rest of the gap cannot be closed in intx without changing the storage of uint<128>, whose constexpr word access needs the two uint64_t words.
- Lenguaje dominante
- C++
- Estrellas
- 979
- Forks
- 340
- Merge medio
- 12 h 16 min
- PR fusionados (30 d)
- 25
Preparar el entorno
- Incluye un Dockerfile o un archivo de Docker Compose
- Sin plantilla de pull request
- Sin guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de ipsilon/evmone
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 82/100
Los mantenedores suelen responder en 1 día
-
Dificultad 3/5 1-2 días Aptitud para principiantes 56/100
Los mantenedores suelen responder en 1 día
-
Dificultad 3/5 1-2 días Aptitud para principiantes 57/100
Los mantenedores suelen responder en 1 día
-
Dificultad 5/5 Más de una semana Aptitud para principiantes 12/100
Los mantenedores suelen responder en 1 día
-
Dificultad 5/5 Más de una semana Aptitud para principiantes 35/100
Los mantenedores suelen responder en 1 día
Todos los issues de ipsilon/evmone
Issues similares
-
Reference check: findingsAbiertoaudit-reference-check
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
schrodinger/pymol-open-source#532 ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 83/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
xlnt-community/xlnt#174 ·