Repository navigation
fe_lab: jobs as sliced scheduler tasks with a progress bar; LBIE, SDF and resize a slice at a time - #890
Merged
Conversation
…ce at a time cvc::schedule_sliced_job (cvc/core/sliced_task.h) runs a cvc::sliced_job as a state_exec process: cooperative slices per frame where there are no threads, background-pool chunks where there are. It is the overlay tasks' machinery made generic, and cvc::tf's overlay tasks now run on it. cvc::fem::stepped_solve runs solve_poisson, solve_heat and laplacian_eigenmodes a slice at a time: chunked libigl assembly, a sliced sparse build, Dirichlet elimination, and a sparse LDL^T over Eigen's AMD ordering (src/cvc/geometry/sliced_ldlt), column by column. Results match the one-shot solves to rounding.
DistanceTransform's init and transform become one stage machine (triangle cells, near-surface marks, the x / y / z line passes, near and far distances), stepped in budgets of cells and voxels; init() and transform() run the same loops to the end. cvc::sdf_stepper wraps it with sdf()'s v2 setup and box expansion, and gives sdf()'s volume bit for bit. Also frees transform1D's scratch on its early return.
The octree's operations -- setting the volume, collapse, QEFs, traversal, extraction, quality improvement -- become stage machines stepped in budgets of units (a voxel, an octree cell, a leaf's edge, a vertex of a flow round, 64 entries of an array being filled), and so do Mesher's extractMesh and qualityImprove, to_geometry, and a new LBIE::mesh_stepper that is do_mesh and do_mesh_geometry. The loops' bodies are the old ones, moved; the one-shot calls run the same steps to the end and give the same meshes bit for bit (93 configurations of iso, tetrahedralize, hexahedralize and tetrahedralize2 compared with the previous code). cvc::mesher_stepper makes those steppers from the four meshers' own arguments, gives their geometry however it is stepped, and rethrows a failure on every later step. Edge contraction, Joe-Liu, minimal volume and optimization step a round at a time; resampling a volume that is not (2^n+1)^3 and converting one to float, property interpolation, and the FASTCONTOURING and LIBISOCONTOUR extractions are one piece each. mesh_extract no longer computes B-spline coefficients for normals that never read them.
A stepped mesh's last steps freed the octree (a QEF is an allocation of its own) and the mesh at once. The QEFs now go 16 a unit and the arrays one at a time, and to_geometry_stepper reserves its arrays rather than growing them. A hexahedral vertex's templates count 256 units, as they cost about as much. Measured at a budget of 64 on 65^3 volumes, a step's median is a few microseconds and its 99.9th percentile under half a millisecond; the rest are a handful of one-off allocations and the resampling of a volume that is not (2^n+1)^3.
…epper) The contour spectrum's resumable copy of resizeTrilinearCPU's dimension mode moves to src/cvc/volume/resample_detail.h, and cvc::resize_stepper drives it a range of output voxels per step: the same taps, edge rule and conversion, so the voxels are bit-identical to volume::resize(dimension)'s CPU path. LBIE's resample to (2^n+1)^3 now uses it (a new "resampling" stage, 4 voxels a unit), so meshing a 64^3 volume no longer spends one long step resampling it to 65^3. Twenty-five one-shot meshes of resampled volumes (tetrahedralize with and without geometric flow, iso, hexahedralize, tetrahedralize2's layer; float spheres at 30^3 and 64^3, a torus, a non-cubic float and a uchar volume) hash the same before and after.
sdf_stepper steps SDF_IGL too: sdf_igl's AABB tree, then its winding-number hierarchy, a step each, then the grid's nodes a range per step, the same query points, so the volume is sdf()'s bit for bit (AlgorithmTest.SDFIglSteppedMatchesOneShot). fem_gallery's 48^3 bunny SDF had been one 1.3 s step. A bounded DistanceTransform step now ends where its stage does, so a budget sized for a cheap stage is not spent in a dear one (a 145 ms step in the tf_binding test), and a near voxel costs a unit per triangle it tests rather than a flat 20.
…ooperatively For running a native build the way a single-threaded wasm page runs: every `automatic` task is sliced on the scheduler thread. Read once from the environment.
…; a progress widget fe_lab's jobs leave its async lanes for the app's state_exec scheduler (cvc/core/sliced_task.h): a few milliseconds a frame on the scheduler thread where there are no threads (single-threaded wasm), ~250 ms chunks on the background pool where there are. Every stage steps: - load: an SDF source's SDF (cvc::sdf_stepper, v2 or libigl), a volume source's resample to source.dim (cvc::resize_stepper); - mesh: LBIE (cvc::mesher_stepper; tetrahedralize_interval's bounds shared through interval_mesher_bounds), then the hex boundary (CutawayStepper), the tets' orientation, boundary and quality, a volume source's isosurface (stepped) and the transfer onto the smooth surface (a mesh_locator, a range of vertices a step); - solve: cvc::fem::stepped_solve (Poisson, heat with its snapshots and stop, modes); - the elements view's cut-away (CutawayStepper) and the field view's cut (cvc::tet_slicer, slice_tets a range of tetrahedra at a time). run_fe_mesh, run_fe_solve and cut_away go; fe.phase publishes the running stage and percent. Ariadne gains a read-only `progress:` widget: bind's number over [lo, hi] with an overlay's text, an ImGui progress bar (a text bar on other backends). It precedes `overlay` in the loader's type scan, since a bar's `overlay:` is its text. fe_controls and fem_gallery show the job's progress and phase with it. The realize, tf_binding and fe_interval tests pump the scheduler while they wait on fe_lab's jobs; all pass threaded and with CVC_SLICED_THREADING=cooperative (save the two checks that assert automatic picks threads natively). On fem_gallery's 48^3 bunny the longest steps left are whole-mesh passes run once: reading the mesh file (~107 ms), libigl's AABB tree (~80-107 ms) and the tets' boundary (~100 ms).
transfix
enabled auto-merge (squash)
October 30, 2026 04:04
This was referenced Oct 30, 2026
transfix
added a commit
that referenced
this pull request
Oct 30, 2026
…d builds (#908) LbieMesherTest.SteppedTetrahedralize2MatchesOneShot took 127-230 s in the Debug package lanes (8.7 s in Release) and went past ctest's 300 s on loaded runners: master 276887d's libcvc-debug, all 3 tries. Each case meshes its volume three times (one-shot, whole, sliced). Its siblings SteppedTetrahedralizeMatchesOneShot and AlgorithmTest.MesherSteppedMatchesOneShotOnTheBunny, and the older GeometryTest.QualityImproveTetrahedralMesh, timed out the same way on master 2d40710's libcvc-debug-grpc. Unoptimized builds now mesh 17-sample stepped volumes (33 optimized) and a 16-wide bunny SDF (32), decided by the optimizer as the locks tests do, not by NDEBUG. With the small sizes forced in a Release build every check passes (step counts, phases) in 3.5-5x less time.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
fe_lab's long-running work (loading a source, meshing, solving, and its cut-away and slice views) now runs as sliced tasks on the app's state_exec scheduler, and the FEM controls show a progress bar.
fe.progress/fe.phasemove while a job runs.Pieces
cvc/core/sliced_task.h: a scheduler runner for any resumable job (step(budget)/phase()/progress()/cancel()). It was moved out ofoverlay_tasks, and the tf overlays now run on it.CVC_SLICED_THREADING=cooperativeruns everyautomatictask cooperatively, so a native build runs the way single-threaded wasm does.cvc::fem::stepped_solve: Poisson, heat (with snapshots and stop) and modes.cvc::sdf_stepper: SDF v2's distance transform runs a stage at a time, and SDF_IGL a range of grid nodes at a time. Both are bit-identical tosdf().cvc::mesher_stepper: LBIE's iso, tetrahedralize, hexahedralize and tetrahedralize2 run a slice at a time.cvc::resize_stepper:volume::resize(dimension)a range of voxels at a time, bit-identical to its CPU path.source.dimresample both use it.cvc::tet_slicer:slice_tetsin pieces, for fe_lab's field-view cut.progress:widget: a read-only bar showingbindover [lo,hi] with anoverlaytext.Verified
Test suites, all passing:
Single-threaded behaviour: the cvcgl programs also pass with
CVC_SLICED_THREADING=cooperative. The only exceptions are two checks that assertautomaticpicks threads natively, which the override switches off by design.Bit-identity:
resize_stepper.fem_gallery snapshots: mid-load, the bar reads "distances 39%"; the finished frame shows the Poisson field.
Known limits
Remaining long steps: each of these runs once per job, as one step, on the 48³ bunny:
igl::boundary_facets), ~100 ms;Everything else is a few ms per call.
Not covered here: