Skip to content

Conversation

seiko2plus
Copy link
Member

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

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
Copy link

@Copilot Copilot AI left a 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'
Copy link

Copilot AI Oct 7, 2025

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'.

Suggested change
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'
Copy link

Copilot AI Oct 7, 2025

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'.

Suggested change
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) {
Copy link

Copilot AI Oct 7, 2025

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) @ ";",
Copy link

Copilot AI Oct 7, 2025

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) @ ";",
Copy link

Copilot AI Oct 7, 2025

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.

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