Repository navigation
More shapes: polyhedra, frames, quadrics and lattices (#298) - #361
Conversation
|
@claude review |
|
Claude finished @rmrsk's task in 1m 13s —— View job Review of #361 (more shapes)This was a partial review. I did not build or run anything, and I did not read the quadric, helix or ray-form code in depth. I found no blocking issues in what I did read. Read closely
Skimmed
Checked and found sound
Nits (none blocking)
Still open per
|
|
@claude review Round 1's nits 1-3 are fixed in 875aae0 (nit 4 is about the CI checkout, not this branch: the working tree here is clean). Please read in depth what round 1 skipped: |
|
Claude finished @rmrsk's task in 2m 36s —— View job Review round 2 (#361): the code round 1 skippedI read all of it, but I did not build or run anything. The checks below are derivations by hand. I found one bug in the box frame's Findings
Checked and found sound
Minor
StateStill pending per |
|
Claude finished @rmrsk's task in 39s —— View job Review round 3 (#361): checking the round 2 fixesI read Round 2 fixes
Nits
Rest of the diffI found nothing new in the code I read in rounds 1 and 2. That covers the quadric roots, the polyhedron topology, the lattice scaling, StateStill pending per |
|
@claude review Round 3: the helix check now uses the exact closest distance between neighboring turns ( |
|
Claude finished @rmrsk's task in 36s —— View job Review round 4 (#361): checking the helix turn-distance fixI read The fix
Nits
Earlier roundsNothing changed in the quadrics, polyhedron topology, lattice, StateReview rounds have converged with no blocking finding. Still pending per |
The declarations and Doxygen contracts, proposed for approval before the implementation: ConvexPolyhedronSDF (the regular solids and the pyramid as static functions, any other from its planes), BoxFrameSDF, QuadricSDF (the hyperboloids and the paraboloid), SuperellipsoidSDF, SolidAngleSDF, VesicaSDF, HelixSDF, LatticeSDF (gyroid, Schwarz P and D, Neovius) and the pool-resident SampledGridSDF with heightField(). The bodies are stubs. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012mR37bzMSJWYPpFgLhy9sk
ConvexPolyhedronSDF with its exact distance (the farthest face's plane when the foot is on the face, else the nearest edge), the regular solids and the pyramid; BoxFrameSDF, exact inside too; QuadricSDF (hyperbola by a monotone root, parabola by a closed-form cubic); SuperellipsoidSDF as a gauge bound; SolidAngleSDF, VesicaSDF; HelixSDF searched turn by turn; LatticeSDF with the gradient bounds of each surface; SampledGridSDF with heightField(). Exact ray forms for the polyhedron, the frame and the quadrics. All are built-in tape types and .ebg shapes; the gallery model shows each. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012mR37bzMSJWYPpFgLhy9sk
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012mR37bzMSJWYPpFgLhy9sk
…ds example, the ShapeFamilies probe The grid's slope bound is taken cell by cell; a chain link as an elongated torus, tested and documented. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012mR37bzMSJWYPpFgLhy9sk
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012mR37bzMSJWYPpFgLhy9sk
…he frame and helix in double only Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012mR37bzMSJWYPpFgLhy9sk
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012mR37bzMSJWYPpFgLhy9sk
…'s root, Newton for the parabola's, one call site of the helix's window search, the frame's bars' spans computed once Each built-in shape's distance and ray form is copied into every level of every tape kernel. On a float proxy of two tape kernels (distance and firstHit), Release, these cut the compile from 414 s to 239 s (the base: 147 s). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012mR37bzMSJWYPpFgLhy9sk
…the solid; the grid's comments where they belong ConvexPolyhedronSDF takes its planes relative to their mean point, and the factories build their planes in double, so a small regular solid far from the origin keeps its vertices apart, also in float. The constructor from planes says to build a float solid near the origin. The grid's slope comment sits above the slope loop, and the height field's doc says what the bound is. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012mR37bzMSJWYPpFgLhy9sk
… tube must clear the next turn RayForm<BoxFrameSDF>::spans() gave a ray starting inside a bar an exact crossing at its start; it now starts open, as every other ray form's. HelixSDF required the tube under half the pitch, but neighboring turns are closer than the pitch across the line, pitch R / sqrt(R^2 + (pitch / 2 pi)^2): the check uses that, with a test of a tube that passed the old one and overlaps. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012mR37bzMSJWYPpFgLhy9sk
…st matches a prefix The closest approach of neighboring turns is not straight across: the constructor now finds it by sampling the first two turns and a golden-section refinement (host only), and the test's overlapping tube is one the previous closed form let through. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012mR37bzMSJWYPpFgLhy9sk
…s, not bit for bit GCC fuses multiply-adds under -std=c++17 too, and fused the new shapes' distances differently inlined into the tape's dispatch than called directly (one ulp, Release with FMA). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012mR37bzMSJWYPpFgLhy9sk
|
Claude finished @rmrsk's task in 20s —— View job Review round 5 (#361): the rebase and the new commitI read
|
…r a surface Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012mR37bzMSJWYPpFgLhy9sk
|
@claude review |
|
Claude finished @rmrsk's task in 21s —— View job Review round 6 (#361):
|
…Split, like the distance dispatch The three new shapes with ray forms added their traces to the tape's ray-leaf chains, and GCC laid out the whole chain afresh inside the renderer's loop: the float orthographic CSG frame (first shapes only) became slower. rayLeafRest() and leafHitRest() send the types from DispatchSplit on out of line on the host, as dispatchRest() does for the distance. A device compile is unchanged (ptxas output of the float tape kernels identical). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012mR37bzMSJWYPpFgLhy9sk
|
@claude review |
|
Claude finished @rmrsk's task in 19s —— View job Review round 7 (#361):
|
…ame's effect Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012mR37bzMSJWYPpFgLhy9sk
Every tape kernel compiles every built-in shape, whatever shapes its tape holds. The solvers of the heaviest new shapes (the frame's bars, the quadric's hyperbola and parabola roots, the superellipsoid's gauge, the helix' window search, the lattice field, and the convex polyhedron's distance, all loops) are now EBGEOMETRY_DEVICE_NOINLINE, so that a kernel holds one copy of each instead of one per inlined level. The cheap shapes stay inlined. The host is unchanged (the attribute is empty there). Measured on scratch builds (sm_86, CUDA 12.5): the studio's GPU build 852 s -> 123 s (main 100 s), the MeshTape probe build 7260 s -> about 590 s CPU (main 650 s); plain tape kernels keep 168 registers. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012mR37bzMSJWYPpFgLhy9sk
|
@claude review |
|
Claude finished @rmrsk's task in 22s —— View job Review round 8 (#361):
|
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012mR37bzMSJWYPpFgLhy9sk
SampledGridSDF, its tests, its probe cases, the SampledFields example and its page are removed, and the tape no longer lists it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012mR37bzMSJWYPpFgLhy9sk
|
@claude review Round 9: |
|
Claude finished @rmrsk's task in 43s —— View job Review round 9 (#361):
|
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012mR37bzMSJWYPpFgLhy9sk
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012mR37bzMSJWYPpFgLhy9sk
…of line on a device; CLAUDE.md and the FMA comment The ellipsoid's root finding and the polygon prism's cross-section distance are EBGEOMETRY_DEVICE_NOINLINE, like the new shapes' solvers: every built-in shape is compiled into every level of every tape kernel. CLAUDE.md states the rule (heavy parts of built-in shapes out of line on a device) and the ray program's leaf dispatch split. The pointDistances2 comment now says what GCC and Clang contract: GCC in every C++ mode, across the intrinsics too. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012mR37bzMSJWYPpFgLhy9sk
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012mR37bzMSJWYPpFgLhy9sk
|
@claude review |
|
Claude finished @rmrsk's task in 18s —— View job Review round 10 (#361):
|
Summary
Closes #298.
Background
#298 lists the primitives EBGeometry still lacks; #300 added the first nine. This pull request adds the rest in one:
polyhedra and frames, quadrics and special shapes, and lattices (triply periodic minimal surfaces). The sampled
distance fields (#298's section G) were in it and are taken out: the maintainer decided not to pursue them. Every built-in tape type
is copied into every level of every tape kernel, so each family is one type where its members share their code, and
users never list a shape type.
Solution
Eight new types, all built into the tape (
PrimitivesinEBGeometry_Tape.hpp, afterWedgeSDF), all in the .ebglanguage, and all in
InstantiateAll:ConvexPolyhedronSDFtetrahedron(),octahedron(),dodecahedron(),icosahedron(),pyramid()BoxFrameSDFQuadricSDFhyperboloid(),hyperboloidTwoSheets(),paraboloid()SuperellipsoidSDFSolidAngleSDFVesicaSDFHelixSDFLatticeSDFA chain link is a documented composition (
Elongateof a turned torus), tested against Quilez's exact link.Also: the language names (
tetrahedron...lattice,convex_polyhedron(plane(...), ...)), the gallery model andits figure, the
Shapesexample and its figure, a newShapeFamiliesprobe,the Sphinx pages (
ImplemCSG's families subsection,ImplemRays,RayTracing,LeavesAndSurfaces,LanguageShapes,Tape,Overview,GeometryRepresentations,PerformanceTesting,TestingLocally).Side-effects
Device compile cost. Every built-in shape is compiled into every level of every tape kernel. The heavy parts of
eight shapes are therefore
EBGEOMETRY_DEVICE_NOINLINE(out of line on a device, inlined on the host): the newconvex polyhedron's distance, the frame's bars, the quadric's hyperbola and parabola roots, the superellipsoid's
gauge, the helix's window search and the lattice's field, and also the existing ellipsoid's root finding and polygon
prism's cross-section. The cheap shapes stay inlined. CLAUDE.md now states the rule. sm_86, CUDA 12.5, base
mainat
344147cc(the first three rows measured with the sampled grid still in and before the ellipsoid and prismmoved):
GPU=CUDA, wall (-j7)Tape<float/double>,signedDistance()/firstHit()), Release[gpu]tests, build, wallThe receipt's probe builds: CUDA 4677 s to 4949 s CPU (+6%), peak memory 5.5 to 5.4 GB; host 765 s to 802 s (+5%).
Registers (the tape-change-check, sm_86,
__launch_bounds__(128), no minimum-blocks bound): the plain float tapekernels keep 168 registers, one
signedDistance()(stack 3040 to 3056 bytes) and sixteen (stack 3024, unchanged).A double
firstHit()kernel keeps 40 (stack 17568 to 17776, spills 484/868 to 620/968 bytes).Host: the ray program's two leaf dispatches (
dispatchRayLeaf,dispatchLeafHit) are split atDispatchSplitlike the distance dispatch (
rayLeafRest(),leafHitRest(),EBGEOMETRY_HOST_NOINLINE): without it, the new rayforms made GCC lay the chain out afresh in the renderer's loop. Device code is unchanged by it.
requireExactSDF()moved fromTestAnalyticSDF.cpptoTests/TestExactSDF.hpp, shared; a single shape in a tapeis compared with the shape within four ulps (plus a few epsilons near a surface), not bit for bit.
Alternative solutions
bodies: Release proxy 211 s to 218 s), so a merge would not reduce it. Not done.
#pragma unroll 1) for the trigonometry and powers: no compile time saved, float tape kernels movedfrom 168 to 40/128 registers. Reverted.
evaluateShared()does for the levels below thetop except the deepest: studio 104 s, proxy 89 s, but float tapes of simple shapes 11-24% slower and double
Regions13-21% slower on the device. Rejected.MaxCallDepth(proxy: depth 2 102 s, 1 83 s, 0 50 s): an API change, not pursued here.main: the double region-by-region query,ClosestPrimitive, theRayCrossingcrossings andDomainObjectgoback to within 3%, but the traced double armadillo shell (
RayShell/armadillo-tape/firstHit) becomes 8-11% slower,with the ray forms inlined or not; the float tapes (+4.5-6.5%) and the csg render (+4%) do not move. Not done: it
trades one MAJOR for another.
from the longer dispatch, not from the shapes' code. Not done; the maintainer chose the shapes.
Performance
Receipt:
Performance/receipts/more-shapes-532f1e6a.md(5497b3beagainst344147cc), both sections accepted bythe maintainer: "Yes, the performance regressions are acceptable."
TapeBVHUnion/maps64-as-written/signedDistance/float+8.1%: the float evaluator laid out afresh (a layout draw).MeshTape/tape/frame/float+4.7%,ClosestPrimitive/csg/closestPrimitive/float+3.6%.over 414 cases: -0.04%.
Domain/DomainObjectlabels (up to
Domain/particles/labels/double+10.0%),Regionsdouble (regionByRegion+7.0%), the csg renderframes (float, +3.7%),
RayCSG/scene-tape/firstHit-morton/float+4.3%, oneLaunchTuningfloat launch,ClosestPrimitiveparts (float). The 158 ray and render cases: geometric mean +0.03%.Where to look
Source/EBGeometry_AnalyticDistanceFunctions.hpp(fromConvexPolyhedronSDFtoLatticeSDF), including whichparts are
EBGEOMETRY_DEVICE_NOINLINE; the new ray forms at the end ofEBGeometry_AnalyticRayFormsImplem.hpp; the ray-leaf split inEBGeometry_Tape.hpp/EBGeometry_TapeImplem.hpp.5497b3be(the ellipsoid and prism out of line): the debug unit tests (1526); the CUDA build of thetest suite run on an RTX A4000 (CUDA 12.5, Release, 1654 of 1654, the
[gpu]tests included); Doxygen withwarnings as errors. On
549a19c(the grid taken out): release-test with both precisions (1523), the Sphinx HTML(9.1.1) with warnings as errors; nine
@claude reviewrounds, the last with no blocking finding. Earlier, on thesame shapes: debug-san. The full CI matrix passed on
3a581dfa(before the ellipsoid and prism moved).Reviewer checklist (to be completed by a human)
@claude review.🤖 Generated with Claude Code
https://claude.ai/code/session_012mR37bzMSJWYPpFgLhy9sk