Repository navigation
[libclc][spirv] Add double support to Vulkan vstore_half/vstorea_half - #242829
Conversation
Implement `double` overloads for `vstore_half` and `vstorea_half` under `cl_khr_fp64`. Round each element with the Vulkan boundary checks, then forward it as `float` to the existing `vstore_half_N` and `vstorea_half_N` helpers. Prerequisite for google/clspv#1752; end-to-end tests will be added there since `libclc/test` currently targets only AMDGPU.
|
Hello @cyrne1-7208 👋 Thank you for submitting a Pull Request (PR) to the LLVM Project. Since this is your first PR, here are a few useful links covering our main contribution policies and review practices.
Please reply to this message to confirm that you have read these policies, especially the LLVM AI Tool Use Policy, and that any AI tool usage has been noted in the PR description. Frequently asked questionsHow do I add reviewers? This PR will be automatically labeled, and the relevant teams will be notified. For some parts of the project, reviewers may also be added automatically. You can also add reviewers manually using the Reviewers section on this page. If you cannot use that section, it is probably because you do not have write permissions for the repository. In that case, you can request a review by tagging reviewers in a comment using What if there are no comments? If you have not received any comments on your PR after a week, you can request a review by pinging the PR with a comment such as “Ping”. The common courtesy ping rate is once a week. Please remember that you are asking for volunteer time from other developers. Are any special GitHub settings required to contribute to LLVM? We only require contributors to have a public email address associated with their GitHub commits, see this section of LLVM Developer Policy for details. If you have questions, feel free to leave a comment on this PR, or ask on LLVM Discord or LLVM Discourse. Thank you, |
|
@wenju-he @rjodinchr could you please review this? |
wenju-he
left a comment
There was a problem hiding this comment.
LGTM. Probably we can de-duplicate with utility functions in clc/lib/generic/shared/clc_vstore.cl as follow-up
|
|
|
Thank you for the review, @wenju-he! I agree we can look into deduplicating with |
|
@cyrne1-7208 Congratulations on having your first Pull Request (PR) merged into the LLVM Project! Your changes will be combined with recent changes from other authors, then tested by our build bots. If there is a problem with a build, you may receive a report in an email or a comment on this PR. Please check whether problems have been caused by your change specifically, as the builds can include changes from many authors. It is not uncommon for your change to be included in a build that fails due to someone else's changes, or infrastructure issues. How to do this, and the rest of the post-merge process, is covered in detail here. If your change does cause a problem, it may be reverted, or you can revert it yourself. This is a normal part of LLVM development. You can fix your changes and open a new PR to merge them again. If you don't get any reports, no action is required from you. Your changes are working as expected, well done! |
Part of google#321 (3/4 of the final `google#321` FP64 completion series). Depends on llvm/llvm-project#242829 (`9fa789fd`) via a `deps.json` LLVM roll. ## Summary Extend `Builtins::BuiltinWithGenericPointer` to recognize `vstorea_half*`, and add lit tests covering FP64 `vstore_half` / `vstorea_half` support implemented upstream in `llvm/llvm-project@9fa789fd`. ## Problem 1. `Builtins::BuiltinWithGenericPointer` matched `vstore_half*` but omitted `vstorea_half(2|3|4|8|16)`. Calls to `vstorea_half*` with a generic pointer failed to retain concrete address-space `libclc` overloads in `GetEquivalentBuiltinsWithoutGenericPointer` and skip pre-lowering in `ReplaceOpenCLBuiltinPass`. 2. `clspv` lacked lit tests exercising `double` `vstore_half` / `vstorea_half` lowering across rounding modes, vector widths, storage options, and generic pointers. ## Change - Extend `Builtins::BuiltinWithGenericPointer` in `lib/Builtins.cpp` with `vstorea_half(2|3|4|8|16)(_rte|_rtz|_rtp|_rtn)?` using `StringRef::starts_with` prefiltering (still excluding non-OpenCL scalar `vstorea_half`). - Add generic-pointer regression coverage in `test/BuiltinsWithGenericPointer/` (`vstorea_half_print.cl`, `vstore_half_double.cl`, and `vstorea_half*` negative cases in `issue-1343.cl`). - Add FP64 `vstore_half` / `vstorea_half` lit tests in `test/HalfStorage/` (`vstore_half_double.cl`, `vstore_half_double_vectors.cl`, `vstore_half8_double.cl`, and `vstore_half_double_rounding.cl`). ## Testing - Added tests covering scalar and vector widths `2`/`3`/`4`/`8` (`-no-16bit-storage=ssbo`, `-vec3-to-vec4`, `--long-vector`, `-O0`), `global`/`local`/`private`/`generic` (`CL2.0`, `CL3.0`, `CLC++`), and IEEE-754 double-rounding/edge cases (`±0`, `+Inf`, `NaN`, saturation), validated with `spirv-val`. - Rebuilt `clspv` locally with `-DCLSPV_EXTERNAL_LIBCLC_DIR` from `llvm/llvm-project@9fa789fd` and verified `lit.py` on the 7 added/modified tests (`7/7` on both `-arch=spirv32` and `-arch=spirv64`) as well as `ninja check-spirv` (`3978/3978`) and `ninja check-spirv-64` (`3978/3978`) pass. - Note: `deps.json` remains at `85a7e596` pending the LLVM roll, so `issue-1343.cl` and `vstorea_half_print.cl` pass standalone while the 5 `double` tests depend on rolling past `9fa789fd`.
Implement
doubleoverloads forvstore_halfandvstorea_halfundercl_khr_fp64. Round each element with the Vulkan boundary checks, then forward it asfloatto the existingvstore_half_Nandvstorea_half_Nhelpers.Prerequisite for google/clspv#1752; end-to-end tests will be added there since
libclc/testcurrently targets only AMDGPU.I used AI assistance to prepare and review this patch.
I reviewed the entire change and take full responsibility for this PR.
Assisted-by: Antigravity Gemini 4 Hydrogen Extra reasoning
Assisted-by: Claude Code Opus 5.5 Max reasoning