Repository navigation
Embedded c target - #13
Merged
Merged
Conversation
Every piece of target text the body renderer produces now goes through a Dialect passed at construction (hawk/emit/dialect.py); today's C++ spelling moves, unchanged, into AetherDialect (dialect_aether.py). The traversal and policy stay in the renderer. Host and cuda output is byte-identical (checked over 488 translation units), with one deliberate exception: a lookup or wide-input plane read twice, and a rank>=1 lookup plane read at all, no longer emit a dead load at the sample index. Dialect.exit_if spells the if that opens a head/middle break so a C dialect can avoid redundant parentheses. Signed-off-by: Rory <Rory@3va.studio>
A kernel now carries the sha256 of its source (None when it cannot be read), carried through hawk.steps. Nothing consumes it yet; the embedded target records it in the header and report. Useful for auditing in embedded generation. Signed-off-by: Rory <Rory@3va.studio>
hawk.embedded.render / check / export emit a kernel as <name>.c, <name>.h and <name>.embedded.json: serial, a plain structure-of-arrays ABI, a status-returning entry, no eagle or aether header. A verify pass over the IR refuses unsupported features by name, records budgets, index sites, the floating-point domain and the interface contract; a text audit, strict cc (c99 and c11) and cppcheck's MISRA addon check the result. The arithmetic comes from aether_dsc.c_core, so hawk now requires aether-dsc>=0.2.4. Also adds the lazy hawk.embedded submodule door, the cppcheck CI install, and the two_fin fixture. Tests include a ctypes bit-identity harness against the host build. Signed-off-by: Rory <Rory@3va.studio>
c joins host and cuda as a build target. A c-only build writes the three C files and no manifest or sidecar; host+c keeps exec_targets host-only. The profile, each kernel's source digest and the aether core version are terms of the unit key (tag unit-key/6). hawk.load and hawk.artifact.plugins refuse a c-only build with an error naming the c target. Signed-off-by: Rory <Rory@3va.studio>
Reference page (docs/content/embedded.md), a runnable example notebook, index and pointer edits, contributing note, the Unreleased changelog entry, and docs/superpowers excluded from the Sphinx tree. Signed-off-by: Rory <Rory@3va.studio>
cppcheck does not read system headers in the MISRA run, and older releases (2.13, the Ubuntu 24.04 package CI installs) then report every INT64_C(...) and UINT32_C(...) as a call to an undeclared function (Rule 17.3). run_checks now writes a small cppcheck library declaring those macros as glibc defines them and passes it with --library. Nothing is suppressed and the emitted C is unchanged. With the macros visible, 2.13 also reports a real Rule 2.2 finding: a runtime-count loop header scaled by a step of magnitude 1, `(12 - cnt) * 1`. The C dialect now omits the multiply when the step is 1. verify.py's imports are re-sorted (lint only). Signed-off-by: Rory <rorytyrrell2@gmail.com>
The double-promotion row planted `(float)sqrt((float)x)`: Clang refuses a float passed to sqrt's double parameter under -Wdouble-promotion, GCC does not, so on CI's GCC the check raised nothing. The planted unit now promotes a float to meet a double operand, which both compilers refuse, and the row asserts the flag's name rather than Clang's wording. A bare sqrt in a float32 unit stays pinned by the float32 render rows. Signed-off-by: Rory <rorytyrrell2@gmail.com>
amasat01
previously approved these changes
Oct 22, 2026
amasat01
left a comment
Owner
There was a problem hiding this comment.
All good - let's talk and discuss a permanent setup for multi-backend language support!
Like for aether, make sure you bump the release versions and that conflicts are resolved (other than all green in CI)
Collaborator
Author
|
macOS tests failing on missing pipit package for aether 0.2.7 which should be released soon. |
amasat01
previously approved these changes
Oct 23, 2026
amasat01
approved these changes
Oct 23, 2026
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.
Created a 'dialect' construct to allow hawk to emit either the c-core added to aether (PR link) or the original aether cpp dialect.
This allows for C-code emission alongside the usual CPU/GPU aether code.
In order to separate the embedded C code generation, an "embedded" module has been added also. Later this might be better generalised by a dedicated dialect handler but for now this is the minimal diff change required to emit embedded code.