-
-
Notifications
You must be signed in to change notification settings - Fork 2
FEAT: Python/Sollya driver that used for generates LUT/Constants #5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Argument reduction & tables: - Payne–Hanek tables via chunked 4/π per exponent range (`reduction.h.sol`) - π splits for FMA/non-FMA and float/double (`constants.h.sol`) - Compact 4-term (value + derivatives) LUTs (`approx.h.sol`) - Precomputed sin/cos(k·π/16) for quadrant handling (`kpi16-inl.h.sol`) Sollya-driven codegen pipeline: - Tooling lives in `tools/sollya` with shared helpers - CLI: `spin sollya [-f]` (via `.spin/cmds.py`) to (re)generate headers - Project wiring: `pyproject.toml` matters for spin
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR introduces a Python/Sollya driver system for automatically generating lookup tables and mathematical constants used in trigonometric computations. The system enables precise generation of argument reduction tables, π splits for different architectures, compact lookup tables for trigonometric approximations, and precomputed sin/cos values.
Key changes include:
- Implementation of a comprehensive Sollya utility library with floating-point type descriptors and code generation helpers
- Python-based CLI tool for processing Sollya scripts with parallel execution and colored output
- Integration with the project's build system through pyproject.toml and spin commands
Reviewed Changes
Copilot reviewed 10 out of 11 changed files in this pull request and generated 5 comments.
Show a summary per file
File | Description |
---|---|
tools/sollya/core.sol | Core Sollya utility library with type descriptors, bit manipulation, and code generation procedures |
tools/sollya/main.py | Python CLI driver for processing Sollya scripts with parallel execution and error handling |
tools/sollya/init.py | Package initialization exposing the main function |
pyproject.toml | Project configuration with spin command integration |
npsr/trig/data/reduction.h.sol | Sollya script generating Payne-Hanek reduction tables for trigonometric functions |
npsr/trig/data/kpi16-inl.h.sol | Script generating sin/cos lookup tables for k·π/16 values with packed low-precision parts |
npsr/trig/data/data.h.sol | Master header inclusion script for trigonometric data tables |
npsr/trig/data/constants.h.sol | Script generating π-related constants for Cody-Waite reduction in various precisions |
npsr/trig/data/approx.h.sol | Script generating 4-element lookup tables for fast trigonometric approximation |
.spin/cmds.py | Spin command integration for the sollya code generation tool |
Comments suppressed due to low confidence (1)
tools/sollya/core.sol:1
- Corrected spelling of 'Tuble' to 'Table'.
// Sollya utility functions for generating C++ header files with mathematical constants and lookup tables
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
|]; | ||
|
||
Prepend @ $.pre; | ||
Append @ [|"inline HWY_ATTR void _dummy_supress_unused_target(){}"|]; // to suppress unused attribute 'target' in '#pragma clang attribute push' |
Copilot
AI
Oct 7, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Corrected spelling of 'supress' to 'suppress'.
Append @ [|"inline HWY_ATTR void _dummy_supress_unused_target(){}"|]; // to suppress unused attribute 'target' in '#pragma clang attribute push' | |
Append @ [|"inline HWY_ATTR void _dummy_suppress_unused_target(){}"|]; // to suppress unused attribute 'target' in '#pragma clang attribute push' |
Copilot uses AI. Check for mistakes.
|]; | ||
|
||
Prepend @ $.pre; | ||
Append @ [|"inline HWY_ATTR void _dummy_supress_unused_target(){}"|]; // to suppress unused attribute 'target' in '#pragma clang attribute push' |
Copilot
AI
Oct 7, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extra space in 'to suppress unused' should be 'to suppress unused'.
Append @ [|"inline HWY_ATTR void _dummy_supress_unused_target(){}"|]; // to suppress unused attribute 'target' in '#pragma clang attribute push' | |
Append @ [|"inline HWY_ATTR void _dummy_supress_unused_target(){}"|]; // to suppress unused attribute 'target' in '#pragma clang attribute push' |
Copilot uses AI. Check for mistakes.
// pOffset - Additional shift offset (70 for float, 137 for double) | ||
// These magic constants position the bits of 4/π correctly | ||
// for the extended precision multiplication scheme | ||
procedure ReductionTuble_(pT, pOffset) { |
Copilot
AI
Oct 7, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Corrected spelling of 'Tuble' to 'Table'.
Copilot uses AI. Check for mistakes.
// The offset 70 means we extract 4/π bits starting from position (exp - 57) | ||
// This aligns with the fractional extraction: 9 + 5 + 18 + 14 = 46 = 2×23 bits | ||
"template <> inline constexpr uint32_t kLargeReductionTable<float>[] = " @ | ||
ReductionTuble_(Float32, 70) @ ";", |
Copilot
AI
Oct 7, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function name should be corrected to match the fixed spelling.
Copilot uses AI. Check for mistakes.
// The offset 137 means we extract 4/π bits starting from position (exp - 886) | ||
// This aligns with the fractional extraction: 12 + 28 + 24 + 40 = 104 = 2×52 bits | ||
"template <> inline constexpr uint64_t kLargeReductionTable<double>[] = " @ | ||
ReductionTuble_(Float64, 137) @ ";", |
Copilot
AI
Oct 7, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function name should be corrected to match the fixed spelling.
Copilot uses AI. Check for mistakes.
Argument reduction & tables:
reduction.h.sol
)constants.h.sol
)approx.h.sol
)kpi16-inl.h.sol
)Sollya-driven codegen pipeline:
tools/sollya
with shared helpersspin sollya [-f]
(via.spin/cmds.py
) to (re)generate headerspyproject.toml
matters for spin