Skip to content

[libclc][spirv] Add double support to Vulkan vstore_half/vstorea_half - #242829

Merged
wenju-he merged 1 commit into
llvm:mainfrom
cyrne1-7208:libclc-vstore-half-double
Nov 16, 2026
Merged

wenju-he merged 1 commit into
llvm:mainfrom
cyrne1-7208:libclc-vstore-half-double

Conversation

@cyrne1-7208

@cyrne1-7208 cyrne1-7208 commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

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.

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

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.
@github-actions

Copy link
Copy Markdown

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.

  • All contributions to LLVM must follow our LLVM AI Tool Use Policy. In particular, if you used AI while working on this PR, remember to add a note to the PR description.
  • The LLVM Code-Review Policy and Practices document contains practical information about the PR process, including how patches are reviewed and accepted, and who can review a PR.
  • Our LLVM Developer Policy describes our expectations for code quality, commit summaries and contains notes on our CI system.

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 questions

How 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 @ followed by their GitHub username.

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,
The LLVM Community

@llvmorg-github-actions llvmorg-github-actions Bot added the libclc libclc OpenCL library label Nov 15, 2026
@cyrne1-7208

Copy link
Copy Markdown
Contributor Author

@wenju-he @rjodinchr could you please review this?

@wenju-he wenju-he left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM. Probably we can de-duplicate with utility functions in clc/lib/generic/shared/clc_vstore.cl as follow-up

@github-actions

Copy link
Copy Markdown

⚠️ We detected that you are using a GitHub private e-mail address to contribute to the repo.
Please turn off Keep my email addresses private setting in your account.
See LLVM Developer Policy and LLVM Discourse for more information.

@cyrne1-7208

Copy link
Copy Markdown
Contributor Author

Thank you for the review, @wenju-he! I agree we can look into deduplicating with clc_vstore.cl as a follow-up. Since I don't have commit access, could you please merge this PR?

@wenju-he
wenju-he merged commit 9fa789f into llvm:main Nov 16, 2026
12 checks passed
@github-actions

Copy link
Copy Markdown

@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!

@cyrne1-7208
cyrne1-7208 deleted the libclc-vstore-half-double branch November 16, 2026 00:30
cyrne1-7208 added a commit to cyrne1-7208/clspv that referenced this pull request Nov 16, 2026
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`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

libclc libclc OpenCL library

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants