Repository navigation
feat(rocke): prototype device-side printing - #10841
tenpercent wants to merge 14 commits into
Conversation
0d9c132 to
6c85182
Compare
✅ All Checks Passed — Ready for Review
📖 Need help? See the Policy FAQ for details on every check and how to fix failures. |
|
🎉 All checks passed! This PR is ready for review. |
|
This pull request has been inactive for 25 days and will be marked as stale. If you would like to keep this PR open, please:
This PR will be automatically closed in 5 days if no further activity occurs. |
|
@copilot resolve the merge conflicts in this pull request |
…ke/aick-1989-device-print # Conflicts: # dnn-providers/hip-kernel-provider/rocke/platform/python/rocke/core/ir.py # dnn-providers/hip-kernel-provider/rocke/platform/python/rocke/core/lower_llvm.py # dnn-providers/hip-kernel-provider/rocke/platform/python/rocke/helpers/compile.py Co-authored-by: tenpercent <4273004+tenpercent@users.noreply.github.com>
Conflicts are resolved by merge commit |
|
This pull request has been inactive for 25 days and will be marked as stale. If you would like to keep this PR open, please:
This PR will be automatically closed in 5 days if no further activity occurs. |
|
Hi @tenpercent , recommend to update the PR or close PR #10841 — device-side printing prototype (tenpercent, AICK-1989) — 🟠 REJECT: stale draft; rebase or closePrior reviews: none (bots: stale ×2; Copilot-agent merge
Utility: 🟢 Sound concept — mirrored printf; Legend: 🔴 blocking · 🟠 should-fix · 🟡 minor nit · 🟢 info/good |
Preserve compiler selection, LLVM layouts and temporal hints; append the new opcode without renumbering existing C values. Install the native test and cover device-library linking across lowering backends. Keep external OCKL functions outside the compiler intrinsic-domain probe.
There was a problem hiding this comment.
🟡 Changes recommended
Ambient validation knobs, malformed-input normalization, and incomplete COMGR flag propagation leave supported compilation paths inconsistent.
5 open findings
What changed in this PR
Adds cross-engine device-side printing to rocKE, including validated IR records, OCKL lowering, conditional device-library linking, and runtime coverage.
Changes:
- Adds Python and C/C++ device-print APIs, validation, serialization, and LLVM lowering.
- Links ROCm device libraries when printing is detected.
- Adds parity, host, GPU, architecture-domain, and installation tests.
| File | Description |
|---|---|
platform/tools/gen_arch_domain.py |
Excludes device-library declarations from intrinsic probes. |
platform/tests/runtime/test_device_print_gpu.py |
Validates GPU print output. |
platform/tests/runtime/device_print_gpu_runner.py |
Builds and launches the print test kernel. |
platform/tests/README.md |
Documents runtime coverage. |
platform/tests/instances/parity/device_print_emit.py |
Adds Python parity emitter. |
platform/tests/instances/parity/device_print_emit.c |
Adds C parity emitter. |
platform/tests/core/test_device_print.py |
Tests Python construction, verification, lowering, and linking. |
platform/tests/core/test_arch_domain_artifact.py |
Tests exclusion of OCKL declarations. |
platform/tests/core/device_print.cpp |
Tests the native C API. |
platform/tests/CMakeLists.txt |
Registers and installs the native test. |
platform/python/rocke/runtime/comgr.py |
Adds optional device-library linking. |
platform/python/rocke/helpers/compile.py |
Detects printing during compilation. |
platform/python/rocke/core/verify.py |
Verifies canonical print records. |
platform/python/rocke/core/lower_llvm.py |
Lowers printing through OCKL. |
platform/python/rocke/core/ir.py |
Adds print records and builder API. |
platform/python/rocke/core/__init__.py |
Exports print record types. |
platform/python/rocke/__init__.py |
Exports print record types publicly. |
platform/dsl_docs/reference/env_flags.md |
Documents print limits. |
platform/cpp/include/rocke/lower_llvm_internal.h |
Adds native lowering state. |
platform/cpp/include/rocke/ir.h |
Adds the C print API and opcode. |
platform/cpp/core/verify.cpp |
Adds native record verification. |
platform/cpp/core/lower_llvm/device_print.cpp |
Implements native OCKL lowering. |
platform/cpp/core/lower_llvm/data.cpp |
Registers OCKL declarations. |
platform/cpp/core/lower_llvm/core.cpp |
Registers lowering and emits format globals. |
platform/cpp/core/ir/device_print.cpp |
Implements native record construction. |
platform/cpp/core/ir/device_print_internal.h |
Declares internal validation helpers. |
platform/cpp/core/ir/core_types.cpp |
Registers opcode name and purity. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| llvm_text, | ||
| isa=isa, | ||
| options=_comgr_options_for_kernel(kernel), | ||
| link_device_libraries=_kernel_requires_device_libraries(kernel), |
| static int parse_device_print_limit( | ||
| const char* name, int default_value, int* value, char* error, size_t error_capacity) | ||
| { | ||
| const char* raw = getenv(name); |
| style = style ? style : "compact"; | ||
| termination = termination ? termination : "ensure_newline"; |
|
|
||
|
|
||
| def _device_print_limit(name: str, default: int) -> int: | ||
| raw = os.environ.get(name) |
| raise TypeError( | ||
| "device_print Value item must contain a rocke SSA Value" | ||
| ) | ||
| logical = item.format or _default_print_format(item.value.type) |
|
This pull request has been inactive for 25 days and will be marked as stale. If you would like to keep this PR open, please:
This PR will be automatically closed in 5 days if no further activity occurs. |


Summary
gpu.device_printText/Value record to the Python and C/C++ rocKE enginesISSUE ID : AICK-1989
Behavior
torfon the ordinary OCKL argument pathROCKE_ENGINE_DEVICE_PRINT_MAX_VALUE_COUNTcontrols the logical record limit;the seven-value OCKL packet width is fixed
Integration
Refreshed against develop
e1e7fdcab9be0f79256e47d653808c7f2e6e1948, resolvingthe four conflicts while retaining current compiler AUTO policy, target resolution,
nontemporal metadata, and native test registration. The new opcode is appended so
all 198 existing opcode values remain unchanged. The installed native print test
is registered, and architecture-domain probes omit external OCKL declarations.
Validation
Validated repair head:
c4044a3cf2ecdd00c78de234fca8d7bb64842cea.print, and nested-print compile-link flag matrix through Python, strict C++, and both.
flavor green under LLVM20, LLVM22, and LLVM23.
differential: three configurations green at each of the three LLVM flavors.
C++, and both backends, with ROCm 7.14.0 and queried LLVM 23.0.0. Covered false
predicate silence, all supported value types, and eight values spanning the
second OCKL packet. The GPU payload used source tree
3bc68dc109cba5f19ddcce6aa73a5b4764ca1bfd; only host test-matrix additionschanged under rocKE afterward.
git diff --checkpassed.Validation limits: the full
ArchDomainRegenerationTestsweep was excluded; otherarchitecture-domain artifact checks passed. The relative-path guard flags
cmake/InstallGpuReferences.cmake:30, which is byte-identical to develop.GPU runtime coverage is limited to gfx950. The relocated artifact predates the
final host test-matrix additions; its production code matches the repaired head.
Scope
This PR covers the checked record, OCKL lowering, and the supported value types
listed above. Typed output, additional dtypes, non-global pointers, vectors,
packed formats, presentation controls, higher-level helpers, and alternative
sinks remain follow-up work.