Skip to content

Tec batch evaluation - #55

Merged
itchinda merged 9 commits into
masterfrom
TEC_BatchEvaluation
May 31, 2026
Merged

Tec batch evaluation#55
itchinda merged 9 commits into
masterfrom
TEC_BatchEvaluation

Conversation

@itchinda

Copy link
Copy Markdown
Owner

No description provided.

itchinda added 9 commits May 17, 2026 16:31
- Added lightweight MatrixView / ConstMatrixView abstractions
  for non-owning matrix access and submatrix extraction.
- Added row-based std::span accessors for safer contiguous access.
- Implemented subView support with stride-aware views.
- Added contiguous-memory detection via isContiguous().
- Improved const-correctness and added [[nodiscard]] annotations.
- Added utility methods:

  - empty()
  - sameShape()
  - isSquare()
  - row()
- Improved transpose() robustness:

  - Added alias-safe handling for M.transpose(M)
  - Added optimized in-place transpose for square matrices
  - Added safe fallback path for rectangular matrices
- Improved resize/assign documentation and API consistency.
- Expanded unit tests:

  - MatrixView and nested subviews
  - transpose aliasing
  - reshape preservation
  - const row access
  - move semantics
  - empty/square/shape utilities
  - contiguous vs non-contiguous views

Preparation work for future batched FEM kernels and view-based
assembly optimizations.
This major update transitions the CFEM++ integration engine from a
single-point scalar evaluation model to a high-performance, SIMD-friendly
batch evaluation architecture using Structure-of-Arrays (SoA).

Core Architecture & Reference Element:
- Redesigned `ReferenceElement` API to fully support batch processing
  (`evaluateShapesBatch`, `computeMappingBatch`).
- Introduced Strict Separation of Concerns for mappings: `MappingInfoBatch`
  acts as the geometric data owner (Jacobian, DetJ), while `MappingInfoBatchView`
  acts as a zero-copy view for physical derivatives.
- Implemented dimensional masking in `computePhysicalFirstDerivativesBatch`
  to correctly handle embedded manifolds (e.g., 2D surface in 3D space)
  based on `refDim` vs `spatialDim`.

Memory Management & Optimization:
- Integrated `EvalContext` with a thread-local Arena memory allocator to
  eliminate dynamic OS allocations (`new`/`malloc`) inside the hot loops.
- Implemented a `Bookmark/Release` mechanism to safely manage temporary
  AST evaluation buffers while preserving physical derivatives.
- Applied Loop-Invariant Code Motion by precomputing SIMD padded strides
  (`kernel_utils::computePaddedStride`) inside the Phase 2 cache build.

Volume Integration (`integrate`):
- Rewrote the integration loop to utilize OpenMP parallelization over cells.
- Hoisted Jacobian and determinant computations out of the quadrature loop
  for affine elements.

Boundary Integration (`integrateBoundary`):
- Implemented the "Hybrid View" architecture: successfully combines facet
  geometry (normals, dS) with parent cell inverse Jacobians (for gradients)
  in a single zero-copy view.
- Added automatic projection of boundary quadrature points into the parent
  reference space (`projectFacetRefCoordToCellRefCoord`).

Bug Fixes & Documentation:
- Fixed a Segmentation Fault caused by blind 3D array access during physical
  derivative computation on 2D elements.
- Added comprehensive Doxygen documentation covering thread-safety,
  Arena memory lifecycles, and the Hybrid Geometry architecture.
@itchinda
itchinda merged commit 8ee1f51 into master May 31, 2026
4 checks passed
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