Skip to content

[HIPIFY][merge] merge amd-develop into amd-staging#2483

Merged
emankov merged 5 commits intoamd-stagingfrom
upstream_merge_202604021507
Apr 2, 2026
Merged

[HIPIFY][merge] merge amd-develop into amd-staging#2483
emankov merged 5 commits intoamd-stagingfrom
upstream_merge_202604021507

Conversation

@z1-cciauto
Copy link
Copy Markdown

No description provided.

emankov and others added 5 commits March 31, 2026 13:38
…ntation (#2473)

+ [IMP]
  - `cuFile` testing is optional on `Windows`, as `NVIDIA`:
    + doesn't support `cuFile` on `Windows`
    + doesn't ship `cuFile` with `CUDA Toolkit` for `Windows`
  - Whereas, `cuFile` -> `hipFile` hipification is absolutely possible on `Windows`

+ [Misc]
  - Populated the documentation TOC with `cuFile`
… - Part 1 - `Data Types` (#2477)

+ Updated the regenerated `hipify-perl` and `BLAS` `CUDA2HIP` docs accordingly
…g` (#2481)

[Synopsis]
+ The legacy `hipify-perl` AST parsing for host function arguments (e.g., `HIP_SYMBOL` injection) relies on brittle negated character classes `([^,\)]+)`.

+ This fails silently or corrupts the `AST` when arguments contain nested C++ syntax like templates (`<int, float>`), function calls, or C++11 initializer lists (`{1, 2}`).
+ The generated parsing logic was duplicated 9 times across different argument-indexing rules, complicating the `hipify-perl` script and violating the `DRY principle`.

[Solution]
+ [Recursive AST Matching] Replaced rigid negated character classes with recursive Perl `regular expressions (?2)` to perfectly capture and balance complete C++ argument lists.
+ [Robust Tokenization] Implemented a depth-aware character scanner to safely track nested parentheses, brackets, angle brackets, and braces to split arguments correctly without breaking internal C++ commas.
+ [DRY / Footprint Reduction] Refactored the C++ generator to output a single, centralized Perl closure (`$process_args`), eliminating the 9-fold code duplication and simplifying the generated `hipify-perl`.

[Impact]
+ Prevents silent transformation failures and `AST` corruption when `API-mandated` casts (`HIP_SYMBOL`, `reinterpret_cast`) are injected into complex host function calls.
+ Centralizes `hipify-perl` argument parsing logic for future maintainability.

[Testing]
+ `perl -c hipify-perl`
+ Compared old and new `hipify-perl` outputs of all `hipify-clang` unit tests
+ Verified an improved hipification for the following unit tests:
   - reinterpret_cast
   - device_symbols
   - macro_check
   - runtime_functions
   - runtime_functions_11010
   - runtime_functions_before_13000
+ Verified AST integrity on host functions containing nested templates and uniform initialization braces

[ToDo]
+ Fix hipification in comments
+ Implement an automated `hipify-perl` test harness based on the existing `hipify-clang` one
… - Part 2 - `Functions` - final (#2482)

+ Updated the regenerated `hipify-perl` and `BLAS` `CUDA2HIP` docs accordingly
@z1-cciauto z1-cciauto requested review from a team, emankov and searlmc1 as code owners April 2, 2026 19:07
@emankov emankov changed the title merge amd-develop into amd-staging [HIPIFY][merge] merge amd-develop into amd-staging Apr 2, 2026
Copy link
Copy Markdown
Collaborator

@emankov emankov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@emankov emankov added bot bot's change merge labels Apr 2, 2026
@emankov emankov merged commit 1a0013f into amd-staging Apr 2, 2026
3 of 6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bot bot's change merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants