Skip to content

Add expression keyword to emit_dirichlet - #69

Merged
xtalax merged 1 commit into
masterfrom
feat/emit-dirichlet-expression
Nov 6, 2026
Merged

xtalax merged 1 commit into
masterfrom
feat/emit-dirichlet-expression

Conversation

@xtalax-droid

Copy link
Copy Markdown
Collaborator

GPU support needs the generated Dirichlet functions as Expr, so that a device pass can retype literals and build a device-callable RuntimeGeneratedFunction. emit_kernels and emit_strong already take expression = Val(true). This PR gives emit_dirichlet the same keyword. It is CPU-only, has no Ferrite dependency, and can merge on its own.

Change

In src/kernels.jl, emit_dirichlet(analysis; expression = Val(false)) passes expression through to the shared compile helper, the same way emit_strong does. With Val(true) the return value keeps the same (piece, field, g) shape, with the generated Expr in place of each g. The docstring is updated to match.

The default behaviour is unchanged. The default path (expression = Val(false)) is already covered end to end: src/frontend.jl calls emit_dirichlet(an) for every problem with an essential condition, and the existing Kernels tests and Frontend boundary tests pass unchanged.

Tests

The new file test/Kernels/dirichlet_expression.jl covers three conditions: a constant g (U ~ 1), a space-dependent g (U ~ 0.1y + x) and a time-dependent g (U ~ sin(t) x). Each generated Expr is built into a RuntimeGeneratedFunction in FiniteElementMethod's own cache. That function is compared with isequal against the default compiled g at random points (X, T, P), and the piece and field are checked as well.

The constant g still compiles to an Int literal and returns Int64. This PR leaves that alone; the device pass will retype it.

Results:

  • GROUP=Kernels: dirichlet_expression.jl 22/22, kernels.jl 345/345, in 1m06s.
  • test/Frontend/boundaries.jl: 23/23 and 19/19.
  • Runic 1.13 --check passes on both touched files.

This branch merges cleanly with #64 and #65: the test lives in a new file rather than test/Kernels/kernels.jl.


🤖 Posted by an AI agent · harness: Claude Code 2.1.318 · model: claude-opus-5-5
Review: unreviewed
Session: f7b46bdf-7cc3-44dd-b8a4-9205616ff6ac

GPU support needs the generated Dirichlet functions as Expr so a device pass can retype literals and build a device-callable function. emit_kernels and emit_strong already take expression = Val(true); emit_dirichlet now does the same. Default behaviour is unchanged.

Agent-Harness: Claude Code 2.1.318
Agent-Model: claude-opus-5-5
Agent-Session: f7b46bdf-7cc3-44dd-b8a4-9205616ff6ac
Agent-Review: unreviewed
Co-authored-by: Claude Code <agent@noreply.juliahub.com>
@github-actions

github-actions Bot commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

Benchmark Results (Julia v1)

Time benchmarks
master 0e6a133... master / 0e6a133...
construction/heat P1 10x10 7.63 ± 0.4 ms 7.84 ± 0.52 ms 0.973 ± 0.082
construction/heat P1 20x20 10.2 ± 0.16 ms 10.4 ± 0.28 ms 0.982 ± 0.031
time_to_load 5.45 ± 0.026 s 5.47 ± 0.035 s 0.995 ± 0.008
Memory benchmarks
master 0e6a133... master / 0e6a133...
construction/heat P1 10x10 0.0393 M allocs: 2.11 MB 0.0393 M allocs: 2.11 MB 1
construction/heat P1 20x20 0.0702 M allocs: 4.73 MB 0.0702 M allocs: 4.73 MB 1
time_to_load 0.2 k allocs: 11.8 kB 0.2 k allocs: 11.8 kB 1

@xtalax
xtalax merged commit e847504 into master Nov 6, 2026
51 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.

2 participants